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

package bedrockagentcorecontrol

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

// Creates a new OAuth2 credential provider.
func (c *Client) CreateOauth2CredentialProvider(ctx context.Context, params *CreateOauth2CredentialProviderInput, optFns ...func(*Options)) (*CreateOauth2CredentialProviderOutput, error) {
	if params == nil {
		params = &CreateOauth2CredentialProviderInput{}
	}

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

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

type CreateOauth2CredentialProviderInput struct {

	// The vendor of the OAuth2 credential provider. This specifies which OAuth2
	// implementation to use.
	//
	// This member is required.
	CredentialProviderVendor types.CredentialProviderVendorType

	// The name of the OAuth2 credential provider. The name must be unique within your
	// account.
	//
	// This member is required.
	Name *string

	// The configuration settings for the OAuth2 provider, including client ID, client
	// secret, and other vendor-specific settings.
	//
	// This member is required.
	Oauth2ProviderConfigInput types.Oauth2ProviderConfigInput

	// A map of tag keys and values to assign to the OAuth2 credential provider. Tags
	// enable you to categorize your resources in different ways, for example, by
	// purpose, owner, or environment.
	Tags map[string]string

	noSmithyDocumentSerde
}

type CreateOauth2CredentialProviderOutput struct {

	// The Amazon Resource Name (ARN) of the client secret in Amazon Web Services
	// Secrets Manager.
	//
	// This member is required.
	ClientSecretArn *types.Secret

	// The Amazon Resource Name (ARN) of the OAuth2 credential provider.
	//
	// This member is required.
	CredentialProviderArn *string

	// The name of the OAuth2 credential provider.
	//
	// This member is required.
	Name *string

	// Callback URL to register on the OAuth2 credential provider as an allowed
	// callback URL. This URL is where the OAuth2 authorization server redirects users
	// after they complete the authorization flow.
	CallbackUrl *string

	// The JSON key used to extract the client secret value from the Amazon Web
	// Services Secrets Manager secret.
	ClientSecretJsonKey *string

	// The source type of the client secret. Either MANAGED if the secret is managed
	// by the service, or EXTERNAL if managed by the user in Amazon Web Services
	// Secrets Manager.
	ClientSecretSource types.SecretSourceType

	// Contains the output configuration for an OAuth2 provider.
	Oauth2ProviderConfigOutput types.Oauth2ProviderConfigOutput

	// The current status of the OAuth2 credential provider.
	Status types.Status

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

	noSmithyDocumentSerde
}

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