// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. package appconfig import ( "context" "fmt" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/internal/awsutil" "github.com/aws/aws-sdk-go-v2/private/protocol" ) type CreateEnvironmentInput struct { _ struct{} `type:"structure"` // The application ID. // // ApplicationId is a required field ApplicationId *string `location:"uri" locationName:"ApplicationId" type:"string" required:"true"` // A description of the environment. Description *string `type:"string"` // Amazon CloudWatch alarms to monitor during the deployment process. Monitors []Monitor `type:"list"` // A name for the environment. // // Name is a required field Name *string `min:"1" type:"string" required:"true"` // Metadata to assign to the environment. Tags help organize and categorize // your AppConfig resources. Each tag consists of a key and an optional value, // both of which you define. Tags map[string]string `type:"map"` } // String returns the string representation func (s CreateEnvironmentInput) String() string { return awsutil.Prettify(s) } // Validate inspects the fields of the type to determine if they are valid. func (s *CreateEnvironmentInput) Validate() error { invalidParams := aws.ErrInvalidParams{Context: "CreateEnvironmentInput"} if s.ApplicationId == nil { invalidParams.Add(aws.NewErrParamRequired("ApplicationId")) } if s.Name == nil { invalidParams.Add(aws.NewErrParamRequired("Name")) } if s.Name != nil && len(*s.Name) < 1 { invalidParams.Add(aws.NewErrParamMinLen("Name", 1)) } if s.Monitors != nil { for i, v := range s.Monitors { if err := v.Validate(); err != nil { invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Monitors", i), err.(aws.ErrInvalidParams)) } } } if invalidParams.Len() > 0 { return invalidParams } return nil } // MarshalFields encodes the AWS API shape using the passed in protocol encoder. func (s CreateEnvironmentInput) MarshalFields(e protocol.FieldEncoder) error { e.SetValue(protocol.HeaderTarget, "Content-Type", protocol.StringValue("application/json"), protocol.Metadata{}) if s.Description != nil { v := *s.Description metadata := protocol.Metadata{} e.SetValue(protocol.BodyTarget, "Description", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) } if s.Monitors != nil { v := s.Monitors metadata := protocol.Metadata{} ls0 := e.List(protocol.BodyTarget, "Monitors", metadata) ls0.Start() for _, v1 := range v { ls0.ListAddFields(v1) } ls0.End() } if s.Name != nil { v := *s.Name metadata := protocol.Metadata{} e.SetValue(protocol.BodyTarget, "Name", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) } if s.Tags != nil { v := s.Tags metadata := protocol.Metadata{} ms0 := e.Map(protocol.BodyTarget, "Tags", metadata) ms0.Start() for k1, v1 := range v { ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) } ms0.End() } if s.ApplicationId != nil { v := *s.ApplicationId metadata := protocol.Metadata{} e.SetValue(protocol.PathTarget, "ApplicationId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) } return nil } type CreateEnvironmentOutput struct { _ struct{} `type:"structure"` // The application ID. ApplicationId *string `type:"string"` // The description of the environment. Description *string `type:"string"` // The environment ID. Id *string `type:"string"` // Amazon CloudWatch alarms monitored during the deployment. Monitors []Monitor `type:"list"` // The name of the environment. Name *string `min:"1" type:"string"` // The state of the environment. An environment can be in one of the following // states: READY_FOR_DEPLOYMENT, DEPLOYING, ROLLING_BACK, or ROLLED_BACK State EnvironmentState `type:"string" enum:"true"` } // String returns the string representation func (s CreateEnvironmentOutput) String() string { return awsutil.Prettify(s) } // MarshalFields encodes the AWS API shape using the passed in protocol encoder. func (s CreateEnvironmentOutput) MarshalFields(e protocol.FieldEncoder) error { if s.ApplicationId != nil { v := *s.ApplicationId metadata := protocol.Metadata{} e.SetValue(protocol.BodyTarget, "ApplicationId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) } if s.Description != nil { v := *s.Description metadata := protocol.Metadata{} e.SetValue(protocol.BodyTarget, "Description", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) } if s.Id != nil { v := *s.Id metadata := protocol.Metadata{} e.SetValue(protocol.BodyTarget, "Id", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) } if s.Monitors != nil { v := s.Monitors metadata := protocol.Metadata{} ls0 := e.List(protocol.BodyTarget, "Monitors", metadata) ls0.Start() for _, v1 := range v { ls0.ListAddFields(v1) } ls0.End() } if s.Name != nil { v := *s.Name metadata := protocol.Metadata{} e.SetValue(protocol.BodyTarget, "Name", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) } if len(s.State) > 0 { v := s.State metadata := protocol.Metadata{} e.SetValue(protocol.BodyTarget, "State", protocol.QuotedValue{ValueMarshaler: v}, metadata) } return nil } const opCreateEnvironment = "CreateEnvironment" // CreateEnvironmentRequest returns a request value for making API operation for // Amazon AppConfig. // // For each application, you define one or more environments. An environment // is a logical deployment group of AppConfig targets, such as applications // in a Beta or Production environment. You can also define environments for // application subcomponents such as the Web, Mobile and Back-end components // for your application. You can configure Amazon CloudWatch alarms for each // environment. The system monitors alarms during a configuration deployment. // If an alarm is triggered, the system rolls back the configuration. // // // Example sending a request using CreateEnvironmentRequest. // req := client.CreateEnvironmentRequest(params) // resp, err := req.Send(context.TODO()) // if err == nil { // fmt.Println(resp) // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/appconfig-2019-10-09/CreateEnvironment func (c *Client) CreateEnvironmentRequest(input *CreateEnvironmentInput) CreateEnvironmentRequest { op := &aws.Operation{ Name: opCreateEnvironment, HTTPMethod: "POST", HTTPPath: "/applications/{ApplicationId}/environments", } if input == nil { input = &CreateEnvironmentInput{} } req := c.newRequest(op, input, &CreateEnvironmentOutput{}) return CreateEnvironmentRequest{Request: req, Input: input, Copy: c.CreateEnvironmentRequest} } // CreateEnvironmentRequest is the request type for the // CreateEnvironment API operation. type CreateEnvironmentRequest struct { *aws.Request Input *CreateEnvironmentInput Copy func(*CreateEnvironmentInput) CreateEnvironmentRequest } // Send marshals and sends the CreateEnvironment API request. func (r CreateEnvironmentRequest) Send(ctx context.Context) (*CreateEnvironmentResponse, error) { r.Request.SetContext(ctx) err := r.Request.Send() if err != nil { return nil, err } resp := &CreateEnvironmentResponse{ CreateEnvironmentOutput: r.Request.Data.(*CreateEnvironmentOutput), response: &aws.Response{Request: r.Request}, } return resp, nil } // CreateEnvironmentResponse is the response type for the // CreateEnvironment API operation. type CreateEnvironmentResponse struct { *CreateEnvironmentOutput response *aws.Response } // SDKResponseMetdata returns the response metadata for the // CreateEnvironment request. func (r *CreateEnvironmentResponse) SDKResponseMetdata() *aws.Response { return r.response }