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

package bedrockagentcore

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

//	Searches for registry records using semantic, lexical, or hybrid queries.
//
// Returns metadata for matching records ordered by relevance within the specified
// registry.
func (c *Client) SearchRegistryRecords(ctx context.Context, params *SearchRegistryRecordsInput, optFns ...func(*Options)) (*SearchRegistryRecordsOutput, error) {
	if params == nil {
		params = &SearchRegistryRecordsInput{}
	}

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

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

type SearchRegistryRecordsInput struct {

	//  The list of registry identifiers to search within. Currently, you can specify
	// exactly one registry identifier. You can provide either the full Amazon Web
	// Services Resource Name (ARN) or the 12-character alphanumeric registry ID.
	//
	// This member is required.
	RegistryIds []string

	//  The search query to find matching registry records.
	//
	// This member is required.
	SearchQuery *string

	//  A metadata filter expression to narrow search results. Uses structured JSON
	// operators including field-level operators ( $eq , $ne , $in ) and logical
	// operators ( $and , $or ) on filterable fields ( name , descriptorType , version
	// ). For example, to filter by descriptor type: {"descriptorType": {"$eq":
	// "MCP"}} . To combine filters: {"$and": [{"descriptorType": {"$eq": "MCP"}},
	// {"name": {"$eq": "my-tool"}}]} .
	Filters document.Interface

	//  The maximum number of records to return in a single call. Valid values are 1
	// through 20. The default value is 10.
	MaxResults *int32

	noSmithyDocumentSerde
}

type SearchRegistryRecordsOutput struct {

	//  The list of registry records that match the search query, ordered by relevance.
	//
	// This member is required.
	RegistryRecords []types.RegistryRecordSummary

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

	noSmithyDocumentSerde
}

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