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

package bedrockagentcore

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

// Get the balance of a payment instrument.
func (c *Client) GetPaymentInstrumentBalance(ctx context.Context, params *GetPaymentInstrumentBalanceInput, optFns ...func(*Options)) (*GetPaymentInstrumentBalanceOutput, error) {
	if params == nil {
		params = &GetPaymentInstrumentBalanceInput{}
	}

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

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

// Request structure for getting payment instrument balance.
type GetPaymentInstrumentBalanceInput struct {

	// The specific blockchain chain to query balance on. Required because balances
	// are chain-specific.
	//
	// This member is required.
	Chain types.BlockchainChainId

	// The ID of the payment connector associated with this instrument.
	//
	// This member is required.
	PaymentConnectorId *string

	// The ID of the payment instrument to query balance for.
	//
	// This member is required.
	PaymentInstrumentId *string

	// The ARN of the payment manager that owns this payment instrument.
	//
	// This member is required.
	PaymentManagerArn *string

	// The token to query balance for. Only tokens supported for X402 payments are
	// returned.
	//
	// This member is required.
	Token types.InstrumentBalanceToken

	// The agent name associated with this request, used for observability.
	AgentName *string

	// The user ID associated with this payment instrument.
	UserId *string

	noSmithyDocumentSerde
}

// Response structure for getting payment instrument balance.
type GetPaymentInstrumentBalanceOutput struct {

	// The ID of the payment instrument.
	//
	// This member is required.
	PaymentInstrumentId *string

	// The balance of the supported token on the requested chain.
	//
	// This member is required.
	TokenBalance *types.TokenBalance

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

	noSmithyDocumentSerde
}

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