本文整理匯總了Golang中github.com/aws/aws-sdk-go/aws.StringMap函數的典型用法代碼示例。如果您正苦於以下問題:Golang StringMap函數的具體用法?Golang StringMap怎麽用?Golang StringMap使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了StringMap函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: resourceAwsApiGatewayIntegrationCreate
func resourceAwsApiGatewayIntegrationCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).apigateway
var integrationHttpMethod *string
if v, ok := d.GetOk("integration_http_method"); ok {
integrationHttpMethod = aws.String(v.(string))
}
var uri *string
if v, ok := d.GetOk("uri"); ok {
uri = aws.String(v.(string))
}
templates := make(map[string]string)
for k, v := range d.Get("request_templates").(map[string]interface{}) {
templates[k] = v.(string)
}
parameters := make(map[string]string)
if v, ok := d.GetOk("request_parameters_in_json"); ok {
if err := json.Unmarshal([]byte(v.(string)), ¶meters); err != nil {
return fmt.Errorf("Error unmarshaling request_parameters_in_json: %s", err)
}
}
var passthroughBehavior *string
if v, ok := d.GetOk("passthrough_behavior"); ok {
passthroughBehavior = aws.String(v.(string))
}
var credentials *string
if val, ok := d.GetOk("credentials"); ok {
credentials = aws.String(val.(string))
}
_, err := conn.PutIntegration(&apigateway.PutIntegrationInput{
HttpMethod: aws.String(d.Get("http_method").(string)),
ResourceId: aws.String(d.Get("resource_id").(string)),
RestApiId: aws.String(d.Get("rest_api_id").(string)),
Type: aws.String(d.Get("type").(string)),
IntegrationHttpMethod: integrationHttpMethod,
Uri: uri,
// TODO reimplement once [GH-2143](https://github.com/hashicorp/terraform/issues/2143) has been implemented
RequestParameters: aws.StringMap(parameters),
RequestTemplates: aws.StringMap(templates),
Credentials: credentials,
CacheNamespace: nil,
CacheKeyParameters: nil,
PassthroughBehavior: passthroughBehavior,
})
if err != nil {
return fmt.Errorf("Error creating API Gateway Integration: %s", err)
}
d.SetId(fmt.Sprintf("agi-%s-%s-%s", d.Get("rest_api_id").(string), d.Get("resource_id").(string), d.Get("http_method").(string)))
return nil
}
示例2: resourceAwsApiGatewayDeploymentCreate
func resourceAwsApiGatewayDeploymentCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).apigateway
// Create the gateway
log.Printf("[DEBUG] Creating API Gateway Deployment")
variables := make(map[string]string)
for k, v := range d.Get("variables").(map[string]interface{}) {
variables[k] = v.(string)
}
var err error
deployment, err := conn.CreateDeployment(&apigateway.CreateDeploymentInput{
RestApiId: aws.String(d.Get("rest_api_id").(string)),
StageName: aws.String(d.Get("stage_name").(string)),
Description: aws.String(d.Get("description").(string)),
StageDescription: aws.String(d.Get("stage_description").(string)),
Variables: aws.StringMap(variables),
})
if err != nil {
return fmt.Errorf("Error creating API Gateway Deployment: %s", err)
}
d.SetId(*deployment.Id)
log.Printf("[DEBUG] API Gateway Deployment ID: %s", d.Id())
return nil
}
示例3: resourceAwsApiGatewayIntegrationResponseCreate
func resourceAwsApiGatewayIntegrationResponseCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).apigateway
templates := make(map[string]string)
for k, v := range d.Get("response_templates").(map[string]interface{}) {
templates[k] = v.(string)
}
input := apigateway.PutIntegrationResponseInput{
HttpMethod: aws.String(d.Get("http_method").(string)),
ResourceId: aws.String(d.Get("resource_id").(string)),
RestApiId: aws.String(d.Get("rest_api_id").(string)),
StatusCode: aws.String(d.Get("status_code").(string)),
ResponseTemplates: aws.StringMap(templates),
// TODO implement once [GH-2143](https://github.com/hashicorp/terraform/issues/2143) has been implemented
ResponseParameters: nil,
}
if v, ok := d.GetOk("selection_pattern"); ok {
input.SelectionPattern = aws.String(v.(string))
}
_, err := conn.PutIntegrationResponse(&input)
if err != nil {
return fmt.Errorf("Error creating API Gateway Integration Response: %s", err)
}
d.SetId(fmt.Sprintf("agir-%s-%s-%s-%s", d.Get("rest_api_id").(string), d.Get("resource_id").(string), d.Get("http_method").(string), d.Get("status_code").(string)))
log.Printf("[DEBUG] API Gateway Integration Response ID: %s", d.Id())
return resourceAwsApiGatewayIntegrationResponseRead(d, meta)
}
示例4: resourceAwsApiGatewayMethodResponseCreate
func resourceAwsApiGatewayMethodResponseCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).apigateway
models := make(map[string]string)
for k, v := range d.Get("response_models").(map[string]interface{}) {
models[k] = v.(string)
}
parameters := make(map[string]bool)
if v, ok := d.GetOk("response_parameters_in_json"); ok {
if err := json.Unmarshal([]byte(v.(string)), ¶meters); err != nil {
return fmt.Errorf("Error unmarshaling request_parameters_in_json: %s", err)
}
}
_, err := conn.PutMethodResponse(&apigateway.PutMethodResponseInput{
HttpMethod: aws.String(d.Get("http_method").(string)),
ResourceId: aws.String(d.Get("resource_id").(string)),
RestApiId: aws.String(d.Get("rest_api_id").(string)),
StatusCode: aws.String(d.Get("status_code").(string)),
ResponseModels: aws.StringMap(models),
// TODO reimplement once [GH-2143](https://github.com/hashicorp/terraform/issues/2143) has been implemented
ResponseParameters: aws.BoolMap(parameters),
})
if err != nil {
return fmt.Errorf("Error creating API Gateway Method Response: %s", err)
}
d.SetId(fmt.Sprintf("agmr-%s-%s-%s-%s", d.Get("rest_api_id").(string), d.Get("resource_id").(string), d.Get("http_method").(string), d.Get("status_code").(string)))
log.Printf("[DEBUG] API Gateway Method ID: %s", d.Id())
return nil
}
示例5: resourceAwsApiGatewayMethodCreate
func resourceAwsApiGatewayMethodCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).apigateway
models := make(map[string]string)
for k, v := range d.Get("request_models").(map[string]interface{}) {
models[k] = v.(string)
}
parameters := make(map[string]bool)
if parameterData, ok := d.GetOk("request_parameters"); ok {
params := parameterData.(*schema.Set).List()
for k := range params {
parameters[params[k].(string)] = true
}
}
_, err := conn.PutMethod(&apigateway.PutMethodInput{
AuthorizationType: aws.String(d.Get("authorization").(string)),
HttpMethod: aws.String(d.Get("http_method").(string)),
ResourceId: aws.String(d.Get("resource_id").(string)),
RestApiId: aws.String(d.Get("rest_api_id").(string)),
RequestModels: aws.StringMap(models),
// TODO implement once [GH-2143](https://github.com/hashicorp/terraform/issues/2143) has been implemented
RequestParameters: nil,
ApiKeyRequired: aws.Bool(d.Get("api_key_required").(bool)),
})
if err != nil {
return fmt.Errorf("Error creating API Gateway Method: %s", err)
}
d.SetId(fmt.Sprintf("agm-%s-%s-%s", d.Get("rest_api_id").(string), d.Get("resource_id").(string), d.Get("http_method").(string)))
log.Printf("[DEBUG] API Gateway Method ID: %s", d.Id())
return nil
}
示例6: resourceAwsApiGatewayIntegrationResponseCreate
func resourceAwsApiGatewayIntegrationResponseCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).apigateway
templates := make(map[string]string)
for k, v := range d.Get("response_templates").(map[string]interface{}) {
templates[k] = v.(string)
}
parameters := make(map[string]string)
if kv, ok := d.GetOk("response_parameters"); ok {
for k, v := range kv.(map[string]interface{}) {
parameters[k] = v.(string)
}
}
if v, ok := d.GetOk("response_parameters_in_json"); ok {
if err := json.Unmarshal([]byte(v.(string)), ¶meters); err != nil {
return fmt.Errorf("Error unmarshaling response_parameters_in_json: %s", err)
}
}
var contentHandling *string
if val, ok := d.GetOk("content_handling"); ok {
contentHandling = aws.String(val.(string))
}
input := apigateway.PutIntegrationResponseInput{
HttpMethod: aws.String(d.Get("http_method").(string)),
ResourceId: aws.String(d.Get("resource_id").(string)),
RestApiId: aws.String(d.Get("rest_api_id").(string)),
StatusCode: aws.String(d.Get("status_code").(string)),
ResponseTemplates: aws.StringMap(templates),
ResponseParameters: aws.StringMap(parameters),
ContentHandling: contentHandling,
}
if v, ok := d.GetOk("selection_pattern"); ok {
input.SelectionPattern = aws.String(v.(string))
}
_, err := conn.PutIntegrationResponse(&input)
if err != nil {
return fmt.Errorf("Error creating API Gateway Integration Response: %s", err)
}
d.SetId(fmt.Sprintf("agir-%s-%s-%s-%s", d.Get("rest_api_id").(string), d.Get("resource_id").(string), d.Get("http_method").(string), d.Get("status_code").(string)))
log.Printf("[DEBUG] API Gateway Integration Response ID: %s", d.Id())
return resourceAwsApiGatewayIntegrationResponseRead(d, meta)
}
示例7: createScheduleRunInput
func createScheduleRunInput(p *model.RunParameters) *devicefarm.ScheduleRunInput {
var wg sync.WaitGroup
result := &devicefarm.ScheduleRunInput{
ProjectArn: aws.String(p.ProjectArn),
Test: &devicefarm.ScheduleRunTest{},
Configuration: &devicefarm.ScheduleRunConfiguration{
Radios: &devicefarm.Radios{
Bluetooth: aws.Bool(true),
Gps: aws.Bool(true),
Nfc: aws.Bool(true),
Wifi: aws.Bool(true),
},
Location: &devicefarm.Location{
Latitude: aws.Float64(47.6204),
Longitude: aws.Float64(-122.3491),
},
},
}
result.Name = aws.String(p.Config.RunName)
result.Configuration.AuxiliaryApps = aws.StringSlice(p.Config.AdditionalData.AuxiliaryApps)
if p.Config.AdditionalData.BillingMethod != "" {
result.Configuration.BillingMethod = aws.String(p.Config.AdditionalData.BillingMethod)
}
result.Configuration.Locale = aws.String(p.Config.AdditionalData.Locale)
if p.Config.AdditionalData.Location.Latitude != 0 {
result.Configuration.Location.Latitude = aws.Float64(p.Config.AdditionalData.Location.Latitude)
}
if p.Config.AdditionalData.Location.Longitude != 0 {
result.Configuration.Location.Longitude = aws.Float64(p.Config.AdditionalData.Location.Longitude)
}
if p.Config.AdditionalData.NetworkProfileArn != "" {
result.Configuration.NetworkProfileArn = aws.String(p.Config.AdditionalData.NetworkProfileArn)
}
result.Configuration.Radios.Bluetooth = aws.Bool(stringToBool(p.Config.AdditionalData.Radios.Bluetooth))
result.Configuration.Radios.Gps = aws.Bool(stringToBool(p.Config.AdditionalData.Radios.Gps))
result.Configuration.Radios.Nfc = aws.Bool(stringToBool(p.Config.AdditionalData.Radios.Nfc))
result.Configuration.Radios.Wifi = aws.Bool(stringToBool(p.Config.AdditionalData.Radios.Wifi))
result.Test.Filter = aws.String(p.Config.Test.Filter)
result.Test.Parameters = aws.StringMap(p.Config.Test.Parameters)
if p.Config.Test.Type != "" {
result.Test.Type = aws.String(p.Config.Test.Type)
} else {
result.Test.Type = aws.String("BUILTIN_FUZZ")
}
if p.Config.Test.TestPackageArn != "" {
result.Test.TestPackageArn = aws.String(p.Config.Test.TestPackageArn)
} else {
uploadTestPackage(p, result, &wg)
}
if p.Config.AdditionalData.ExtraDataPackageArn != "" {
result.Configuration.ExtraDataPackageArn = aws.String(p.Config.AdditionalData.ExtraDataPackageArn)
} else {
uploadExtraData(p, result, &wg)
}
wg.Wait()
return result
}
示例8: Decrypt
// Decrypt decrypts the encrypted key.
func (k *Kms) Decrypt(keyCiphertext []byte, secretID string) ([]byte, error) {
do, err := k.client.Decrypt(&kms.DecryptInput{
EncryptionContext: aws.StringMap(map[string]string{
"SecretId": secretID,
}),
CiphertextBlob: keyCiphertext,
})
return do.Plaintext, err
}
示例9: GenerateEnvelopeKey
// GenerateEnvelopeKey generates an EnvelopeKey under a specific KeyID.
func (k *Kms) GenerateEnvelopeKey(keyID string, secretID string) (EnvelopeKey, error) {
generateDataKeyInput := &kms.GenerateDataKeyInput{
KeyId: aws.String(keyID),
EncryptionContext: aws.StringMap(map[string]string{
"SecretId": secretID,
}),
NumberOfBytes: aws.Int64(32)}
gdko, err := k.client.GenerateDataKey(generateDataKeyInput)
return EnvelopeKey{gdko.Plaintext, gdko.CiphertextBlob}, err
}
示例10: resourceAwsApiGatewayMethodCreate
func resourceAwsApiGatewayMethodCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).apigateway
input := apigateway.PutMethodInput{
AuthorizationType: aws.String(d.Get("authorization").(string)),
HttpMethod: aws.String(d.Get("http_method").(string)),
ResourceId: aws.String(d.Get("resource_id").(string)),
RestApiId: aws.String(d.Get("rest_api_id").(string)),
ApiKeyRequired: aws.Bool(d.Get("api_key_required").(bool)),
}
models := make(map[string]string)
for k, v := range d.Get("request_models").(map[string]interface{}) {
models[k] = v.(string)
}
if len(models) > 0 {
input.RequestModels = aws.StringMap(models)
}
parameters := make(map[string]bool)
if kv, ok := d.GetOk("request_parameters"); ok {
for k, v := range kv.(map[string]interface{}) {
parameters[k], ok = v.(bool)
if !ok {
value, _ := strconv.ParseBool(v.(string))
parameters[k] = value
}
}
input.RequestParameters = aws.BoolMap(parameters)
}
if v, ok := d.GetOk("request_parameters_in_json"); ok {
if err := json.Unmarshal([]byte(v.(string)), ¶meters); err != nil {
return fmt.Errorf("Error unmarshaling request_parameters_in_json: %s", err)
}
input.RequestParameters = aws.BoolMap(parameters)
}
if v, ok := d.GetOk("authorizer_id"); ok {
input.AuthorizerId = aws.String(v.(string))
}
_, err := conn.PutMethod(&input)
if err != nil {
return fmt.Errorf("Error creating API Gateway Method: %s", err)
}
d.SetId(fmt.Sprintf("agm-%s-%s-%s", d.Get("rest_api_id").(string), d.Get("resource_id").(string), d.Get("http_method").(string)))
log.Printf("[DEBUG] API Gateway Method ID: %s", d.Id())
return nil
}
示例11: resourceAwsSqsQueuePolicyDelete
func resourceAwsSqsQueuePolicyDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).sqsconn
url := d.Get("queue_url").(string)
log.Printf("[DEBUG] Deleting SQS Queue Policy of %s", url)
_, err := conn.SetQueueAttributes(&sqs.SetQueueAttributesInput{
QueueUrl: aws.String(url),
Attributes: aws.StringMap(map[string]string{
"Policy": "",
}),
})
if err != nil {
return fmt.Errorf("Error deleting SQS Queue policy: %s", err)
}
return nil
}
示例12: TestStringMap
func TestStringMap(t *testing.T) {
for idx, in := range testCasesStringMap {
if in == nil {
continue
}
out := aws.StringMap(in)
assert.Len(t, out, len(in), "Unexpected len at idx %d", idx)
for i := range out {
assert.Equal(t, in[i], *(out[i]), "Unexpected value at idx %d", idx)
}
out2 := aws.StringValueMap(out)
assert.Len(t, out2, len(in), "Unexpected len at idx %d", idx)
assert.Equal(t, in, out2, "Unexpected value at idx %d", idx)
}
}
示例13: resourceAwsSqsQueuePolicyUpsert
func resourceAwsSqsQueuePolicyUpsert(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).sqsconn
url := d.Get("queue_url").(string)
_, err := conn.SetQueueAttributes(&sqs.SetQueueAttributesInput{
QueueUrl: aws.String(url),
Attributes: aws.StringMap(map[string]string{
"Policy": d.Get("policy").(string),
}),
})
if err != nil {
return fmt.Errorf("Error updating SQS attributes: %s", err)
}
d.SetId("sqs-policy-" + url)
return resourceAwsSqsQueuePolicyRead(d, meta)
}
示例14: decrypt
// decrypt returns a KMS decrypted byte array
// See http://docs.aws.amazon.com/sdk-for-go/api/service/kms/KMS.html#Decrypt-instance_method
func decrypt(payload []byte, svc *kms.KMS) ([]byte, error) {
params := &kms.DecryptInput{
CiphertextBlob: payload,
EncryptionContext: aws.StringMap(map[string]string{
"Key": "EncryptionContextValue",
}),
GrantTokens: aws.StringSlice([]string{
"GrantTokenType",
}),
}
resp, err := svc.Decrypt(params)
if err != nil {
return nil, err
}
return resp.Plaintext, nil
}
示例15: encrypt
// encrypt returns a KMS encrypted byte array
// See http://docs.aws.amazon.com/sdk-for-go/api/service/kms/KMS.html#Encrypt-instance_method
func encrypt(payload []byte, svc *kms.KMS, keyID string) ([]byte, error) {
params := &kms.EncryptInput{
KeyId: aws.String(keyID),
Plaintext: payload,
EncryptionContext: aws.StringMap(map[string]string{
"Key": "EncryptionContextValue",
}),
GrantTokens: aws.StringSlice([]string{
"GrantTokenType",
}),
}
resp, err := svc.Encrypt(params)
if err != nil {
return nil, err
}
return resp.CiphertextBlob, nil
}