Akamai.Netstorage.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 Add-NetstorageUploadAccountFTPKey { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $UploadAccountID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [string] $Key, [Parameter()] [string] $Comments, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/keys/ftp" $Body = @{ key = $Key } if ($null -ne $Comments) { $Body.comments = $Comments } $RequestParams = @{ 'Path' = $Path 'Method' = 'PUT' 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Add-NetstorageUploadAccountHTTPKey { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $UploadAccountID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/keys/g2o" $RequestParams = @{ Path = $Path Method = 'PUT' Body = $Body EdgeRCFile = $EdgeRCFile Section = $Section AccountSwitchKey = $AccountSwitchKey Debug = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Add-NetstorageUploadAccountRSyncKey { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $UploadAccountID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [string] $Key, [Parameter()] [string] $Comments, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/keys/rsync" $Body = @{ key = $Key } if ($null -ne $Comments) { $Body.comments = $Comments } $RequestParams = @{ 'Path' = $Path 'Method' = 'PUT' 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Add-NetstorageUploadAccountSSHKey { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $UploadAccountID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [string] $Key, [Parameter()] [string] $EmailID, [Parameter()] [string] $Comments, [Parameter()] [switch] $Update, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/keys/ssh/$Identity" $QueryParameters = @{ 'update' = $PSBoundParameters.Update } $Body = @{ key = $Key } if ($EmailID) { $Body.emailId = $EmailID } if ($Comments) { $Body.comments = $Comments } $RequestParams = @{ 'Path' = $Path 'Method' = 'PUT' 'QueryParameters' = $QueryParameters 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Disable-NetstorageUploadAccount { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [string] $UploadAccountID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/disable" $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Disable-NetstorageUploadAccountFTPKey { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $UploadAccountID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [Alias('id')] [string] $Identity, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/keys/ftp/$Identity/disable" $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Disable-NetstorageUploadAccountHTTPKey { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $UploadAccountID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [Alias('id')] [string] $Identity, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/keys/g2o/$Identity/disable" $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 Disable-NetstorageUploadAccountRSyncKey { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $UploadAccountID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [Alias('id')] [string] $Identity, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/keys/rsync/$Identity/disable" $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Disable-NetstorageUploadAccountSSHKey { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $UploadAccountID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [Alias('id')] [string] $Identity, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/keys/ssh/$Identity/disable" $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Enable-NetstorageUploadAccount { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [string] $UploadAccountID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/enable" $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Enable-NetstorageUploadAccountFTPKey { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $UploadAccountID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [Alias('id')] [string] $Identity, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/keys/ftp/$Identity/enable" $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Enable-NetstorageUploadAccountHTTPKey { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $UploadAccountID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [Alias('id')] [string] $Identity, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/keys/g2o/$Identity/enable" $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 Enable-NetstorageUploadAccountRSyncKey { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $UploadAccountID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [Alias('id')] [string] $Identity, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/keys/rsync/$Identity/enable" $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Enable-NetstorageUploadAccountSSHKey { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $UploadAccountID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [Alias('id')] [string] $Identity, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/keys/ssh/$Identity/enable" $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Get-NetstorageCPCode { [CmdletBinding()] Param( [Parameter()] [switch] $Unused, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { if ($Unused) { $Path = "/storage/v1/cpcodes/unused" } else { $Path = "/storage/v1/cpcodes/used" } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body.items } } function Get-NetstorageCPCodePurgeRoutine { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $CPCodeID, [Parameter()] [string] $AgeDeletionDirectoryPrefix, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/cpcodes/$CPCodeID/age-deletions" $QueryParameters = @{ 'ageDeletionDirectoryPrefix' = $AgeDeletionDirectoryPrefix } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'QueryParameters' = $QueryParameters 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return @($Response.Body) } } function Get-NetstorageDirectory { [CmdletBinding(DefaultParameterSetName = 'Directory')] Param( [Parameter(Mandatory, Position = 1, ValueFromPipeline)] [string] $Path, [Parameter(ParameterSetName = 'Directory')] [string] $Prefix, [Parameter(ParameterSetName = 'List')] [switch] $Recurse, [Parameter(ParameterSetName = 'Directory')] [string] $StartPath, [Parameter()] [string] $EndPath, [Parameter()] [int] $MaxEntries, [Parameter()] [string] $Encoding, [Parameter()] [switch] $SlashBoth, [Parameter()] [Alias('AuthFile')] [string] $NSRCFile, [Parameter()] [string] $Section ) process { $Action = 'dir' if ($PSCmdlet.ParameterSetName -eq 'List') { $Action = 'list' # Add end param to list action if missing. Otherwise the API returns everything if ($Path -ne '/' -and -not $EndPath) { $EndPath = $Path } } $AdditionalOptions = @{ 'format' = 'sql' } if ($StartPath) { $AdditionalOptions['start'] = $StartPath } if ($EndPath) { $AdditionalOptions['end'] = $EndPath } if ($MaxEntries) { $AdditionalOptions['max_entries'] = $MaxEntries } if ($Encoding) { $AdditionalOptions['encoding'] = $Encoding } if ($Prefix -ne '') { $AdditionalOptions['prefix'] = $Prefix } if ($SlashBoth) { $AdditionalOptions['slash'] = 'both' } $RequestParams = @{ 'Path' = $Path 'Action' = $Action 'AdditionalOptions' = $AdditionalOptions 'NSRCFile' = $NSRCFile 'Section' = $Section } try { $Response = Invoke-NetstorageRequest @RequestParams if ($PSCmdlet.ParameterSetName -eq 'Directory') { return $Response.stat.file } else { return $Response.list.file } } catch { throw $_ } } } function Get-NetstorageDirectoryUsage { [CmdletBinding()] Param( [Parameter(Mandatory, Position = 1, ValueFromPipeline)] [string] $Path, [Parameter()] [Alias('AuthFile')] [string] $NSRCFile, [Parameter()] [string] $Section ) process { $Action = "du" $AdditionalOptions = @{ 'format' = 'sql' } $RequestParams = @{ 'Path' = $Path 'Action' = $Action 'AdditionalOptions' = $AdditionalOptions 'NSRCFile' = $NSRCFile 'Section' = $Section } try { $Response = Invoke-NetstorageRequest @RequestParams return $Response.du.'du-info' } catch { throw $_ } } } function Get-NetstorageGroup { [CmdletBinding(DefaultParameterSetName = 'Get all')] Param( [Parameter(ParameterSetName = 'Get one', ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $StorageGroupID, [Parameter(ParameterSetName = 'Get all')] [int] $CPCodeID, [Parameter(ParameterSetName = 'Get all')] [ValidateSet('NETSTORAGE', 'EDGESTREAM', 'EDGESTREAM_IPHONE', 'ADAPTIVEEDGE', 'AD_INSERTION', 'CONTENT_PREPARATION', 'MSL_ORIGIN', 'FEO')] [string] $StorageGroupPurpose, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { if ($StorageGroupID) { $Path = "/storage/v1/storage-groups/$StorageGroupID" } else { $Path = "/storage/v1/storage-groups" } $QueryParameters = @{ 'cpcodeId' = $PSBoundParameters.CPCodeID 'storageGroupPurpose' = $StorageGroupPurpose } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'QueryParameters' = $QueryParameters 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams if ($StorageGroupID) { return $Response.Body } else { return $Response.Body.items } } } function Get-NetstorageRuleSet { [CmdletBinding()] Param( [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $RuleSetID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { if ($RuleSetID) { $Path = "/storage/v1/rule-sets/$RuleSetID" } else { $Path = "/storage/v1/rule-sets" } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams if ($RuleSetID) { return $Response.Body } else { return $Response.Body.items } } } function Get-NetstorageSnapshot { [CmdletBinding()] Param( [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $SnapShotID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { if ($SnapShotID) { $Path = "/storage/v1/site-snapshots/$SnapShotID" } else { $Path = "/storage/v1/site-snapshots" } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams if ($SnapShotID) { return $Response.Body } else { return $Response.Body.items } } } function Get-NetstorageUploadAccount { [CmdletBinding()] Param( [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)] [string] $UploadAccountID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { if ($UploadAccountID) { $Path = "/storage/v1/upload-accounts/$UploadAccountID" } else { $Path = "/storage/v1/upload-accounts" } $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams if ($UploadAccountID) { return $Response.Body } else { return $Response.Body.items } } } function Get-NetstorageZones { [CmdletBinding()] Param( [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/zones" $RequestParams = @{ 'Path' = $Path 'Method' = 'GET' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body.zones.zoneName } } function Measure-NetstorageObject { [CmdletBinding()] Param( [Parameter(Mandatory, Position = 1, ValueFromPipeline)] [string] $Path, [Parameter()] [string] $Encoding, [Parameter()] [switch] $Implicit, [Parameter()] [switch] $SlashBoth, [Parameter()] [Alias('AuthFile')] [string] $NSRCFile, [Parameter()] [string] $Section ) process { $Action = 'stat' $AdditionalOptions = @{ 'format' = 'sql' 'encoding' = $Encoding } if ($Implicit) { $AdditionalOptions['implicit'] = 'yes' } if ($SlashBoth) { $AdditionalOptions['slash'] = 'both' } $RequestParams = @{ 'Path' = $Path 'Action' = $Action 'AdditionalOptions' = $AdditionalOptions 'NSRCFile' = $NSRCFile 'Section' = $Section } try { $Response = Invoke-NetstorageRequest @RequestParams return $Response.stat.file } catch { throw $_ } } } function New-NetstorageCPCode { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $CPCodeName, [Parameter(Mandatory)] [string] $ContractID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/cpcodes" $Body = @{ 'contractId' = $ContractID 'cpcodeName' = $CPCodeName } $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function New-NetstorageCredentials { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [string] $UploadAccountID, [Parameter()] [string] $APIKey, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { # ----------------- Get credentials # Gets the given upload account's details. # # The response contains two values needed for the auth file, the HTTP API key and the storage group ID. $UploadAccountParams = @{ 'UploadAccountID' = $UploadAccountID 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } $UploadAccount = Get-NetstorageUploadAccount @UploadAccountParams # Check if upload account has http api access if (-not $UploadAccount.hasHttpApiAccess) { throw "Upload account ID $UploadAccountID does not have HTTP API access enabled. Please enable and try again." } # Select the API key from the upload user, unless provided if (-not $APIKey) { # Warn the user if account has multiple g2o keys if ($UploadAccount.keys.g2o.Count -gt 1) { Write-Warning "Upload account ID $UploadAccountID has multiple g2o keys, we will use the first one returned by the API. If you want to specify a different key, please provide it with the -APIKey parameter." } $APIKey = $UploadAccount.keys.g2o[0].key } # Gets the given storage group's details. # # The response contains two additional values needed for the auth file, the HTTP domain name and upload directory's CP code. $GroupParams = @{ 'StorageGroupID' = $UploadAccount.storageGroupId 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } $StorageGroup = Get-NetstorageGroup @GroupParams # The content of the NS auth resource file. return [PSCustomObject] @{ 'key' = $APIKey 'id' = $UploadAccountID 'group' = $UploadAccount.storageGroupId 'host' = "$($StorageGroup.domainprefix)-nsu.akamaihd.net" 'cpcode' = $StorageGroup.cpcodes[0].cpcodeId } } } function New-NetstorageDirectory { [CmdletBinding()] Param( [Parameter(Mandatory, Position = 1, ValueFromPipeline)] [string] $Path, [Parameter()] [Alias('AuthFile')] [string] $NSRCFile, [Parameter()] [string] $Section ) process { $Action = "mkdir" $RequestParams = @{ 'Path' = $Path 'Action' = $Action 'NSRCFile' = $NSRCFile 'Section' = $Section } try { $Response = Invoke-NetstorageRequest @RequestParams return $Response } catch { throw $_ } } } function New-NetstorageGroup { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline)] $Body, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/storage-groups" $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function New-NetstorageRuleSet { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline)] $Body, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/rule-sets" $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body.items } } function New-NetstorageSnapshot { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline)] $Body, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/site-snapshots" $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function New-NetstorageSymlink { [CmdletBinding()] Param( [Parameter(Mandatory, Position = 1)] [string] $Path, [Parameter(Mandatory)] [string] $TargetPath, [Parameter()] [Alias('AuthFile')] [string] $NSRCFile, [Parameter()] [string] $Section ) process { $Action = 'symlink' $Body = '' $EncodedTargetPath = [System.Web.HttpUtility]::UrlEncode($TargetPath) $AdditionalOptions = @{ 'target' = $EncodedTargetPath } $RequestParams = @{ 'Path' = $Path 'Action' = $Action 'AdditionalOptions' = $AdditionalOptions 'Body' = $Body 'NSRCFile' = $NSRCFile 'Section' = $Section } try { $Response = Invoke-NetstorageRequest @RequestParams return $Response } catch { throw $_ } } } function New-NetstorageUploadAccount { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline)] $Body, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts" $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Read-NetstorageDirectory { [CmdletBinding(DefaultParameterSetName = 'Directory')] Param( [Parameter(Mandatory, Position = 1, ValueFromPipeline)] [string] $Path, [Parameter(ParameterSetName = 'Directory')] [string] $Prefix, [Parameter(ParameterSetName = 'List')] [switch] $Recurse, [Parameter(Mandatory)] [string] $OutputDirectory, [Parameter()] [string] $StartPath, [Parameter()] [string] $EndPath, [Parameter()] [int] $MaxEntries, [Parameter()] [string] $Encoding, [Parameter()] [switch] $SlashBoth, [Parameter()] [Alias('AuthFile')] [string] $NSRCFile, [Parameter()] [string] $Section ) process { # Set common params for Read calls $CommonParams = @{ NSRCFile = $NSRCFile Section = $Section } if (-not (Test-Path $OutputDirectory)) { Write-Host 'Creating output directory ' -NoNewline Write-Host -ForegroundColor Cyan $OutputDirectory -NoNewline Write-Host '.' New-Item -ItemType Directory -Path $OutputDirectory | Out-Null } # Get list of files $GetParams = $PSBoundParameters.PSObject.Copy() $GetParams.Remove('OutputDirectory') | Out-Null $NetstorageFiles = Get-NetstorageDirectory @GetParams $Files = $NetstorageFiles | Where-Object type -eq file Write-Debug "Retrieving $($Files.count) files" $Files | ForEach-Object { $LocalPath = "$OutputDirectory/$($_.name)" Read-NetstorageObject -RemotePath $_.name -LocalPath $LocalPath @CommonParams } } } function Read-NetstorageObject { [CmdletBinding()] Param( [Parameter(Mandatory, Position = 1, ValueFromPipeline)] [string] $RemotePath, [Parameter()] [string] $LocalPath, [Parameter()] [Alias('AuthFile')] [string] $NSRCFile, [Parameter()] [string] $Section ) process { $Action = "download" if (!$LocalPath) { $FileName = $RemotePath.Substring($RemotePath.LastIndexOf("/") + 1) $LocalPath = ".\$FileName" } # Track path creation $NewItemCreated = $false # Create local path with parents if (-not (Test-Path $LocalPath)) { New-Item -Path $LocalPath -Force | Out-Null $NewItemCreated = $true } Write-Host "Downloading Netstorage file '" -NoNewline Write-Host -ForegroundColor Cyan $RemotePath -NoNewline Write-Host "' to '" -NoNewline Write-Host -ForegroundColor Cyan $LocalPath -NoNewline Write-Host "'." $RequestParams = @{ 'Path' = $RemotePath 'Action' = $Action 'Outputfile' = $LocalPath 'NSRCFile' = $NSRCFile 'Section' = $Section } try { Invoke-NetstorageRequest @RequestParams } catch { if ($NewItemCreated) { Remove-Item -Force -Path $LocalPath } throw $_ } } } function Remove-NetstorageCPCode { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $CPCodeID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $StorageGroupID, [Parameter()] [switch] $ForceDelete, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/storage-groups/$StorageGroupID/cpcodes/$CpcodeID" $QueryParameters = @{ 'forceDelete' = $PSBoundParameters.ForceDelete.IsPresent } $RequestParams = @{ Path = $Path Method = 'DELETE' QueryParameters = $QueryParameters EdgeRCFile = $EdgeRCFile Section = $Section AccountSwitchKey = $AccountSwitchKey Debug = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Remove-NetstorageCPCodePurgeRoutine { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $CPCodeID, [Parameter()] [string] $AgeDeletionDirectoryPrefix, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/cpcodes/$CPCodeID/age-deletions" $Body = "ageDeletionDirectoryPrefix=$AgeDeletionDirectoryPrefix" $AdditionalHeaders = @{ 'content-type' = 'application/x-www-form-urlencoded' } $RequestParams = @{ 'Path' = $Path 'Method' = 'DELETE' 'AdditionalHeaders' = $AdditionalHeaders 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Remove-NetstorageDirectory { [CmdletBinding()] Param( [Parameter(Mandatory, Position = 1, ValueFromPipeline)] [string] $Path, [Parameter()] [switch] $DirectoryIsEmpty, [Parameter()] [switch] $Force, [Parameter()] [Alias('AuthFile')] [string] $NSRCFile, [Parameter()] [string] $Section ) process { if ($DirectoryIsEmpty) { $Action = 'rmdir' $Body = '' $AdditionalOptions = @{} } else { if (!$Force) { $Sure = Read-Host "This operation will delete the directory $Path with no further confirmation. Are you really, really sure?[y/n]" if ($Sure.ToLower() -ne "y") { Write-Host -ForegroundColor "Red" "Delete cancelled." return } } $Action = 'quick-delete' $Body = '' $AdditionalOptions = @{ 'quick-delete' = 'imreallyreallysure' } } $RequestParams = @{ 'Path' = $Path 'Action' = $Action 'Body' = $Body 'AdditionalOptions' = $AdditionalOptions 'NSRCFile' = $NSRCFile 'Section' = $Section } try { $Response = Invoke-NetstorageRequest @RequestParams return $Response } catch { throw $_ } } } function Remove-NetstorageGroup { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $StorageGroupID, [Parameter()] [switch] $ForceDelete, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/storage-groups/$StorageGroupID" $QueryParameters = @{ 'forceDelete' = $PSBoundParameters.ForceDelete.IsPresent } $RequestParams = @{ Path = $Path Method = 'DELETE' QueryParameters = $QueryParameters EdgeRCFile = $EdgeRCFile Section = $Section AccountSwitchKey = $AccountSwitchKey Debug = ($PSBoundParameters.Debug -eq $true) } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Remove-NetstorageObject { [CmdletBinding()] Param( [Parameter(Mandatory, Position = 1, ValueFromPipeline)] [string] $Path, [Parameter()] [Alias('AuthFile')] [string] $NSRCFile, [Parameter()] [string] $Section ) process { $Action = "delete" $Body = '' $RequestParams = @{ 'Path' = $Path 'Action' = $Action 'Body' = $Body 'NSRCFile' = $NSRCFile 'Section' = $Section } try { $Response = Invoke-NetstorageRequest @RequestParams return $Response } catch { throw $_ } } } function Remove-NetstorageRuleSet { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $RuleSetID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/rule-sets/$RuleSetID" $RequestParams = @{ 'Path' = $Path 'Method' = 'DELETE' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Remove-NetstorageSnapshot { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $SnapShotID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/site-snapshots/$SnapShotID" $RequestParams = @{ 'Path' = $Path 'Method' = 'DELETE' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Remove-NetstorageUploadAccount { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [string] $UploadAccountID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID" $RequestParams = @{ 'Path' = $Path 'Method' = 'DELETE' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Remove-NetstorageUploadAccountFTPKey { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $UploadAccountID, [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [Alias('id')] [string] $Identity, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/keys/ftp/$Identity" $RequestParams = @{ 'Path' = $Path 'Method' = 'DELETE' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Remove-NetstorageUploadAccountHTTPKey { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $UploadAccountID, [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [Alias('id')] [string] $Identity, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/keys/g2o/$Identity" $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 } } function Remove-NetstorageUploadAccountRSyncKey { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $UploadAccountID, [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [Alias('id')] [string] $Identity, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/keys/rsync/$Identity" $RequestParams = @{ 'Path' = $Path 'Method' = 'DELETE' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Remove-NetstorageUploadAccountSSHKey { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $UploadAccountID, [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [Alias('id')] [string] $Identity, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/keys/ssh/$Identity" $RequestParams = @{ 'Path' = $Path 'Method' = 'DELETE' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Rename-NetstorageObject { [CmdletBinding()] Param( [Parameter(Mandatory, Position = 1, ValueFromPipeline)] [string] $Path, [Parameter(Mandatory)] [string] $NewFilename, [Parameter()] [Alias('AuthFile')] [string] $NSRCFile, [Parameter()] [string] $Section ) process { $Action = 'rename' $Body = '' $OldFilename = $Path.Substring($Path.LastIndexOf("/") + 1) $NewPath = $Path.Replace($OldFilename, $NewFilename) $EncodedNewPath = [System.Web.HttpUtility]::UrlEncode($NewPath) $AdditionalOptions = @{ 'destination' = $EncodedNewPath } $RequestParams = @{ 'Path' = $Path 'Action' = $Action 'AdditionalOptions' = $AdditionalOptions 'Body' = $Body 'NSRCFile' = $NSRCFile 'Section' = $Section } try { $Response = Invoke-NetstorageRequest @RequestParams return $Response } catch { throw $_ } } } function Restore-NetstorageCPCode { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [int] $CpcodeID, [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [int] $StorageGroupID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/storage-groups/$StorageGroupID/cpcodes/$CpcodeID/cancel-delete" $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 Restore-NetstorageGroup { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [int] $StorageGroupID, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/storage-groups/$StorageGroupID/cancel-delete" $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 Set-NetstorageCPCodePurgeRoutine { [CmdletBinding()] Param( [Parameter(Mandatory)] [int] $CPCodeID, [Parameter(Mandatory, ValueFromPipeline)] $Body, [Parameter()] [string] $AgeDeletionDirectoryPrefix, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/cpcodes/$CPCodeID/age-deletions" $QueryParameters = @{ 'ageDeletionDirectoryPrefix' = $AgeDeletionDirectoryPrefix } # Convert body to object in order to check it is an array of objects, rather than a single if ($Body -is 'String') { $Body = ConvertFrom-Json $Body } if ($Body -isnot 'Array') { $Body = @($Body) } $RequestParams = @{ 'Path' = $Path 'Method' = 'PUT' 'QueryParameters' = $QueryParameters 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Set-NetstorageGroup { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [int] $StorageGroupID, [Parameter(Mandatory, ValueFromPipeline)] $Body, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/storage-groups/$StorageGroupID" $RequestParams = @{ 'Path' = $Path 'Method' = 'PUT' 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Set-NetstorageObjectMTime { [CmdletBinding()] Param( [Parameter(Mandatory, Position = 1, ValueFromPipeline)] [string] $Path, [Parameter(Mandatory)] [string] $mtime, [Parameter()] [Alias('AuthFile')] [string] $NSRCFile, [Parameter()] [string] $Section ) process { $Action = "mtime" $Body = '' $AdditionalOptions = @{ 'mtime' = $mtime } $RequestParams = @{ 'Path' = $Path 'Action' = $Action 'AdditionalOptions' = $AdditionalOptions 'Body' = $Body 'NSRCFile' = $NSRCFile 'Section' = $Section } try { $Response = Invoke-NetstorageRequest @RequestParams return $Response } catch { throw $_ } } } function Set-NetstorageRuleSet { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [int] $RuleSetID, [Parameter(Mandatory, ValueFromPipeline)] $Body, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/rule-sets/$RuleSetID" $RequestParams = @{ 'Path' = $Path 'Method' = 'PUT' 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Set-NetstorageSnapshot { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [int] $SnapShotID, [Parameter(Mandatory, ValueFromPipeline)] $Body, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/site-snapshots/$SnapShotID" $RequestParams = @{ 'Path' = $Path 'Method' = 'PUT' 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Set-NetstorageUploadAccount { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [string] $UploadAccountID, [Parameter(Mandatory, ValueFromPipeline)] $Body, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID" $RequestParams = @{ 'Path' = $Path 'Method' = 'PUT' 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Set-NetstorageUploadAccountFTPKey { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $UploadAccountID, [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [string] $Identity, [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [string] $Key, [Parameter(ValueFromPipelineByPropertyName)] [string] $Comments, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/keys/ftp/$Identity" $Body = @{ key = $Key } if ($null -ne $Comments) { $Body.comments = $Comments } $RequestParams = @{ 'Path' = $Path 'Method' = 'PUT' 'Body' = $Body 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Start-NetstorageSnapshot { [CmdletBinding()] Param( [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [int] $SnapShotID, [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [string] $SnapshotName, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/site-snapshots/schedule-now" $QueryParameters = @{ 'snapshotId' = $SnapShotID 'snapshotName' = $SnapshotName } $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'QueryParameters' = $QueryParameters 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Update-NetstorageUploadAccountFTPKey { [CmdletBinding()] Param( [Parameter(Mandatory)] [string] $UploadAccountID, [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [Alias('id')] [string] $Identity, [Parameter()] [string] $EdgeRCFile, [Parameter()] [string] $Section, [Parameter()] [string] $AccountSwitchKey ) process { $Path = "/storage/v1/upload-accounts/$UploadAccountID/keys/ftp/$Identity/extend" $RequestParams = @{ 'Path' = $Path 'Method' = 'POST' 'EdgeRCFile' = $EdgeRCFile 'Section' = $Section 'AccountSwitchKey' = $AccountSwitchKey } # Make Request $Response = Invoke-AkamaiRequest @RequestParams return $Response.Body } } function Write-NetstorageObject { [CmdletBinding()] Param( [Parameter(Mandatory, Position = 1)] [string] $LocalPath, [Parameter(Mandatory)] [string] $RemotePath, [Parameter()] [string] $MTime, [Parameter()] [string] $Size, [Parameter()] [switch] $CheckHash, [Parameter()] [switch] $IndexZip, [Parameter()] [Alias('AuthFile')] [string] $NSRCFile, [Parameter()] [string] $Section ) process { $Action = 'upload' # Assume if path ends with / we are uploading to a folder and append the filename if ($RemotePath.EndsWith("/")) { $File = Get-Item $LocalPath $RemotePath += $($File.Name) } $AdditionalOptions = @{ 'mtime' = $MTime 'size' = $Size } if ($CheckHash) { $Hash = (Get-FileHash -Path $LocalPath -Algorithm SHA256).Hash $AdditionalOptions['sha256'] = $Hash } if ($IndexZip) { $AdditionalOptions['index-zip'] = 1 } $RequestParams = @{ 'Path' = $RemotePath 'Action' = $Action 'InputFile' = $LocalPath 'AdditionalOptions' = $AdditionalOptions 'NSRCFile' = $NSRCFile 'Section' = $Section } try { $Response = Invoke-NetstorageRequest @RequestParams return $Response } catch { throw $_ } } } # SIG # Begin signature block # MIIKmAYJKoZIhvcNAQcCoIIKiTCCCoUCAQExDzANBglghkgBZQMEAgEFADB5Bgor # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG # KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCAc4xF/nvw9gbgb # LqD53SQvljGRJhH2KFE4NdrpYZ7CbqCCB1owggdWMIIFPqADAgECAhAGRzH371Sh # X6hjGl1wSSyYMA0GCSqGSIb3DQEBCwUAMGkxCzAJBgNVBAYTAlVTMRcwFQYDVQQK # Ew5EaWdpQ2VydCwgSW5jLjFBMD8GA1UEAxM4RGlnaUNlcnQgVHJ1c3RlZCBHNCBD # b2RlIFNpZ25pbmcgUlNBNDA5NiBTSEEzODQgMjAyMSBDQTEwHhcNMjYwMjI1MDAw # MDAwWhcNMjcwMzEwMjM1OTU5WjCB3jETMBEGCysGAQQBgjc8AgEDEwJVUzEZMBcG # CysGAQQBgjc8AgECEwhEZWxhd2FyZTEdMBsGA1UEDwwUUHJpd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