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

package appsync

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

// Updates a ChannelNamespace associated with an Api .
func (c *Client) UpdateChannelNamespace(ctx context.Context, params *UpdateChannelNamespaceInput, optFns ...func(*Options)) (*UpdateChannelNamespaceOutput, error) {
	if params == nil {
		params = &UpdateChannelNamespaceInput{}
	}

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

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

type UpdateChannelNamespaceInput struct {

	// The Api ID.
	//
	// This member is required.
	ApiId *string

	// The name of the ChannelNamespace .
	//
	// This member is required.
	Name *string

	// The event handler functions that run custom business logic to process published
	// events and subscribe requests.
	CodeHandlers *string

	// The configuration for the OnPublish and OnSubscribe handlers.
	HandlerConfigs *types.HandlerConfigs

	// The authorization mode to use for publishing messages on the channel namespace.
	// This configuration overrides the default Api authorization configuration.
	PublishAuthModes []types.AuthMode

	// The authorization mode to use for subscribing to messages on the channel
	// namespace. This configuration overrides the default Api authorization
	// configuration.
	SubscribeAuthModes []types.AuthMode

	noSmithyDocumentSerde
}

type UpdateChannelNamespaceOutput struct {

	// The ChannelNamespace object.
	ChannelNamespace *types.ChannelNamespace

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

	noSmithyDocumentSerde
}

func (c *Client) addOperationUpdateChannelNamespaceMiddlewares(stack *middleware.Stack, options Options) (err error) {
	err = stack.Serialize.Add(&awsRestjson1_serializeOpUpdateChannelNamespace{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpUpdateChannelNamespace{}, 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); 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 = addOpUpdateChannelNamespaceValidationMiddleware(stack); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware(options.Region, "UpdateChannelNamespace"), 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
}
