Akamai.Datastream.psm1
|
function Get-BodyObject { [CmdletBinding()] Param( [Parameter(Mandatory)] $Source ) if ($Source -is 'String') { # Trim whitespace $Source = $Source.Trim() # Handle JSON array if ($Source.StartsWith('[')) { $BodyObject = ConvertFrom-Json -InputObject $Source -AsArray -NoEnumerate } # Handle standard JSON object elseif ($Source.StartsWith('{') -and $Source.EndsWith('}')) { $BodyObject = ConvertFrom-Json -InputObject $Source } # If none of the above, just use string as-is else { $BodyObject = $Source } } elseif ($Source -is 'Hashtable') { $BodyObject = [PScustomObject] $Source } elseif ($Source -is 'PSCustomObject' -or $Source -is 'Object' -or $Source -is 'Object[]') { $BodyObject = $Source } else { throw "Source param is of an unhandled type '$($Source.GetType().Name)'" } return $BodyObject } function Get-DataStream { [CmdletBinding(DefaultParameterSetName = 'Get all')] Param( [Parameter()] [ValidateSet('cdn', 'edgeworkers', 'edns', 'gtm')] [string] $LogType = 'cdn', # Defaulting to CDN for backward compatibility [Parameter(ParameterSetName = 'Get one')] [int] $StreamID, [Parameter(ParameterSetName = 'Get all')] [int] $GroupID, [Parameter(ParameterSetName = 'Get all')] [string] $ObjectName, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) if ($StreamID) { $Path = "/datastream-config-api/v3/log/$LogType/streams/$StreamID" } else { $Path = "/datastream-config-api/v3/log/$LogType/streams" } $QueryParameters = @{ 'groupId' = $PSBoundParameters.GroupID 'objectName' = $ObjectName } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'QueryParameters' = $QueryParameters 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } function Get-DataStreamActivationHistory { [CmdletBinding()] Param( [Parameter()] [ValidateSet('cdn', 'edgeworkers', 'edns', 'gtm')] [string] $LogType = 'cdn', # Defaulting to CDN for backward compatibility [Parameter(Mandatory)] [string] $StreamID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) $Path = "/datastream-config-api/v3/log/$LogType/streams/$StreamID/activation-history" $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } function Get-DataStreamDatasets { [CmdletBinding()] Param( [Parameter()] [ValidateSet('cdn', 'edgeworkers', 'edns', 'gtm')] [string] $LogType = 'cdn', # Defaulting to CDN for backward compatibility [Parameter()] [string] $ProductID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) $Path = "/datastream-config-api/v3/log/$LogType/datasets-fields" $QueryParameters = @{ 'productId' = $ProductID } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'QueryParameters' = $QueryParameters 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body.datasetFields } function Get-DatastreamEDNSZones { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $ContractID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) $Path = "/datastream-config-api/v3/log/edns/contracts/$ContractID/zones" $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body.zones } function Get-DatastreamGroups { [CmdletBinding()] Param( [Parameter()] [ValidateSet('cdn', 'edgeworkers', 'edns', 'gtm')] [string] $LogType = 'cdn', # Defaulting to CDN for backward compatibility [Parameter()] [string] $ContractID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) $Path = "/datastream-config-api/v3/log/$LogType/groups" $QueryParameters = @{ 'contractId' = $ContractID } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'QueryParameters' = $QueryParameters 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body.groups } function Get-DatastreamGTMProperties { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $ContractID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) $Path = "/datastream-config-api/v3/log/gtm/contracts/$ContractID/properties" $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body.properties } function Get-DataStreamHistory { [CmdletBinding()] Param( [Parameter()] [ValidateSet('cdn', 'edgeworkers', 'edns', 'gtm')] [string] $LogType = 'cdn', # Defaulting to CDN for backward compatibility [Parameter(Mandatory)] [string] $StreamID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) $Path = "/datastream-config-api/v3/log/$LogType/streams/$StreamID/history" $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } function Get-DataStreamMetrics { [CmdletBinding()] Param( [Parameter()] [string] $StreamID, [Parameter()] [string] $Start, [Parameter()] [string] $End, [Parameter()] [int] $GroupID, [Parameter()] [ValidateSet('FIVE_MINUTE', 'HOUR', 'DAY')] [string] $AggregationInterval, [Parameter()] [switch] $IncludeDetails, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) $Path = "/datastream-config-api/v3/log/streams/metrics" $QueryParameters = @{ 'streamId' = $PSBoundParameters.StreamID 'start' = $PSBoundParameters.Start 'end' = $PSBoundParameters.End 'aggregationInterval' = $AggregationInterval 'includeDetails' = $PSBoundParameters.includeDetails } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'QueryParameters' = $QueryParameters 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } function Get-DataStreamProperties { [CmdletBinding()] Param( [Parameter(Mandatory)] [int] $GroupID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) $Path = "/datastream-config-api/v3/log/cdn/groups/$GroupID/properties" $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body.properties } function New-DataStream { [CmdletBinding()] Param( [Parameter()] [ValidateSet('cdn', 'edgeworkers', 'edns', 'gtm')] [string] $LogType = 'cdn', # Defaulting to CDN for backward compatibility [Parameter(Mandatory, ValueFromPipeline)] $Body, [Parameter()] [switch] $Activate, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) begin {} process { $Path = "/datastream-config-api/v3/log/$LogType/streams" $QueryParameters = @{ 'activate' = $PSBoundParameters.Activate.IsPresent } $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'QueryParameters' = $QueryParameters 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } end {} } function New-DataStreamActivation { [CmdletBinding()] [Alias('Deploy-DataStream')] Param( [Parameter()] [ValidateSet('cdn', 'edgeworkers', 'edns', 'gtm')] [string] $LogType = 'cdn', # Defaulting to CDN for backward compatibility [Parameter(Mandatory)] [int] $StreamID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) $Path = "/datastream-config-api/v3/log/$LogType/streams/$StreamID/activate" $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } function New-DataStreamDeactivation { [CmdletBinding()] [Alias('Disable-DataStream')] Param( [Parameter()] [ValidateSet('cdn', 'edgeworkers', 'edns', 'gtm')] [string] $LogType = 'cdn', # Defaulting to CDN for backward compatibility [Parameter(Mandatory)] [int] $StreamID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) $Path = "/datastream-config-api/v3/log/$LogType/streams/$StreamID/deactivate" $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } function Remove-DataStream { [CmdletBinding()] Param( [Parameter()] [ValidateSet('cdn', 'edgeworkers', 'edns', 'gtm')] [string] $LogType = 'cdn', # Defaulting to CDN for backward compatibility [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $StreamID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) begin {} process { $Path = "/datastream-config-api/v3/log/$logType/streams/$StreamID" $RequestParams = @{ 'Path' = $Path 'Method' = 'DELETE' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } end {} } function Set-DataStream { [CmdletBinding()] Param( [Parameter()] [ValidateSet('cdn', 'edgeworkers', 'edns', 'gtm')] [string] $LogType = 'cdn', # Defaulting to CDN for backward compatibility [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [int] $StreamID, [Parameter(Mandatory, ValueFromPipeline)] $Body, [Parameter()] [switch] $Activate, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) begin {} process { $Path = "/datastream-config-api/v3/log/$LogType/streams/$StreamID" $QueryParameters = @{ 'activate' = $PSBoundParameters.Activate.IsPresent } $RequestParams = @{ 'Path' = $Path 'Method' = 'PUT' 'QueryParameters' = $QueryParameters 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } end {} } function Update-DataStream { [CmdletBinding()] Param( [Parameter()] [ValidateSet('cdn', 'edgeworkers', 'edns', 'gtm')] [string] $LogType = 'cdn', # Defaulting to CDN for backward compatibility [Parameter(Mandatory)] [int] $StreamID, [Parameter(Mandatory, ValueFromPipeline)] $Body, [Parameter()] [switch] $Activate, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) begin { $CollatedUpdates = New-Object -TypeName System.Collections.Generic.List[object] } process { if ($Body -isnot 'String') { if ($Body -is 'array') { if ($Body.Count -eq 1) { $CollatedUpdates.Add($Body) } elseif ($Body.Count -gt 1) { $CollatedUpdates.AddRange($Body) } } elseif ($Body -is 'hashtable' -or $Body -is 'PSCustomObject') { $CollatedUpdates.Add($Body) } } } end { $Path = "/datastream-config-api/v3/log/$LogType/streams/$StreamID" if ($CollatedUpdates.Count -gt 0) { $Body = $CollatedUpdates } $QueryParameters = @{ 'activate' = $PSBoundParameters.Activate.IsPresent } $RequestParams = @{ 'Path' = $Path 'Method' = 'PATCH' 'QueryParameters' = $QueryParameters 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } # SIG # Begin signature block # MIIKmAYJKoZIhvcNAQcCoIIKiTCCCoUCAQExDzANBglghkgBZQMEAgEFADB5Bgor # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG # KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCBYSXN3ih1tB+As # +fEy9zr+ky7arXSBWFpo3ljOIbQ4qaCCB1owggdWMIIFPqADAgECAhAGRzH371Sh # X6hjGl1wSSyYMA0GCSqGSIb3DQEBCwUAMGkxCzAJBgNVBAYTAlVTMRcwFQYDVQQK # Ew5EaWdpQ2VydCwgSW5jLjFBMD8GA1UEAxM4RGlnaUNlcnQgVHJ1c3RlZCBHNCBD # b2RlIFNpZ25pbmcgUlNBNDA5NiBTSEEzODQgMjAyMSBDQTEwHhcNMjYwMjI1MDAw # MDAwWhcNMjcwMzEwMjM1OTU5WjCB3jETMBEGCysGAQQBgjc8AgEDEwJVUzEZMBcG # CysGAQQBgjc8AgECEwhEZWxhd2FyZTEdMBsGA1UEDwwUUHJpdmF0ZSBPcmdhbml6 # YXRpb24xEDAOBgNVBAUTBzI5MzM2MzcxCzAJB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