本文整理匯總了Golang中github.com/aws/aws-sdk-go/service/apigateway.PatchOperation.Value方法的典型用法代碼示例。如果您正苦於以下問題:Golang PatchOperation.Value方法的具體用法?Golang PatchOperation.Value怎麽用?Golang PatchOperation.Value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/aws/aws-sdk-go/service/apigateway.PatchOperation
的用法示例。
在下文中一共展示了PatchOperation.Value方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: expandApiGatewayMethodParametersOperations
func expandApiGatewayMethodParametersOperations(d *schema.ResourceData, key string, prefix string) ([]*apigateway.PatchOperation, error) {
operations := make([]*apigateway.PatchOperation, 0)
oldParameters, newParameters := d.GetChange(key)
oldParametersMap := oldParameters.(map[string]interface{})
newParametersMap := newParameters.(map[string]interface{})
for k, _ := range oldParametersMap {
operation := apigateway.PatchOperation{
Op: aws.String("remove"),
Path: aws.String(fmt.Sprintf("/%s/%s", prefix, k)),
}
for nK, nV := range newParametersMap {
b, ok := nV.(bool)
if !ok {
value, _ := strconv.ParseBool(nV.(string))
b = value
}
if nK == k {
operation.Op = aws.String("replace")
operation.Value = aws.String(strconv.FormatBool(b))
}
}
operations = append(operations, &operation)
}
for nK, nV := range newParametersMap {
exists := false
for k, _ := range oldParametersMap {
if k == nK {
exists = true
}
}
if !exists {
b, ok := nV.(bool)
if !ok {
value, _ := strconv.ParseBool(nV.(string))
b = value
}
operation := apigateway.PatchOperation{
Op: aws.String("add"),
Path: aws.String(fmt.Sprintf("/%s/%s", prefix, nK)),
Value: aws.String(strconv.FormatBool(b)),
}
operations = append(operations, &operation)
}
}
return operations, nil
}
示例2: expandApiGatewayMethodParametersJSONOperations
func expandApiGatewayMethodParametersJSONOperations(d *schema.ResourceData, key string, prefix string) ([]*apigateway.PatchOperation, error) {
operations := make([]*apigateway.PatchOperation, 0)
oldParameters, newParameters := d.GetChange(key)
oldParametersMap := make(map[string]interface{})
newParametersMap := make(map[string]interface{})
if err := json.Unmarshal([]byte(oldParameters.(string)), &oldParametersMap); err != nil {
err := fmt.Errorf("Error unmarshaling old %s: %s", key, err)
return operations, err
}
if err := json.Unmarshal([]byte(newParameters.(string)), &newParametersMap); err != nil {
err := fmt.Errorf("Error unmarshaling new %s: %s", key, err)
return operations, err
}
for k, _ := range oldParametersMap {
operation := apigateway.PatchOperation{
Op: aws.String("remove"),
Path: aws.String(fmt.Sprintf("/%s/%s", prefix, k)),
}
for nK, nV := range newParametersMap {
if nK == k {
operation.Op = aws.String("replace")
operation.Value = aws.String(strconv.FormatBool(nV.(bool)))
}
}
operations = append(operations, &operation)
}
for nK, nV := range newParametersMap {
exists := false
for k, _ := range oldParametersMap {
if k == nK {
exists = true
}
}
if !exists {
operation := apigateway.PatchOperation{
Op: aws.String("add"),
Path: aws.String(fmt.Sprintf("/%s/%s", prefix, nK)),
Value: aws.String(strconv.FormatBool(nV.(bool))),
}
operations = append(operations, &operation)
}
}
return operations, nil
}
示例3: expandApiGatewayRequestResponseModelOperations
func expandApiGatewayRequestResponseModelOperations(d *schema.ResourceData, key string, prefix string) []*apigateway.PatchOperation {
operations := make([]*apigateway.PatchOperation, 0)
oldModels, newModels := d.GetChange(key)
oldModelMap := oldModels.(map[string]interface{})
newModelMap := newModels.(map[string]interface{})
for k, _ := range oldModelMap {
operation := apigateway.PatchOperation{
Op: aws.String("remove"),
Path: aws.String(fmt.Sprintf("/%s/%s", prefix, strings.Replace(k, "/", "~1", -1))),
}
for nK, nV := range newModelMap {
if nK == k {
operation.Op = aws.String("replace")
operation.Value = aws.String(nV.(string))
}
}
operations = append(operations, &operation)
}
for nK, nV := range newModelMap {
exists := false
for k, _ := range oldModelMap {
if k == nK {
exists = true
}
}
if !exists {
operation := apigateway.PatchOperation{
Op: aws.String("add"),
Path: aws.String(fmt.Sprintf("/%s/%s", prefix, strings.Replace(nK, "/", "~1", -1))),
Value: aws.String(nV.(string)),
}
operations = append(operations, &operation)
}
}
return operations
}