Akamai.CPS.psm1
|
function Format-CPSResponse { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline)] [PSCustomObject] $ResponseBody ) process { # Enrollment member if ($ResponseBody.enrollment) { if ($ResponseBody.enrollment -match '[\d]+$') { $ResponseBody | Add-Member -NotePropertyName enrollmentId -NotePropertyValue ([int] $Matches[0]) } } # Basic changes if ($ResponseBody.change) { if ($ResponseBody.change -match '[\d]+$') { $ResponseBody | Add-Member -NotePropertyName changeId -NotePropertyValue ([int] $Matches[0]) } } # Enrollment pendingChanges if ($ResponseBody.pendingChanges) { foreach ($PendingChange in $ResponseBody.pendingChanges) { if ($PendingChange.location -match '[\d]+$') { $PendingChange | Add-Member -NotePropertyName changeId -NotePropertyValue ([int] $Matches[0]) } } } # changes array if ($ResponseBody.changes) { $ChangeIDs = New-Object -TypeName System.Collections.Generic.List[long] $ResponseBody.changes | ForEach-Object { if ($_ -match '[\d]+$') { $ChangeIDs.Add([int] $Matches[0]) } } if ($ChangeIDs.count -gt 0) { $ResponseBody | Add-Member -NotePropertyName changeIds -NotePropertyValue $ChangeIDs } } return $ResponseBody } } 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 Add-CPSThirdPartyCert { [CmdletBinding(DefaultParameterSetName = 'Attributes')] Param( [Parameter(Mandatory)] [int] $EnrollmentID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $ChangeID, [Parameter(ParameterSetName = 'Attributes', Mandatory)] [string] $Certificate, [Parameter(ParameterSetName = 'Attributes')] [string] $TrustChain, [Parameter(ParameterSetName = 'Attributes', Mandatory)] [ValidateSet('RSA', 'ECDSA')] [string] $KeyAlgorithm, [Parameter(ParameterSetName = 'Body', Mandatory, ValueFromPipeline)] $Body, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/changes/$ChangeID/input/update/third-party-cert-and-trust-chain" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.change-id.v1+json' 'content-type' = 'application/vnd.akamai.cps.certificate-and-trust-chain.v2+json' } if ($PSCmdlet.ParameterSetName -eq 'Attributes') { $Body = @{ 'certificatesAndTrustChains' = @( @{ 'certificate' = $Certificate 'keyAlgorithm' = $KeyAlgorithm } ) } if ($TrustChain) { $Body.certificatesAndTrustChains[0]['trustChain'] = $TrustChain } } $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'AdditionalHeaders' = $AdditionalHeaders 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body | Format-CPSResponse } } function Complete-CPSChange { [CmdletBinding()] Param( [Parameter(Mandatory)] [int] $EnrollmentID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $ChangeID, [Parameter(Mandatory)] [ValidateSet('acknowledge', 'deny')] [string] $Acknowledgement, [Parameter()] [string] $Hash, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/changes/$ChangeID/input/update/change-management-ack" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.change-id.v1+json' 'content-type' = 'application/vnd.akamai.cps.acknowledgement.v1+json' } $Body = @{ 'acknowledgement' = $Acknowledgement } if ($Hash) { $AdditionalHeaders['content-type'] = 'application/vnd.akamai.cps.acknowledgement-with-hash.v1+json' $Body['hash'] = $Hash } $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'AdditionalHeaders' = $AdditionalHeaders 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body | Format-CPSResponse } } function Confirm-CPSLetsEncryptChallengesCompleted { [CmdletBinding()] Param( [Parameter(Mandatory)] [int] $EnrollmentID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $ChangeID, [Parameter(Mandatory)] [ValidateSet('acknowledge', 'deny')] [string] $Acknowledgement, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/changes/$ChangeID/input/update/lets-encrypt-challenges-completed" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.change-id.v1+json' 'content-type' = 'application/vnd.akamai.cps.acknowledgement.v1+json' } $Body = @{ 'acknowledgement' = $Acknowledgement } $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'AdditionalHeaders' = $AdditionalHeaders 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body | Format-CPSResponse } } function Confirm-CPSPostVerificationWarnings { [CmdletBinding()] Param( [Parameter(Mandatory)] [int] $EnrollmentID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $ChangeID, [Parameter(Mandatory)] [ValidateSet('acknowledge', 'deny')] [string] $Acknowledgement, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/changes/$ChangeID/input/update/post-verification-warnings-ack" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.change-id.v1+json' 'content-type' = 'application/vnd.akamai.cps.acknowledgement.v1+json' } $Body = @{ 'acknowledgement' = $Acknowledgement } $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'AdditionalHeaders' = $AdditionalHeaders 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body | Format-CPSResponse } } function Confirm-CPSPreVerificationWarnings { [CmdletBinding()] Param( [Parameter(Mandatory)] [int] $EnrollmentID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $ChangeID, [Parameter(Mandatory)] [ValidateSet('acknowledge', 'deny')] [string] $Acknowledgement, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/changes/$ChangeID/input/update/pre-verification-warnings-ack" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.change-id.v1+json' 'content-type' = 'application/vnd.akamai.cps.acknowledgement.v1+json' } $Body = @{ 'acknowledgement' = $Acknowledgement } $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'AdditionalHeaders' = $AdditionalHeaders 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body | Format-CPSResponse } } function Get-CPSActiveCertificate { [CmdletBinding()] Param( [Parameter(ValueFromPipeline)] [string] $ContractID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/active-certificates" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.active-certificates.v2+json' } $QueryParameters = @{ 'contractId' = $ContractID } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'QueryParameters' = $QueryParameters 'AdditionalHeaders' = $AdditionalHeaders 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body.enrollments } } function Get-CPSCertificateHistory { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [Alias('id')] [int] $EnrollmentID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/history/certificates" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.certificate-history.v2+json' } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'AdditionalHeaders' = $AdditionalHeaders 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body.certificates } } function Get-CPSChangeHistory { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [Alias('id')] [int] $EnrollmentID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/history/changes" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.change-history.v5+json' } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'AdditionalHeaders' = $AdditionalHeaders 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body.changes } } function Get-CPSChangeStagingStatus { [CmdletBinding()] Param( [Parameter(Mandatory)] [int] $EnrollmentID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $ChangeID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/changes/$ChangeID/input/info/change-management-info" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.change-management-info.v6+json' } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'AdditionalHeaders' = $AdditionalHeaders 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Get-CPSChangeStatus { [CmdletBinding()] Param( [Parameter(Mandatory)] [int] $EnrollmentID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $ChangeID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/changes/$ChangeID" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.change.v2+json' } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'AdditionalHeaders' = $AdditionalHeaders 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Get-CPSCSR { [CmdletBinding()] Param( [Parameter(Mandatory)] [int] $EnrollmentID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $ChangeID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/changes/$ChangeID/input/info/third-party-csr" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.csr.v2+json' } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'AdditionalHeaders' = $AdditionalHeaders 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Get-CPSDeployment { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [Alias('id')] [int] $EnrollmentID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/deployments" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.deployments.v8+json' } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'AdditionalHeaders' = $AdditionalHeaders 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Get-CPSDeploymentSchedule { [CmdletBinding()] Param( [Parameter(Mandatory)] [int] $EnrollmentID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $ChangeID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/changes/$ChangeID/deployment-schedule" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.deployment-schedule.v1+json' } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'AdditionalHeaders' = $AdditionalHeaders 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Get-CPSDVHistory { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [Alias('id')] [int] $EnrollmentID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/dv-history" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.dv-history.v1+json' } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'AdditionalHeaders' = $AdditionalHeaders 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body.results } } function Get-CPSEnrollment { [CmdletBinding(DefaultParameterSetName = 'Get all')] Param( [Parameter(ParameterSetName = 'Get one', ValueFromPipeline)] [int] $EnrollmentID, [Parameter(ParameterSetName = 'Get all')] [string] $ContractID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { if ($EnrollmentID) { $Path = "/cps/v2/enrollments/$EnrollmentID" } else { $Path = "/cps/v2/enrollments" } if ($PSBoundParameters.EnrollmentID) { $AcceptHeader = 'application/vnd.akamai.cps.enrollment.v12+json' } else { $AcceptHeader = 'application/vnd.akamai.cps.enrollments.v12+json' } $AdditionalHeaders = @{ 'accept' = $AcceptHeader } $QueryParameters = @{ 'contractId' = $ContractID } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'QueryParameters' = $QueryParameters 'AdditionalHeaders' = $AdditionalHeaders 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams if ($PSBoundParameters.EnrollmentID) { return $Response.Body | Format-CPSResponse } else { return $Response.Body.enrollments | Format-CPSResponse } } } function Get-CPSLetsEncryptChallenges { [CmdletBinding()] Param( [Parameter(Mandatory)] [int] $EnrollmentID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $ChangeID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/changes/$ChangeID/input/info/lets-encrypt-challenges" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.dv-challenges.v2+json' } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'AdditionalHeaders' = $AdditionalHeaders 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Get-CPSPostVerificationWarnings { [CmdletBinding()] Param( [Parameter(Mandatory)] [int] $EnrollmentID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $ChangeID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/changes/$ChangeID/input/info/post-verification-warnings" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.warnings.v1+json' } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'AdditionalHeaders' = $AdditionalHeaders 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Get-CPSPreVerificationWarnings { [CmdletBinding()] Param( [Parameter(Mandatory)] [int] $EnrollmentID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $ChangeID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/changes/$ChangeID/input/info/pre-verification-warnings" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.warnings.v1+json' } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'AdditionalHeaders' = $AdditionalHeaders 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Get-CPSProductionDeployment { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [Alias('id')] [int] $EnrollmentID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/deployments/production" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.deployment.v8+json' } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'AdditionalHeaders' = $AdditionalHeaders 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Get-CPSStagingDeployment { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [Alias('id')] [int] $EnrollmentID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/deployments/staging" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.deployment.v8+json' } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'AdditionalHeaders' = $AdditionalHeaders 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function New-CPSEnrollment { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $ContractID, [Parameter(Mandatory, ValueFromPipeline)] $Body, [Parameter()] [string] $DeployNotAfter, [Parameter()] [string] $DeployNotBefore, [Parameter()] [switch] $AllowDuplicateCN, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) begin { $DateMatch = '[\d]{4}-[\d]{2}-[\d]{2}' if (($DeployNotAfter -or $DeployNotBefore) -and ($DeployNotAfter -notmatch $DateMatch -or $DeployNotBefore -notmatch $DateMatch)) { throw "ERROR: DeployNotAfter & DeployNotBefore must be in the format 'YYYY-MM-DD'" } $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.enrollment-status.v1+json' 'content-type' = 'application/vnd.akamai.cps.enrollment.v12+json' } $Path = "/cps/v2/enrollments" $QueryParameters = @{ 'contractId' = $ContractID 'deploy-not-after' = $DeployNotAfter 'deploy-not-before' = $DeployNotBefore 'allowDuplicateCN' = $PSBoundParameters.AllowDuplicateCN } } process { # Cleanup request body to remove additional elements added in Get-CPSEnrollment $Body = Get-BodyObject -Source $Body if ($Body.pendingChanges) { $Body.pendingChanges | ForEach-Object { if ($_.changeId) { $_.PSObject.Members.Remove('changeId') } } } $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'AdditionalHeaders' = $AdditionalHeaders 'QueryParameters' = $QueryParameters 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body | Format-CPSResponse } } function Remove-CPSChange { [CmdletBinding()] Param( [Parameter(Mandatory)] [int] $EnrollmentID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $ChangeID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/changes/$ChangeID" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.change-id.v1+json' } $RequestParams = @{ 'Path' = $Path 'Method' = 'DELETE' 'AdditionalHeaders' = $AdditionalHeaders 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body | Format-CPSResponse } } function Remove-CPSEnrollment { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [Alias('id')] [int] $EnrollmentID, [Parameter()] [switch] $AllowCancelPendingChanges, [Parameter()] [string] $DeployNotAfter, [Parameter()] [string] $DeployNotBefore, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $DateMatch = '[\d]{4}-[\d]{2}-[\d]{2}' if (($DeployNotAfter -or $DeployNotBefore) -and ($DeployNotAfter -notmatch $DateMatch -or $DeployNotBefore -notmatch $DateMatch)) { throw "ERROR: DeployNotAfter & DeployNotBefore must be in the format 'YYYY-MM-DD'" } $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.enrollment-status.v1+json' } $Path = "/cps/v2/enrollments/$EnrollmentID" $QueryParameters = @{ 'allow-cancel-pending-changes' = $PSBoundParameters.AllowCancelPendingChanges 'deploy-not-after' = $DeployNotAfter 'deploy-not-before' = $DeployNotBefore } $RequestParams = @{ 'Path' = $Path 'Method' = 'DELETE' 'AdditionalHeaders' = $AdditionalHeaders 'QueryParameters' = $QueryParameters 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body | Format-CPSResponse } } function Set-CPSDeploymentSchedule { [CmdletBinding()] Param( [Parameter(Mandatory)] [int] $EnrollmentID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $ChangeID, [Parameter()] [string] $NotAfter, [Parameter()] [string] $NotBefore, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/cps/v2/enrollments/$EnrollmentID/changes/$ChangeID/deployment-schedule" $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.change-id.v1+json' 'content-type' = 'application/vnd.akamai.cps.deployment-schedule.v1+json' } $Body = @{} if ($NotAfter) { $Body['notAfter'] = $NotAfter } if ($NotBefore) { $Body['notBefore'] = $NotBefore } $RequestParams = @{ 'Path' = $Path 'Method' = 'PUT' 'AdditionalHeaders' = $AdditionalHeaders 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body | Format-CPSResponse } } function Set-CPSEnrollment { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [Alias('id')] [int] $EnrollmentID, [Parameter(Mandatory, ValueFromPipeline)] $Body, [Parameter()] [switch] $AllowCancelPendingChanges, [Parameter()] [switch] $AllowStagingBypass, [Parameter()] [string] $DeployNotAfter, [Parameter()] [string] $DeployNotBefore, [Parameter()] [switch] $ForceRenewal, [Parameter()] [switch] $RenewalDateCheckOverride, [Parameter()] [switch] $AllowMissingCertificateAddition, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) begin { $DateMatch = '[\d]{4}-[\d]{2}-[\d]{2}' if (($DeployNotAfter -or $DeployNotBefore) -and ($DeployNotAfter -notmatch $DateMatch -or $DeployNotBefore -notmatch $DateMatch)) { throw "ERROR: DeployNotAfter & DeployNotBefore must be in the format 'YYYY-MM-DD'" } $QueryParameters = @{ 'allow-cancel-pending-changes' = $PSBoundParameters.AllowCancelPendingChanges 'allow-staging-bypass' = $PSBoundParameters.AllowStagingBypass 'force-renewal' = $PSBoundParameters.ForceRenewal 'renewal-date-check-override' = $PSBoundParameters.RenewalDateCheckOverride 'allow-missing-certificate-addition' = $PSBoundParameters.AllowMissingCertificateAddition } $AdditionalHeaders = @{ 'accept' = 'application/vnd.akamai.cps.enrollment-status.v1+json' 'content-type' = 'application/vnd.akamai.cps.enrollment.v12+json' } } process { $Path = "/cps/v2/enrollments/$EnrollmentID" # Cleanup request body to remove additional elements added in Get-CPSEnrollment $Body = Get-BodyObject -Source $Body if ($Body.pendingChanges) { $Body.pendingChanges | ForEach-Object { if ($_.changeId) { $_.PSObject.Members.Remove('changeId') } } } $RequestParams = @{ 'Path' = $Path 'Method' = 'PUT' 'AdditionalHeaders' = $AdditionalHeaders 'QueryParameters' = $QueryParameters 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey 'Debug' = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body | Format-CPSResponse } } # SIG # Begin signature block # MIIKmAYJKoZIhvcNAQcCoIIKiTCCCoUCAQExDzANBglghkgBZQMEAgEFADB5Bgor # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG # KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCCvrD6hX4MGpTN3 # u3KmlaVK9SLgipwUEOE18/ydD62DLaCCB1owggdWMIIFPqADAgECAhAGRzH371Sh # X6hjGl1wSSyYM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