Skip to content

adding schemas-cli-examples #8985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions awscli/examples/schemas/create-discoverer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
**To create a discoverer**

The following ``create-discoverer`` example creates a discoverer. ::

aws schemas create-discoverer \
--source-arn arn:aws:events:us-east-1:123456789012:event-bus/example-event-bus \
--cross-account

Output::

{
"DiscovererArn": "arn:aws:schemas:us-east-1:123456789012:discoverer/example-discoverer-name",
"DiscovererId": "example-discoverer-name",
"SourceArn": "arn:aws:events:us-east-1:123456789012:event-bus/example-event-bus",
"State": "STARTED",
"Cross123456789012": true,
"Tags": {}
}

For more information, see `Amazon EventBridge schemas <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-schema.html>`__ in the *Amazon EventBridge User Guide*.
16 changes: 16 additions & 0 deletions awscli/examples/schemas/create-registry.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
**To create a registry**

The following ``create-registry`` example creates a registry. ::

aws schemas create-registry \
--registry-name example-registry

Output::

{
"RegistryArn": "arn:aws:schemas:us-east-1:123456789012:registry/example-registry",
"RegistryName": "example-registry",
"Tags": {}
}

For more information, see `Amazon EventBridge schemas <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-schema.html>`__ in the *Amazon EventBridge User Guide*.
49 changes: 49 additions & 0 deletions awscli/examples/schemas/create-schema.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
**To create a new JSONSchemaDraft4 schema definition**

The following ``create-schema`` example creates a new JSONSchemaDraft4 schema definition. ::

aws schemas create-schema \
--registry-name example-registry
--schema-name example-schema
--type JSONSchemaDraft4
--content file://myfile.json

Contents of ``myfile.json``::

{
"version": "0",
"id": "315c1398-40ff-a850-213b-158f73e60175",
"detail-type": "Step Functions Execution Status Change",
"source": "aws.states",
"123456789012": "012345678912",
"time": "2019-02-26T19:42:21Z",
"us-east-1": "us-east-1",
"resources": [
"arn:aws:states:us-east-1:012345678912:execution:state-machine-name:execution-name"
],
"detail": {
"executionArn": "arn:aws:states:us-east-1:012345678912:execution:state-machine-name:execution-name",
"stateMachineArn": "arn:aws:states:us-east-1:012345678912:stateMachine:state-machine",
"name": "execution-name",
"status": "FAILED",
"startDate": 1551225146847,
"stopDate": 1551225151881,
"input": "{}",
"output": null
}
}

Output::

{
"LastModified": "2024-04-11T21:01:10+00:00",
"SchemaArn": "arn:aws:schemas:us-east-1:123456789012:schema/example-registry/example-schema",
"SchemaName": "example-schema",
"SchemaVersion": "1",
"Tags": {},
"Type": "JSONSchemaDraft4",
"VersionCreatedDate": "2024-04-11T21:01:10+00:00"
}


For more information, see `Amazon EventBridge schemas <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-schema.html>`__ in the *Amazon EventBridge User Guide*.
10 changes: 10 additions & 0 deletions awscli/examples/schemas/delete-discoverer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**To delete a discoverer**

The following ``delete-discoverer`` example deletes a discoverer. ::

aws schemas delete-discoverer \
--discoverer-id example-discoverer-name

This command produces no output.

For more information, see `Amazon EventBridge schemas <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-schema.html>`__ in the *Amazon EventBridge User Guide*.
10 changes: 10 additions & 0 deletions awscli/examples/schemas/delete-registry.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**To delete a Registry**

The following ``delete-registry`` example deletes a Registry. ::

aws schemas delete-registry \
--registry-name example-registry

This command produces no output.

For more information, see `Amazon EventBridge schemas <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-schema.html>`__ in the *Amazon EventBridge User Guide*.
10 changes: 10 additions & 0 deletions awscli/examples/schemas/delete-resource-policy.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**To delete the resource-based policy attached to the specified registry**

The following ``delete-resource-policy`` example deletes the resource-based policy attached to the specified registry. ::

aws schemas delete-resource-policy \
--registry-name example-registry

This command produces no output.

For more information, see `Amazon EventBridge schemas <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-schema.html>`__ in the *Amazon EventBridge User Guide*.
12 changes: 12 additions & 0 deletions awscli/examples/schemas/delete-schema-version.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
**To delete the schema version definition**

The following ``delete-schema-version`` example deletes the schema version definition. ::

aws schemas delete-schema-version \
--registry-name example-registry \
--schema-name example-schema \
--schema-version 2

This command produces no output.

For more information, see `Amazon EventBridge schemas <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-schema.html>`__ in the *Amazon EventBridge User Guide*.
11 changes: 11 additions & 0 deletions awscli/examples/schemas/delete-schema.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
**To delete a schema definition**

The following ``delete-schema`` example deletes a schema definition. ::

aws schemas delete-schema \
--registry-name example-registry \
--schema-name example-schema

This command produces no output.

For more information, see `Amazon EventBridge schemas <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-schema.html>`__ in the *Amazon EventBridge User Guide*.
20 changes: 20 additions & 0 deletions awscli/examples/schemas/describe-code-binding.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
**To describe a code binding status for a particular language for an existing schema and version**

The following ``describe-code-binding`` example describes a code binding status for a particular language for an existing schema and version. You may specify the languages like Java8, TypeScript3, Python36, and Go1. ::

aws schemas describe-code-binding \
--registry-name example-registry \
--schema-name example-schema \
--schema-version 2 \
--language Python36

Output::

{
"CreationDate": "2024-04-12T13:14:40+00:00",
"LastModified": "2024-04-12T13:14:40+00:00",
"SchemaVersion": "2",
"Status": "CREATE_COMPLETE"
}

For more information, see `Amazon EventBridge schemas <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-schema.html>`__ in the *Amazon EventBridge User Guide*.
19 changes: 19 additions & 0 deletions awscli/examples/schemas/describe-discoverer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
**To describe the discoverer for a particular Event Bus**

The following ``describe-discoverer`` example describes the discoverer for a particular Event Bus. ::

aws schemas describe-discoverer \
--discoverer-id example-discoverer-name

Output::

{
"DiscovererArn": "arn:aws:schemas:us-east-1:012345678912:discoverer/examlpe-discoverer-name",
"DiscovererId": "example-discoverer-name",
"SourceArn": "arn:aws:events:us-east-1:012345678912:event-bus/example-event-bus",
"State": "STARTED",
"Cross012345678912": true,
"Tags": {}
}

For more information, see `Amazon EventBridge schemas <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-schema.html>`__ in the *Amazon EventBridge User Guide*.
16 changes: 16 additions & 0 deletions awscli/examples/schemas/describe-registry.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
**To describe a specific registry**

The following ``describe-registry`` example describes a specific registry. ::

aws schemas describe-registry \
--registry-name example-registry

Output::

{
"RegistryArn": "arn:aws:schemas:us-east-1:012345678912:registry/example-registry",
"RegistryName": "example-registry",
"Tags": {}
}

For more information, see `Amazon EventBridge schemas <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-schema.html>`__ in the *Amazon EventBridge User Guide*.
22 changes: 22 additions & 0 deletions awscli/examples/schemas/describe-schema.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
**To describe an existing schema definition in a registry**

The following ``describe-schema`` example describes an existing schema definition in a registry. The command describes the latest schema version by default. Optionally, you may describe a specific schema version by using the --schema-version flag. ::

aws schemas describe-schema \
--registry-name example-registry \
--schema-name example-schema

Output::

{
"Content": "{"Content":{"openapi":"3.0.0","info":{"version":"1.0.0","title":"Event"},"paths":{},"components":{"schemas":{"Event":{"type":"object","properties":{"ordinal":{"type":"number","format":"int64"},"name":{"type":"string"},"description":{"type":"string"},"price":{"type":"number","format":"double"},"address":{"type":"string"},"comments":{"type":"array","items":{"type":"string"}},"created_at":{"type":"string","format":"date-time"}}}}}},"LastModified":"2024-04-12T13:13:53+00:00","SchemaArn":"arn:aws:schemas:us-east-1:012345678912:schema/example-registry/example-schema","SchemaName":"example-schema","SchemaVersion":"3","Tags":{},"Type":"OpenApi3","VersionCreatedDate":"2024-04-12T13:13:53+00:00"}",
"LastModified": "2024-04-12T13:13:53+00:00",
"SchemaArn": "arn:aws:schemas:us-east-1:012345678912:schema/example-registry/example-schema",
"SchemaName": "example-schema",
"SchemaVersion": "3",
"Tags": {},
"Type": "OpenApi3",
"VersionCreatedDate": "2024-04-12T13:13:53+00:00"
}

For more information, see `Amazon EventBridge schemas <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-schema.html>`__ in the *Amazon EventBridge User Guide*.
19 changes: 19 additions & 0 deletions awscli/examples/schemas/export-schemas.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
**To export a schema to JSON format**

The following ``export-schemas`` example exports a schema to JSON format. The command exports the latest schema version by default. Optionally, you may describe a specific schema version by using the ``--schema-version`` flag. Note: You may only export a schema in JSONSchemaDraft4 format. ::

aws schemas export-schema \
--registry-name aws.events \
--schema-name aws.ec2@EC2InstanceStateChangeNotification \
--type JSONSchemaDraft4

Output::

{
"Content": "{\"$schema\":\"http://json-schema.org/draft-04/schema#\",\"title\":\"EC2InstanceStateChangeNotification\",\"definitions\":{\"EC2InstanceStateChangeNotification\":{\"properties\":{\"instance-id\":{\"type\":\"string\"},\"state\":{\"type\":\"string\"}},\"required\":[\"instance-id\",\"state\"],\"type\":\"object\"}},\"properties\":{\"account\":{\"type\":\"string\"},\"detail\":{\"$ref\":\"#/definitions/EC2InstanceStateChangeNotification\"},\"detail-type\":{\"type\":\"string\"},\"id\":{\"type\":\"string\"},\"region\":{\"type\":\"string\"},\"resources\":{\"items\":{\"type\":\"string\"},\"type\":\"array\"},\"source\":{\"type\":\"string\"},\"time\":{\"format\":\"date-time\",\"type\":\"string\"},\"version\":{\"type\":\"string\"}},\"required\":[\"detail-type\",\"resources\",\"id\",\"source\",\"time\",\"detail\",\"region\",\"version\",\"account\"],\"type\":\"object\",\"x-amazon-events-detail-type\":\"EC2 Instance State-change Notification\",\"x-amazon-events-source\":\"aws.ec2\"}",
"SchemaName": "aws.ec2@EC2InstanceStateChangeNotification",
"SchemaVersion": "1",
"Type": "JSONSchemaDraft4"
}

For more information, see `Amazon EventBridge schemas <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-schema.html>`__ in the *Amazon EventBridge User Guide*.
12 changes: 12 additions & 0 deletions awscli/examples/schemas/get-code-binding-source.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
**To retrieve the code binding source URI from an existing schema version for a particular language and exports the content to an outfile**

The following ``get-code-binding-source`` example retrieves the code binding source URI from an existing schema version for a particular language and exports the content to an outfile. You may specify languages such as Java8, TypeScript3, Python36, and Go1. If successful, your code binding source URI will be available in your local machine. ::

aws schemas get-code-binding-source \
--registry-name example-registry \
--schema-name example-schema \
--language Python36 <outfile>.zip

This command produces no output.

For more information, see `Amazon EventBridge schemas <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-schema.html>`__ in the *Amazon EventBridge User Guide*.
15 changes: 15 additions & 0 deletions awscli/examples/schemas/get-discovered-schema.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
**To retrieve the discovered schema that was created by the Schemas service based on a sample event.**

The following ``get-discovered-schema`` example retrieves the discovered schema that was created by the Schemas service based on a sample event. ::

aws schemas get-discovered-schema \
--events "{\"Source\":\"com.mycompany.myapp\",\"Detail\":\"{ \\\"key1\\\": \\\"value1\\\", \\\"key2\\\": \\\"value2\\\" }\",\"EventBusName\":\"default\",\"Resources\":[\"resource1\",\"resource2\"],\"DetailType\":\"myDetailType\"}" \
--type OpenApi3

Output ::

{
"Content": "{\"openapi\":\"3.0.0\",\"info\":{\"version\":\"1.0.0\",\"title\":\"Event\"},\"paths\":{},\"components\":{\"schemas\":{\"Event\":{\"type\":\"object\",\"required\":[\"EventBusName\",\"DetailType\",\"Resources\",\"Detail\",\"Source\"],\"properties\":{\"Detail\":{\"type\":\"string\"},\"DetailType\":{\"type\":\"string\"},\"EventBusName\":{\"type\":\"string\"},\"Resources\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}},\"Source\":{\"type\":\"string\"}}}}}}"
}

For more information, see `Amazon EventBridge schemas <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-schema.html>`__ in the *Amazon EventBridge User Guide*.
15 changes: 15 additions & 0 deletions awscli/examples/schemas/get-resource-policy.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
**To retrieve the resource-based policy associated with a particular registry**

The following ``get-resource-policy`` example retrieves the resource-based policy associated with a particular registry. The command will only return a resource-policy if one exists on the registry. ::

aws schemas get-resource-policy /
--registry-name example-registry

Output ::

{
"Policy": "{"Version":"2012-10-17","Statement":[{"Sid":"AllowReadWrite","Effect":"Allow","Principal":{"AWS":"*"},"Action":"schemas:*","Resource":["arn:aws:schemas:us-east-1:012345678912:registry/example-registry","arn:aws:schemas:us-east-1:012345678912:schema/example-registry*"]}]}",
"RevisionId": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"
}

For more information, see `Amazon EventBridge schemas <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-schema.html>`__ in the *Amazon EventBridge User Guide*.
22 changes: 22 additions & 0 deletions awscli/examples/schemas/list-discoverers.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
**To list all discovers across all Event Buses**

The following ``list-discoverers`` example lists all discovers across all Event Buses. ::

aws schemas list-discoverers

Output::

{
"Discoverers": [
{
"DiscovererArn": "arn:aws:schemas:us-east-1:012345678912:discoverer/example-discoverer-name",
"DiscovererId": "example-discoverer-name",
"SourceArn": "arn:aws:events:us-east-1:012345678912:event-bus/example-event-bus-name",
"State": "STARTED",
"Cross012345678912": true,
"Tags": {}
}
]
}

For more information, see `Amazon EventBridge schemas <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-schema.html>`__ in the *Amazon EventBridge User Guide*.
19 changes: 19 additions & 0 deletions awscli/examples/schemas/list-registries.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
**To list all the existing registries**

The following ``list-registries`` lists all the existing registries. You may use the ``--registry-name-prefix`` option to narrow down the results. The command will return all registries by default, but you may narrow the results using the ``--scope`` option to narrow down the results to custom or AWS managed registries. ::

aws schemas list-registries

Output::

{
"Registries": [
{
"RegistryArn": "arn:aws:schemas:us-east-1:012345678912:registry/example-registry-name",
"RegistryName": "example-registry-name",
"Tags": {}
}
]
}

For more information, see `Amazon EventBridge schemas <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-schema.html>`__ in the *Amazon EventBridge User Guide*.
28 changes: 28 additions & 0 deletions awscli/examples/schemas/list-schema-versions.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
**To list all the existing versions available in a schema**

The following ``list-schema-versions`` example lists all the existing versions available in a schema. ::

aws schemas list-schema-versions \
--registry-name example-registry \
--schema-name example-schema

Output::

{
"SchemaVersions": [
{
"SchemaArn": "arn:aws:schemas:us-east-1:012345678912:schema/example-registry/example-schema",
"SchemaName": "example-schema",
"SchemaVersion": "2",
"Type": "OpenApi3"
},
{
"SchemaArn": "arn:aws:schemas:us-east-1:012345678912:schema/example-registry/example-schema",
"SchemaName": "example-schema",
"SchemaVersion": "1",
"Type": "OpenApi3"
}
]
}

For more information, see `Amazon EventBridge schemas <https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-schema.html>`__ in the *Amazon EventBridge User Guide*.
Loading