> **Experimental**
>
> `@aws-cdk/aws-bedrock-alpha` is an [**experimental**](https://docs.aws.amazon.com/cdk/api/stability.html) (alpha) package: its API may change in any release, without a major version bump.
# AssetApiSchema

API Schema from a local asset.

The asset is uploaded to an S3 staging bucket, then moved to its final location
by CloudFormation during deployment.

Extends: [ApiSchema](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.ApiSchema.html) › AssetApiSchema
Obtainable from: [ApiSchema.fromLocalAsset](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.ApiSchema.html#fromlocalasset)

- Stability: [Experimental](https://docs.aws.amazon.com/cdk/api/stability.html)
- Source: [`bedrock/agents/api-schema.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/@aws-cdk/aws-bedrock-alpha/bedrock/agents/api-schema.ts#L76)

## Example

TypeScript:

```ts
const actionGroupFunction = new lambda.Function(this, 'ActionGroupFunction', {
  runtime: lambda.Runtime.PYTHON_3_12,
  handler: 'index.handler',
  code: lambda.Code.fromAsset(path.join(__dirname, '../lambda/action-group')),
});

// When using ApiSchema.fromLocalAsset, you must bind the schema to a scope
const schema = bedrock.ApiSchema.fromLocalAsset(path.join(__dirname, 'action-group.yaml'));
schema.bind(this);

const actionGroup = new bedrock.AgentActionGroup({
  name: 'query-library',
  description: 'Use these functions to get information about the books in the library.',
  executor: bedrock.ActionGroupExecutor.fromLambda(actionGroupFunction),
  enabled: true,
  apiSchema: schema,
});

const agent = new bedrock.Agent(this, 'Agent', {
  foundationModel: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,
  instruction: 'You are a helpful and friendly agent that answers questions about literature.',
});

agent.addActionGroup(actionGroup);
```

Python:

```python
action_group_function = lambda_.Function(self, "ActionGroupFunction",
    runtime=lambda_.Runtime.PYTHON_3_12,
    handler="index.handler",
    code=lambda_.Code.from_asset(path.join(__dirname, "../lambda/action-group"))
)

# When using ApiSchema.fromLocalAsset, you must bind the schema to a scope
schema = bedrock.ApiSchema.from_local_asset(path.join(__dirname, "action-group.yaml"))
schema.bind(self)

action_group = bedrock.AgentActionGroup(
    name="query-library",
    description="Use these functions to get information about the books in the library.",
    executor=bedrock.ActionGroupExecutor.from_lambda(action_group_function),
    enabled=True,
    api_schema=schema
)

agent = bedrock.Agent(self, "Agent",
    foundation_model=bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,
    instruction="You are a helpful and friendly agent that answers questions about literature."
)

agent.add_action_group(action_group)
```

Java:

```java
Function actionGroupFunction = Function.Builder.create(this, "ActionGroupFunction")
        .runtime(Runtime.PYTHON_3_12)
        .handler("index.handler")
        .code(Code.fromAsset(join(__dirname, "../lambda/action-group")))
        .build();

// When using ApiSchema.fromLocalAsset, you must bind the schema to a scope
AssetApiSchema schema = ApiSchema.fromLocalAsset(join(__dirname, "action-group.yaml"));
schema.bind(this);

AgentActionGroup actionGroup = AgentActionGroup.Builder.create()
        .name("query-library")
        .description("Use these functions to get information about the books in the library.")
        .executor(ActionGroupExecutor.fromLambda(actionGroupFunction))
        .enabled(true)
        .apiSchema(schema)
        .build();

Agent agent = Agent.Builder.create(this, "Agent")
        .foundationModel(BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0)
        .instruction("You are a helpful and friendly agent that answers questions about literature.")
        .build();

agent.addActionGroup(actionGroup);
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Alpha
var actionGroupFunction = new Function(this, "ActionGroupFunction", new FunctionProps {
    Runtime = Runtime.PYTHON_3_12,
    Handler = "index.handler",
    Code = Code.FromAsset(Join(__dirname, "../lambda/action-group"))
});

// When using ApiSchema.fromLocalAsset, you must bind the schema to a scope
var schema = ApiSchema.FromLocalAsset(Join(__dirname, "action-group.yaml"));
schema.Bind(this);

var actionGroup = new AgentActionGroup(new AgentActionGroupProps {
    Name = "query-library",
    Description = "Use these functions to get information about the books in the library.",
    Executor = ActionGroupExecutor.FromLambda(actionGroupFunction),
    Enabled = true,
    ApiSchema = schema
});

var agent = new Agent(this, "Agent", new AgentProps {
    FoundationModel = BedrockFoundationModel.ANTHROPIC_CLAUDE_HAIKU_V1_0,
    Instruction = "You are a helpful and friendly agent that answers questions about literature."
});

agent.AddActionGroup(actionGroup);
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockalpha/v2
actionGroupFunction := lambda.NewFunction(this, jsii.String("ActionGroupFunction"), &FunctionProps{
	Runtime: lambda.Runtime_PYTHON_3_12(),
	Handler: jsii.String("index.handler"),
	Code: lambda.Code_FromAsset(path.join(__dirname, jsii.String("../lambda/action-group"))),
})

// When using ApiSchema.fromLocalAsset, you must bind the schema to a scope
schema := bedrock.ApiSchema_FromLocalAsset(path.join(__dirname, jsii.String("action-group.yaml")))
schema.Bind(this)

actionGroup := bedrock.NewAgentActionGroup(&AgentActionGroupProps{
	Name: jsii.String("query-library"),
	Description: jsii.String("Use these functions to get information about the books in the library."),
	Executor: bedrock.ActionGroupExecutor_FromLambda(actionGroupFunction),
	Enabled: jsii.Boolean(true),
	ApiSchema: schema,
})

agent := bedrock.NewAgent(this, jsii.String("Agent"), &AgentProps{
	FoundationModel: bedrock.BedrockFoundationModel_ANTHROPIC_CLAUDE_HAIKU_V1_0(),
	Instruction: jsii.String("You are a helpful and friendly agent that answers questions about literature."),
})

agent.AddActionGroup(actionGroup)
```

## Initializer

TypeScript:

```ts
new AssetApiSchema(path: string, options?: AssetOptions)
```

Python:

```python
AssetApiSchema(path: str, options: typing.Optional[AssetOptions] = None)
```

Java:

```java
new AssetApiSchema(String path, AssetOptions options)
```

C# / .NET:

```csharp
new AssetApiSchema(string path, AssetOptions? options = null)
```

Golang:

```go
NewAssetApiSchema(Path *string, Options AssetOptions)
```

## Properties

- `inlineSchema`: string — The inline OpenAPI schema definition as a string, if using an inline schema.

  Can be in JSON or YAML format.

- `s3File`: [Location](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.Location.html) — The S3 location of the API schema file, if using an S3-based schema.

  Contains the bucket name and object key information.

## Methods

- `bind(scope: Construct): void` — Binds this API schema to a construct scope.

  This method initializes the S3 asset if it hasn't been initialized yet.
  Must be called before rendering the schema as CFN properties.

  **Parameters**

  - `scope` — - The construct scope to bind to.

- `fromInline(schema: string): InlineApiSchema` (static) — Creates an API Schema from an inline string.

  **Parameters**

  - `schema` — - the JSON or YAML payload defining the OpenAPI schema for the action group.

- `fromLocalAsset(path: string): AssetApiSchema // chainable` (static) — Creates an API Schema from a local file.

  **Parameters**

  - `path` — - the path to the local file containing the OpenAPI schema for the action group.

- `fromS3File(bucket: IBucketRef, objectKey: string): S3ApiSchema` (static) — Creates an API Schema from an S3 File.

  **Parameters**

  - `bucket` — - the bucket containing the local file containing the OpenAPI schema for the action group.
  - `objectKey` — - object key in the bucket.
