// Code generated by smithy-go-codegen DO NOT EDIT. package iotsitewise import ( "context" "fmt" awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" "github.com/aws/aws-sdk-go-v2/aws/signer/v4" "github.com/aws/aws-sdk-go-v2/service/iotsitewise/types" "github.com/aws/smithy-go/middleware" smithyhttp "github.com/aws/smithy-go/transport/http" ) // Deletes an asset model. This action can't be undone. You must delete all assets // created from an asset model before you can delete the model. Also, you can't // delete an asset model if a parent asset model exists that contains a property // formula expression that depends on the asset model that you want to delete. For // more information, see Deleting assets and models // (https://docs.aws.amazon.com/iot-sitewise/latest/userguide/delete-assets-and-models.html) // in the AWS IoT SiteWise User Guide. func (c *Client) DeleteAssetModel(ctx context.Context, params *DeleteAssetModelInput, optFns ...func(*Options)) (*DeleteAssetModelOutput, error) { if params == nil { params = &DeleteAssetModelInput{} } result, metadata, err := c.invokeOperation(ctx, "DeleteAssetModel", params, optFns, addOperationDeleteAssetModelMiddlewares) if err != nil { return nil, err } out := result.(*DeleteAssetModelOutput) out.ResultMetadata = metadata return out, nil } type DeleteAssetModelInput struct { // The ID of the asset model to delete. // // This member is required. AssetModelId *string // A unique case-sensitive identifier that you can provide to ensure the // idempotency of the request. Don't reuse this client token if a new idempotent // request is required. ClientToken *string } type DeleteAssetModelOutput struct { // The status of the asset model, which contains a state (DELETING after // successfully calling this operation) and any error message. // // This member is required. AssetModelStatus *types.AssetModelStatus // Metadata pertaining to the operation's result. ResultMetadata middleware.Metadata } func addOperationDeleteAssetModelMiddlewares(stack *middleware.Stack, options Options) (err error) { err = stack.Serialize.Add(&awsRestjson1_serializeOpDeleteAssetModel{}, middleware.After) if err != nil { return err } err = stack.Deserialize.Add(&awsRestjson1_deserializeOpDeleteAssetModel{}, middleware.After) if err != nil { return err } if err = addSetLoggerMiddleware(stack, options); err != nil { return err } if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { return err } if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { return err } if err = addResolveEndpointMiddleware(stack, options); err != nil { return err } if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { return err } if err = addRetryMiddlewares(stack, options); err != nil { return err } if err = addHTTPSignerV4Middleware(stack, options); err != nil { return err } if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { return err } if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { return err } if err = addClientUserAgent(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 = addEndpointPrefix_opDeleteAssetModelMiddleware(stack); err != nil { return err } if err = addIdempotencyToken_opDeleteAssetModelMiddleware(stack, options); err != nil { return err } if err = addOpDeleteAssetModelValidationMiddleware(stack); err != nil { return err } if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDeleteAssetModel(options.Region), 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 } return nil } type endpointPrefix_opDeleteAssetModelMiddleware struct { } func (*endpointPrefix_opDeleteAssetModelMiddleware) ID() string { return "EndpointHostPrefix" } func (m *endpointPrefix_opDeleteAssetModelMiddleware) HandleSerialize(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) ( out middleware.SerializeOutput, metadata middleware.Metadata, err error, ) { if smithyhttp.GetHostnameImmutable(ctx) || smithyhttp.IsEndpointHostPrefixDisabled(ctx) { return next.HandleSerialize(ctx, in) } req, ok := in.Request.(*smithyhttp.Request) if !ok { return out, metadata, fmt.Errorf("unknown transport type %T", in.Request) } req.URL.Host = "model." + req.URL.Host return next.HandleSerialize(ctx, in) } func addEndpointPrefix_opDeleteAssetModelMiddleware(stack *middleware.Stack) error { return stack.Serialize.Insert(&endpointPrefix_opDeleteAssetModelMiddleware{}, `OperationSerializer`, middleware.After) } type idempotencyToken_initializeOpDeleteAssetModel struct { tokenProvider IdempotencyTokenProvider } func (*idempotencyToken_initializeOpDeleteAssetModel) ID() string { return "OperationIdempotencyTokenAutoFill" } func (m *idempotencyToken_initializeOpDeleteAssetModel) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) ( out middleware.InitializeOutput, metadata middleware.Metadata, err error, ) { if m.tokenProvider == nil { return next.HandleInitialize(ctx, in) } input, ok := in.Parameters.(*DeleteAssetModelInput) if !ok { return out, metadata, fmt.Errorf("expected middleware input to be of type *DeleteAssetModelInput ") } if input.ClientToken == nil { t, err := m.tokenProvider.GetIdempotencyToken() if err != nil { return out, metadata, err } input.ClientToken = &t } return next.HandleInitialize(ctx, in) } func addIdempotencyToken_opDeleteAssetModelMiddleware(stack *middleware.Stack, cfg Options) error { return stack.Initialize.Add(&idempotencyToken_initializeOpDeleteAssetModel{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before) } func newServiceMetadataMiddleware_opDeleteAssetModel(region string) *awsmiddleware.RegisterServiceMetadata { return &awsmiddleware.RegisterServiceMetadata{ Region: region, ServiceID: ServiceID, SigningName: "iotsitewise", OperationName: "DeleteAssetModel", } }