Skip to content

Instantly share code, notes, and snippets.

@CameronHall
Created September 18, 2019 07:04
Show Gist options
  • Save CameronHall/f67b9514bd84c4a5715e703811df3628 to your computer and use it in GitHub Desktop.
Save CameronHall/f67b9514bd84c4a5715e703811df3628 to your computer and use it in GitHub Desktop.
Synergy Wholesale API - Powershell Client
$ResellerID = <ResellerID>
$APIKey = "<APIKey>"
$APIAuth = @{
resellerID = $ResellerID
apiKey = $APIKey
}
$APISession = New-WebServiceProxy -Uri "https://api.synergywholesale.com/?wsdl"
function DomainInfo() {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[System.Web.Services.Protocols.SoapHttpClientProtocol]$APISession,
[Parameter(Mandatory = $true)]
[hashtable]$APIAuth,
[Parameter(Mandatory = $true)]
[string]$Domain
)
$APIRequest = $APIAuth.Clone()
$APIRequest.Add("domainName", $Domain)
$APISession.domainInfo($APIRequest)
}
function ListDNSZone () {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[System.Web.Services.Protocols.SoapHttpClientProtocol]$APISession,
[Parameter(Mandatory = $true)]
[hashtable]$APIAuth,
[Parameter(Mandatory = $true)]
[string]$Domain
)
$APIRequest = $APIAuth.Clone()
$APIRequest.Add("domainName", $Domain)
$APISession.listDNSZone($APIRequest)
}
function AddDNSRecord () {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[System.Web.Services.Protocols.SoapHttpClientProtocol]$APISession,
[Parameter(Mandatory = $true)]
[hashtable]$APIAuth,
[Parameter(Mandatory = $true)]
[string]$Domain,
[Parameter(Mandatory = $true)]
[ValidateSet("A", "AAAA", "CNAME", "MX", "TXT")]
[string]$Type,
[Parameter(Mandatory = $true)]
[string]$Hostname,
[Parameter(Mandatory = $true)]
[string]$Value,
[Parameter(Mandatory = $true)]
[string]$TTL,
[Parameter(Mandatory = $false)]
[string]$MXPriority = 10
)
$APIRequest = $APIAuth.Clone()
$APIRequest.Add("domainName", $Domain)
$APIRequest.Add("recordType", $Type)
$APIRequest.Add("recordName", $Hostname)
$APIRequest.Add("recordContent", $Value)
$APIRequest.Add("recordTTL", $TTL)
if ($Type -eq "MX") {
$APIRequest.Add("MXPriority", $MXPriority)
}
$APISession.addDNSRecord($APIRequest)
}
function DeleteDNSZone() {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[System.Web.Services.Protocols.SoapHttpClientProtocol]$APISession,
[Parameter(Mandatory = $true)]
[hashtable]$APIAuth,
[Parameter(Mandatory = $true)]
[string]$Domain
)
$APIRequest = $APIAuth.Clone()
$APIRequest.Add("domainName", $Domain)
$APISession.deleteDNSZone($APIRequest)
}
function AddDNSZone() {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[System.Web.Services.Protocols.SoapHttpClientProtocol]$APISession,
[Parameter(Mandatory = $true)]
[hashtable]$APIAuth,
[Parameter(Mandatory = $true)]
[string]$Domain
)
$APIRequest = $APIAuth.Clone()
$APIRequest.Add("domainName", $Domain)
$APISession.addDNSZone($APIRequest)
}
function UpdateNameServers() {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[System.Web.Services.Protocols.SoapHttpClientProtocol]$APISession,
[Parameter(Mandatory = $true)]
[hashtable]$APIAuth,
[Parameter(Mandatory = $true)]
[string]$Domain,
[Parameter(Mandatory = $false)]
[array]$Nameservers = @("ns1.nameserver.net.au", "ns2.nameserver.net.au", "ns3.nameserver.net.au"),
[Parameter(Mandatory = $false)]
[int]$DNSConfig = 4, # Sets dnsConfig to 4 if value not specified
[Parameter(Mandatory = $false)]
[int]$skipDefaultARecords = 1
)
$APIRequest = $APIAuth.Clone()
$APIRequest.Add("domainName", $Domain)
$APIRequest.Add("dnsConfig", $DNSConfig)
$APIRequest.Add("nameServers", $Nameservers)
$APIRequest.Add("skipDefaultARecords", $skipDefaultARecords)
# Writes $APIRequest to console
Write-Output $APIRequest
$result = $APISession.updateNameServers($APIRequest)
Write-Output $result.GetWebRequest();
}
# cls
# ListDNSZone -APISession $APISession -APIAuth $APIAuth -Domain "<your_domain>"
# DomainInfo -APISession $APISession -APIAuth $APIAuth -Domain "<your_domain>"
# (ListDNSZone -APISession $APISession -APIAuth $APIAuth -Domain "<your_domain>").records | ft
#AddDNSRecord -APISession $APISession -APIAuth $APIAuth -Domain "<your_domain>" -Type "A" -Hostname "test.<your_domain>" -Value "1.1.1.1" -TTL 3660
#AddDNSZone -APISession $APISession -APIAuth $APIAuth -Domain "<your_domain>"
#DeleteDNSZone -APISession $APISession -APIAuth $APIAuth -Domain "<your_domain>"
Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1api_synergywholesale_com__wsdl.updateNameServersRequest -APISession $APISession -APIAuth $APIAuth -Domain "<your_domain>" -DNSConfig 4
# DomainInfo -APISession $APISession -APIAuth $APIAuth -Domain "<your_domain>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment