本文整理汇总了Golang中github.com/tetrafolium/aws-sdk-go/service/kms.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ExampleKMS_CreateKey
func ExampleKMS_CreateKey() {
svc := kms.New(nil)
params := &kms.CreateKeyInput{
Description: aws.String("DescriptionType"),
KeyUsage: aws.String("KeyUsageType"),
Policy: aws.String("PolicyType"),
}
resp, err := svc.CreateKey(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
示例2: ExampleKMS_UpdateAlias
func ExampleKMS_UpdateAlias() {
svc := kms.New(nil)
params := &kms.UpdateAliasInput{
AliasName: aws.String("AliasNameType"), // Required
TargetKeyId: aws.String("KeyIdType"), // Required
}
resp, err := svc.UpdateAlias(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
示例3: ExampleKMS_GenerateRandom
func ExampleKMS_GenerateRandom() {
svc := kms.New(nil)
params := &kms.GenerateRandomInput{
NumberOfBytes: aws.Int64(1),
}
resp, err := svc.GenerateRandom(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
示例4: ExampleKMS_Encrypt
func ExampleKMS_Encrypt() {
svc := kms.New(nil)
params := &kms.EncryptInput{
KeyId: aws.String("KeyIdType"), // Required
Plaintext: []byte("PAYLOAD"), // Required
EncryptionContext: map[string]*string{
"Key": aws.String("EncryptionContextValue"), // Required
// More values...
},
GrantTokens: []*string{
aws.String("GrantTokenType"), // Required
// More values...
},
}
resp, err := svc.Encrypt(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
示例5: init
func init() {
Before("@kms", func() {
World["client"] = kms.New(nil)
})
}
示例6: TestInterface
func TestInterface(t *testing.T) {
assert.Implements(t, (*kmsiface.KMSAPI)(nil), kms.New(nil))
}