| 1 |  |  | package ssm | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | import ( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | 	"context" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | 	SDK "github.com/aws/aws-sdk-go-v2/service/ssm" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | 	"github.com/evalphobia/aws-sdk-go-v2-wrapper/errors" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | 	"github.com/evalphobia/aws-sdk-go-v2-wrapper/private/pointers" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | // PutParameter executes `PutParameter` operation. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | func (svc *SSM) PutParameter(ctx context.Context, r PutParameterRequest) (*PutParameterResult, error) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 	out, err := svc.RawPutParameter(ctx, r.ToInput()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | 	if err == nil { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 		return NewPutParameterResult(out), err | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | 	if errors.GetAWSErrorCode(err) == "ParameterAlreadyExists" { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 		return &PutParameterResult{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 			AlreadyExists: true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 		}, nil | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 	err = svc.errWrap(errors.ErrorData{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 		Err:          err, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 		AWSOperation: "PutParameter", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 	}) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 	svc.Errorf(err.Error()) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 	return nil, err | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | // PutParameterRequest has parameters for `PutParameter` operation. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | type PutParameterRequest struct { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 	Name  string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 	Value string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 	// optional | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 	AllowedPattern string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 	DataType       string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 	Description    string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 	KeyID          string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 	Overwrite      bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 	Policies       string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 	Tags           []Tag | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 	Tier           ParameterTier | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 	Type           ParameterType | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  | func (r PutParameterRequest) ToInput() *SDK.PutParameterInput { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  | 	in := &SDK.PutParameterInput{} | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  | 	if r.Name != "" { | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  | 		in.Name = pointers.String(r.Name) | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  | 	if r.Value != "" { | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  | 		in.Value = pointers.String(r.Value) | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  | 	if r.AllowedPattern != "" { | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  | 		in.AllowedPattern = pointers.String(r.AllowedPattern) | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  | 	if r.DataType != "" { | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  | 		in.DataType = pointers.String(r.DataType) | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  | 	if r.Description != "" { | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  | 		in.Description = pointers.String(r.Description) | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  | 	if r.KeyID != "" { | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  | 		in.KeyId = pointers.String(r.KeyID) | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  | 	if r.Overwrite { | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  | 		in.Overwrite = pointers.Bool(r.Overwrite) | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  | 	if r.Policies != "" { | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  | 		in.Policies = pointers.String(r.Policies) | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  | 	if len(r.Tags) != 0 { | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  | 		list := make([]SDK.Tag, len(r.Tags)) | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  | 		for i, v := range r.Tags { | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  | 			list[i] = v.ToSDK() | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  | 		in.Tags = list | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  | 	in.Tier = SDK.ParameterTier(r.Tier) | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  | 	in.Type = SDK.ParameterType(r.Type) | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  | 	return in | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | type PutParameterResult struct { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 	AlreadyExists bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 	Tier    ParameterTier | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 	Version int64 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | func NewPutParameterResult(o *SDK.PutParameterResponse) *PutParameterResult { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 	result := &PutParameterResult{} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 	if o == nil { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 		return result | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 	result.Tier = ParameterTier(o.Tier) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 	if o.Version != nil { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 		result.Version = *o.Version | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 	return result | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 107 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 108 |  |  |  |