Skip to content

Commit

Permalink
Unifying usage
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartio committed Dec 2, 2022
1 parent 68a8543 commit 6279233
Show file tree
Hide file tree
Showing 3 changed files with 514 additions and 515 deletions.
58 changes: 29 additions & 29 deletions cpcodes/List-CPCodes.ps1
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
function List-CPCodes
{
Param(
[Parameter(Mandatory=$false)] [string] $ContractID,
[Parameter(Mandatory=$false)] [string] $GroupID,
[Parameter(Mandatory=$false)] [string] $ProductID,
[Parameter(Mandatory=$false)] [string] $Name,
[Parameter(Mandatory=$false)] [string] $EdgeRCFile = '~\.edgerc',
[Parameter(Mandatory=$false)] [string] $Section = 'default',
[Parameter(Mandatory=$false)] [string] $AccountSwitchKey
)

# Sanitize IDs
if($GroupID -and $GroupID.contains("grp_")){
$GroupID = $GroupID.replace("grp_","")
}
if($ContractID -and $ContractID.contains("ctr_")){
$ContractID = $ContractID.replace("ctr_","")
}

$Path = "/cprg/v1/cpcodes?contractId=$ContractID&groupId=$GroupID&productId=$ProductID&cpcodeName=$Name&accountSwitchKey=$AccountSwitchKey"

try {
$Result = Invoke-AkamaiRestMethod -Method GET -Path $Path -EdgeRCFile $EdgeRCFile -Section $Section
return $Result.cpcodes
}
catch {
throw $_
}
function List-CPCodes
{
Param(
[Parameter(Mandatory=$false)] [string] $ContractID,
[Parameter(Mandatory=$false)] [string] $GroupID,
[Parameter(Mandatory=$false)] [string] $ProductID,
[Parameter(Mandatory=$false)] [string] $Name,
[Parameter(Mandatory=$false)] [string] $EdgeRCFile = '~\.edgerc',
[Parameter(Mandatory=$false)] [string] $Section = 'default',
[Parameter(Mandatory=$false)] [string] $AccountSwitchKey
)

# Sanitize IDs
if($GroupID -and $GroupID.contains("grp_")){
$GroupID = $GroupID.replace("grp_","")
}
if($ContractID -and $ContractID.contains("ctr_")){
$ContractID = $ContractID.replace("ctr_","")
}

$Path = "/cprg/v1/cpcodes?contractId=$ContractID&groupId=$GroupID&productId=$ProductID&cpcodeName=$Name&accountSwitchKey=$AccountSwitchKey"

try {
$Result = Invoke-AkamaiRestMethod -Method GET -Path $Path -EdgeRCFile $EdgeRCFile -Section $Section
return $Result.cpcodes
}
catch {
throw $_
}
}
Loading

0 comments on commit 6279233

Please sign in to comment.