// Code generated by smithy-go-codegen DO NOT EDIT.

package cloud9

import (
	"context"
	"github.com/aws/aws-sdk-go-v2/service/cloud9/types"
	"github.com/aws/smithy-go/middleware"
	smithyhttp "github.com/aws/smithy-go/transport/http"
)

// Changes the settings of an existing environment member for an Cloud9
// development environment.
//
// Cloud9 is no longer available to new customers. Existing customers of Cloud9
// can continue to use the service as normal. [Learn more"]
//
// [Learn more"]: http://aws.amazon.com/blogs/devops/how-to-migrate-from-aws-cloud9-to-aws-ide-toolkits-or-aws-cloudshell/
func (c *Client) UpdateEnvironmentMembership(ctx context.Context, params *UpdateEnvironmentMembershipInput, optFns ...func(*Options)) (*UpdateEnvironmentMembershipOutput, error) {
	if params == nil {
		params = &UpdateEnvironmentMembershipInput{}
	}

	result, metadata, err := c.invokeOperation(ctx, "UpdateEnvironmentMembership", params, optFns, c.addOperationUpdateEnvironmentMembershipMiddlewares)
	if err != nil {
		return nil, err
	}

	out := result.(*UpdateEnvironmentMembershipOutput)
	out.ResultMetadata = metadata
	return out, nil
}

type UpdateEnvironmentMembershipInput struct {

	// The ID of the environment for the environment member whose settings you want to
	// change.
	//
	// This member is required.
	EnvironmentId *string

	// The replacement type of environment member permissions you want to associate
	// with this environment member. Available values include:
	//
	//   - read-only : Has read-only access to the environment.
	//
	//   - read-write : Has read-write access to the environment.
	//
	// This member is required.
	Permissions types.MemberPermissions

	// The Amazon Resource Name (ARN) of the environment member whose settings you
	// want to change.
	//
	// This member is required.
	UserArn *string

	noSmithyDocumentSerde
}

type UpdateEnvironmentMembershipOutput struct {

	// Information about the environment member whose settings were changed.
	Membership *types.EnvironmentMember

	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

func (c *Client) addOperationUpdateEnvironmentMembershipMiddlewares(stack *middleware.Stack, options Options) (err error) {
	err = stack.Serialize.Add(&awsAwsjson11_serializeOpUpdateEnvironmentMembership{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpUpdateEnvironmentMembership{}, middleware.After)
	if err != nil {
		return err
	}

	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
		return err
	}
	if err = addComputeContentLength(stack); err != nil {
		return err
	}
	if err = addResolveEndpointMiddleware(stack, options); err != nil {
		return err
	}
	if err = addComputePayloadSHA256(stack); err != nil {
		return err
	}
	if err = addRecordResponseTiming(stack, options); err != nil {
		return err
	}
	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = addCredentialSource(stack, options); err != nil {
		return err
	}
	if err = addOpUpdateEnvironmentMembershipValidationMiddleware(stack); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "UpdateEnvironmentMembership"), middleware.Before); err != nil {
		return err
	}
	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
		return err
	}
	if err = addResponseErrorMiddleware(stack); err != nil {
		return err
	}
	if err = addRequestResponseLogging(stack, options); err != nil {
		return err
	}
	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
		return err
	}
	if err = addInterceptors(stack, options); err != nil {
		return err
	}
	return nil
}
