Powershell SourceTube API Script

powershellsourcetubeapiscript

Powershell SourceTube API Script is a Powershell script which lets you control your SVN repositories on SourceTube.

Howto:

  1. Download SourceTubeAPI.zip
  2. Extract the Files where ever you wanna save the powershell script
  3. Run the script
  4. Now you can run the Powershell Cmdlets

Powershell SourceTube API Script Commands:

  • Get-SourceTubeUsage
  • Get-SourceTubeSVN
  • Create-SourceTubeSVN

Changelog:

1.0

  • Release 1.0

The Script:

#
#*****************************************************************
#
# Powershell SourceTube API Script v1 $Rev: 754 $
# (c) 2004-2010 Thomas Maurer. All rights reserved.
# created by Thomas Maurer
#
# http://www.thomasmaurer.ch
# http://www.thomasmaurer.ch/projects
#
# last Update by $Author: tmaurer $ on $Date: 2010-12-05 15:23:33 +0100 (So, 05 Dez 2010) $
#
# Version 1.0.0
#
#*****************************************************************
#

# Individual Config
$SourceTubeName = "YOURACCOUNTNAME"
$ApiPassword  = "YOURAPIPASSWORD"

# SourceTube Config - Basicliy don't change anything
$listSVNURL = "http://" + $SourceTubeName + ".sourcetube.net/api/sourcetube/subversion"
$createSVNURL = "http://" + $SourceTubeName + ".sourcetube.net/api/sourcetube/subversion?repository="
$UsageURL = "http://" + $SourceTubeName + ".sourcetube.net/api/sourcetube/usage"
$ApiUser = "apiuser"

# Welcome
Write-Host "******************************************************************" -BackgroundColor Black -ForegroundColor White
Write-Host "                                                                  " -BackgroundColor Black -ForegroundColor White
Write-Host " Welcome to the Powershell SourceTube API Script                  " -BackgroundColor Black -ForegroundColor White
Write-Host "                                                                  " -BackgroundColor Black -ForegroundColor White
Write-Host " (c) 2010 Thomas Maurer www.thomasmaurer.ch/projects              " -BackgroundColor Black -ForegroundColor White
Write-Host "                                                                  " -BackgroundColor Black -ForegroundColor White
Write-Host "******************************************************************" -BackgroundColor Black -ForegroundColor White
Write-Host "                                                                  " -BackgroundColor Black -ForegroundColor White
Write-Host " for Help use the Get-SourceTubeHelp                              " -BackgroundColor Black -ForegroundColor White
Write-Host "                                                                  " -BackgroundColor Black -ForegroundColor White

# Get SourceTube Usage
function Get-SourceTubeUsage {
	begin{
		$URL = $UsageURL
	}
    process {
		[Object]$WebClient = New-Object System.Net.WebClient
		$WebClient.Credentials = New-Object System.Net.NetworkCredential($ApiUser, $ApiPassword)
		$WebClient.DownloadString($URL)
	}
}

# Get SourceTube SVN Repositories
function Get-SourceTubeSVN {
	begin{
		$URL = $listSVNURL
	}
    process {
		[Object]$WebClient = New-Object System.Net.WebClient
		$WebClient.Credentials = New-Object System.Net.NetworkCredential($ApiUser, $ApiPassword)
		$WebClient.DownloadString($URL)
	}
}

# Create SVN Repository
function Create-SourceTubeSVN {
	param(
		[String]$SVNName
	)
	begin{
		$URL = $createSVNURL + $SVNName
	}
    process {
		$req = [System.Net.HttpWebRequest]::Create($URL)
 		$req.Method = "POST"
 		$req.Credentials = New-Object System.Net.NetworkCredential($apiuser,$ApiPassword)
 		$req.GetResponse()
	}
}	

# Function to show a quick Help for SourceTube API Script
function get-SourceTubeHelp {
    process {
	Write-Host " "
	Write-Host " Powershell SourceTube API Script Help"
	Write-Host " "
	Write-Host "********************************************************"
	Write-Host " "
	Write-Host " Commands"
	Write-Host " "
	Write-Host " Get-SourceTubeUsage			Get Usage"
	Write-Host " Get-SourceTubeSVN			Get List of SVN Repositories"
	Write-Host " Create-SourceTubeSVN			Create a new SVN Repository"
	}
}

One thought on “Powershell SourceTube API Script

  1. Pingback: API Zugriff mit Powershell — sourceTube

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>