1

私はAWS PowerShellでNewAg-ApiKeyコマンドレットを実行しようとしています。私はStageKeysの形式については不明です。誰かがこれを明確にすることはできますか?NewAg-APIKEYのフォーマットエラー

現在としてNew-AgApiKeyを書く:

New-AGApiKey -CustomerId '11' -Description 'aa' -Enabled $True -GenerateDistinctId $True -Name 'newAPIKey'-StageKeys [{"RestApiId":'yz50sp19a7'},{"StageName":'wh1'}] -Force 

と、次のエラー

At C:\Users\sgoswami\Desktop\Scripts\create1.ps1:2 char:132 + ... $True -Name 'newAPIKey'-StageKeys [{"RestApiId":'yz50sp19a7'},{"Stag ... + ~~~~~~~~~~~~~ Unexpected token ':'yz50sp19a7'' in expression or statement. At C:\Users\sgoswami\Desktop\Scripts\create1.ps1:2 char:159 + ... Key'-StageKeys [{"RestApiId":'yz50sp19a7'},{"StageName":'wh1'}] -Forc ... + ~~~~~~ Unexpected token ':'wh1'' in expression or statement. + CategoryInfo : ParserError: (:) [], ParseException + FullyQualifiedErrorId : UnexpectedToken

答えて

1

は全くStageKeysなしAPIKEYを作成してみてください取得。これは、必要なパラメータではない、とNew-AGApiKey documentationごとに、このパラメータはusage plansの賛成で廃止されました:

-StageKey StageKey[]

DEPRECATED FOR USAGE PLANS - Specifies stages associated with the API key.
Required? False
Position? Named
Accept pipeline input? False

このオプションは、同様に、CLIおよびその他のSDKで廃止されました。

それでも.NETドキュメントのためにAWS SDKでStageKeys、Amazon.APIGateway.Model.StageKey type is defined hereを、使用する必要がある場合。以下に説明するように、一致するプロパティの名前と値を持つPowerShellの新しいオブジェクトに対する入力として使用される場合、PowerShellでこのタイプの新しいインスタンスを作成することができ:

$obj = New-Object Amazon.APIGateway.Model.StageKey -Property @{ RestApiId = "myId"; StageName = "myName" } 

のタイプを確認する正しい:

$obj | get-member 

    TypeName: Amazon.APIGateway.Model.StageKey 

Name  MemberType Definition 
----  ---------- ---------- 
Equals  Method  bool Equals(System.Object obj) 
GetHashCode Method  int GetHashCode() 
GetType  Method  type GetType() 
ToString Method  string ToString() 
RestApiId Property string RestApiId {get;set;} 
StageName Property string StageName {get;set;} 
+0

これは機能します。 。しかし、構文の新しいエラーが発生しています。何らかの理由でこれが起こっている可能性があります。 新AGApiKey -CustomerId '11' -Description 'AA' ... -Enabled $ Trueの-Gener ~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:NotSpecified:( :) [新AGApiKey]、TypeInitializationException + FullyQualifiedErrorId:System.TypeInitializationException、Amazon.PowerShell.Cmdlets.AG.NewAGApiKeyCmdlet に向けた新AGApiKey -CustomerId '11' -Description 'AA' -Enabled $ Trueの-GenerateDistinctId $ True -Name 'newAPIKey'-StageKeys $ obj -Force –

+0

こんにちは、なぜ厳密に非推奨機能を使用しようとしていますか? –

関連する問題