Skip to content
v2.275.0

AssetApiSchema Class ​

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.

Example ​

ts

const gateway = new agentcore.Gateway(this, "MyGateway", {
  gatewayName: "my-gateway",
});

const smithySchema = agentcore.ApiSchema.fromLocalAsset(
  path.join(__dirname, "models", "smithy-model.json")
);
smithySchema.bind(this);

// Create a gateway target with Smithy Model and OAuth
const target = agentcore.GatewayTarget.forSmithy(this, "MySmithyTarget", {
  gatewayTargetName: "my-smithy-target",
  description: "Target for Smithy model integration",
  gateway: gateway,
  smithyModel: smithySchema,
});
python
gateway = agentcore.Gateway(self, "MyGateway",
    gateway_name="my-gateway"
)

smithy_schema = agentcore.ApiSchema.from_local_asset(
    path.join(__dirname, "models", "smithy-model.json"))
smithy_schema.bind(self)

# Create a gateway target with Smithy Model and OAuth
target = agentcore.GatewayTarget.for_smithy(self, "MySmithyTarget",
    gateway_target_name="my-smithy-target",
    description="Target for Smithy model integration",
    gateway=gateway,
    smithy_model=smithy_schema
)
java
Gateway gateway = Gateway.Builder.create(this, "MyGateway")
        .gatewayName("my-gateway")
        .build();

AssetApiSchema smithySchema = ApiSchema.fromLocalAsset(path.join(__dirname, "models", "smithy-model.json"));
smithySchema.bind(this);

// Create a gateway target with Smithy Model and OAuth
GatewayTarget target = GatewayTarget.forSmithy(this, "MySmithyTarget", GatewayTargetSmithyProps.builder()
        .gatewayTargetName("my-smithy-target")
        .description("Target for Smithy model integration")
        .gateway(gateway)
        .smithyModel(smithySchema)
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
var gateway = new Gateway(this, "MyGateway", new GatewayProps {
    GatewayName = "my-gateway"
});

var smithySchema = ApiSchema.FromLocalAsset(path.Join(__dirname, "models", "smithy-model.json"));
smithySchema.Bind(this);

// Create a gateway target with Smithy Model and OAuth
var target = GatewayTarget.ForSmithy(this, "MySmithyTarget", new GatewayTargetSmithyProps {
    GatewayTargetName = "my-smithy-target",
    Description = "Target for Smithy model integration",
    Gateway = gateway,
    SmithyModel = smithySchema
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
gateway := agentcore.NewGateway(this, jsii.String("MyGateway"), &GatewayProps{
	GatewayName: jsii.String("my-gateway"),
})

smithySchema := agentcore.ApiSchema_FromLocalAsset(path.join(__dirname, jsii.String("models"), jsii.String("smithy-model.json")))
smithySchema.Bind(this)

// Create a gateway target with Smithy Model and OAuth
target := agentcore.GatewayTarget_ForSmithy(this, jsii.String("MySmithyTarget"), &GatewayTargetSmithyProps{
	GatewayTargetName: jsii.String("my-smithy-target"),
	Description: jsii.String("Target for Smithy model integration"),
	Gateway: gateway,
	SmithyModel: smithySchema,
})

Initializer ​

ts
new AssetApiSchema(path: string, options?: AssetOptions)
python
AssetApiSchema(path: str, options: typing.Optional[AssetOptions] = None)
java
new AssetApiSchema(String path, AssetOptions options)
csharp
new AssetApiSchema(string path, AssetOptions? options = null)
go
NewAssetApiSchema(Path *string, Options AssetOptions)

Properties ​

bucketOwnerAccountIdmay be undefinedstringbucket_owner_account_idmay be undefinedstrbucketOwnerAccountIdmay be undefinedStringBucketOwnerAccountIdmay be undefinedstringBucketOwnerAccountIdmay be undefined*string#
The account ID of the S3 bucket owner for cross-account access.
inlineSchemamay be undefinedstringinline_schemamay be undefinedstrinlineSchemamay be undefinedStringInlineSchemamay be undefinedstringInlineSchemamay be undefined*string#
The inline OpenAPI schema definition as a string, if using an inline schema.

Can be in JSON or YAML format.

s3Filemay be undefinedLocations3_filemay be undefinedLocations3Filemay be undefinedLocationS3Filemay be undefinedLocationS3Filemay be undefinedLocation#
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): voiddef bind(self, scope: Construct) -> Nonepublic void bind(Construct scope)public void Bind(Construct scope)func Bind(Scope Construct)#
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.

1 parameter

Parameters

  • scopescopescopescopeScope — - The construct scope to bind to.
fromInline(schema: string): InlineApiSchema@staticmethod def from_inline(schema: str) -> InlineApiSchemapublic static InlineApiSchema fromInline(String schema)public static InlineApiSchema FromInline(string schema)func FromInline(Schema *string) InlineApiSchemastatic#
Creates an API Schema from an inline string.
1 parameter

Parameters

  • schemaschemaschemaschemaSchema — - the JSON or YAML payload defining the schema (OpenAPI or Smithy).
fromLocalAsset(path: string): AssetApiSchema // chainable@staticmethod def from_local_asset(path: str) -> AssetApiSchemapublic static AssetApiSchema fromLocalAsset(String path)public static AssetApiSchema FromLocalAsset(string path)func FromLocalAsset(Path *string) AssetApiSchemastatic#
Creates an API Schema from a local file.
1 parameter

Parameters

  • pathpathpathpathPath — - the path to the local file containing the OpenAPI schema for the action group.
fromS3File(bucket: IBucket, objectKey: string, bucketOwnerAccountId?: string): S3ApiSchema@staticmethod def from_s3_file(bucket: IBucket, object_key: str, bucket_owner_account_id: typing.Optional[str] = None) -> S3ApiSchemapublic static S3ApiSchema fromS3File(IBucket bucket, String objectKey, String bucketOwnerAccountId)public static S3ApiSchema FromS3File(IBucket bucket, string objectKey, string? bucketOwnerAccountId = null)func FromS3File(Bucket IBucket, ObjectKey *string, BucketOwnerAccountId *string) S3ApiSchemastatic#
Creates an API Schema from an S3 File.
3 parameters

Parameters

  • bucketbucketbucketbucketBucket — - the bucket containing the local file containing the OpenAPI schema for the action group.
  • objectKeyobject_keyobjectKeyobjectKeyObjectKey — - object key in the bucket.
  • bucketOwnerAccountIdbucket_owner_account_idbucketOwnerAccountIdbucketOwnerAccountIdBucketOwnerAccountId — - optional The account ID of the Amazon S3 bucket owner.
grantPermissionsToRole(role: IRole): voiddef grant_permissions_to_role(self, role: IRole) -> Nonepublic void grantPermissionsToRole(IRole role)public void GrantPermissionsToRole(IRole role)func GrantPermissionsToRole(Role IRole)#
Grant permissions to the role.