Skip to content

Commit

Permalink
validate capability names and incorporate them into schemas
Browse files Browse the repository at this point in the history
also added a minio example and updated example schemas

Signed-off-by: Lance Drane <[email protected]>
  • Loading branch information
Lance-Drane committed Sep 11, 2024
1 parent 2884001 commit 1753a2c
Show file tree
Hide file tree
Showing 51 changed files with 2,094 additions and 1,619 deletions.
9 changes: 0 additions & 9 deletions examples/1_hello_world/hello_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@ def simple_client_callback(
In most cases, everything under from_config_file should come from a configuration file, command line arguments, or environment variables.
"""
from_config_file = {
'data_stores': {
'minio': [
{
'username': 'AKIAIOSFODNN7EXAMPLE',
'password': 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
'port': 9000,
},
],
},
'brokers': [
{
'username': 'intersect_username',
Expand Down
12 changes: 2 additions & 10 deletions examples/1_hello_world/hello_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class HelloServiceCapabilityImplementation(IntersectBaseCapabilityImplementation
and will send a string back in its own payload.
"""

intersect_sdk_capability_name = 'HelloExample'

@intersect_status()
def status(self) -> str:
"""Basic status function which returns a hard-coded string."""
Expand All @@ -43,15 +45,6 @@ def say_hello_to_name(self, name: str) -> str:
In most cases, everything under from_config_file should come from a configuration file, command line arguments, or environment variables.
"""
from_config_file = {
'data_stores': {
'minio': [
{
'username': 'AKIAIOSFODNN7EXAMPLE',
'password': 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
'port': 9000,
},
],
},
'brokers': [
{
'username': 'intersect_username',
Expand Down Expand Up @@ -79,7 +72,6 @@ def say_hello_to_name(self, name: str) -> str:
@intersect_message and @intersect_status, and that these functions are appropriately type-annotated.
"""
capability = HelloServiceCapabilityImplementation()
capability.capability_name = 'HelloExample'

"""
step three - create service from both the configuration and your own capability
Expand Down
91 changes: 40 additions & 51 deletions examples/1_hello_world/hello_service_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,50 @@
"x-intersect-version": "0.7.0",
"info": {
"title": "hello-organization.hello-facility.hello-system.hello-subsystem.hello-service",
"version": "0.0.0",
"description": "Rudimentary capability implementation example.\n\nAll capability implementations are required to have an @intersect_status decorated function,\nbut we do not use it here.\n\nThe operation we are calling is `say_hello_to_name` , so the message being sent will need to have\nan operationId of `say_hello_to_name`. The operation expects a string sent to it in the payload,\nand will send a string back in its own payload."
"description": "INTERSECT schema",
"version": "0.0.0"
},
"defaultContentType": "application/json",
"channels": {
"say_hello_to_name": {
"publish": {
"message": {
"schemaFormat": "application/vnd.aai.asyncapi+json;version=2.6.0",
"contentType": "application/json",
"traits": {
"$ref": "#/components/messageTraits/commonHeaders"
"capabilities": {
"HelloExample": {
"channels": {
"say_hello_to_name": {
"publish": {
"message": {
"schemaFormat": "application/vnd.aai.asyncapi+json;version=2.6.0",
"contentType": "application/json",
"traits": {
"$ref": "#/components/messageTraits/commonHeaders"
},
"payload": {
"type": "string"
}
},
"description": "Takes in a string parameter and says 'Hello' to the parameter!"
},
"payload": {
"type": "string"
}
},
"description": "Takes in a string parameter and says 'Hello' to the parameter!"
},
"subscribe": {
"message": {
"schemaFormat": "application/vnd.aai.asyncapi+json;version=2.6.0",
"contentType": "application/json",
"traits": {
"$ref": "#/components/messageTraits/commonHeaders"
"subscribe": {
"message": {
"schemaFormat": "application/vnd.aai.asyncapi+json;version=2.6.0",
"contentType": "application/json",
"traits": {
"$ref": "#/components/messageTraits/commonHeaders"
},
"payload": {
"type": "string"
}
},
"description": "Takes in a string parameter and says 'Hello' to the parameter!"
},
"payload": {
"type": "string"
}
},
"description": "Takes in a string parameter and says 'Hello' to the parameter!"
"events": []
}
},
"events": []
"description": "Rudimentary capability implementation example.\n\nAll capability implementations are required to have an @intersect_status decorated function,\nbut we do not use it here.\n\nThe operation we are calling is `say_hello_to_name` , so the message being sent will need to have\nan operationId of `say_hello_to_name`. The operation expects a string sent to it in the payload,\nand will send a string back in its own payload."
}
},
"events": {},
"status": {
"type": "string"
},
"components": {
"schemas": {},
"messageTraits": {
Expand All @@ -47,10 +55,7 @@
"$defs": {
"IntersectDataHandler": {
"description": "What data transfer type do you want to use for handling the request/response?\n\nDefault: MESSAGE",
"enum": [
0,
1
],
"enum": [0, 1],
"title": "IntersectDataHandler",
"type": "integer"
}
Expand Down Expand Up @@ -97,23 +102,15 @@
"type": "boolean"
}
},
"required": [
"source",
"destination",
"created_at",
"sdk_version"
],
"required": ["source", "destination", "created_at", "sdk_version"],
"title": "UserspaceMessageHeader",
"type": "object"
},
"eventHeaders": {
"$defs": {
"IntersectDataHandler": {
"description": "What data transfer type do you want to use for handling the request/response?\n\nDefault: MESSAGE",
"enum": [
0,
1
],
"enum": [0, 1],
"title": "IntersectDataHandler",
"type": "integer"
}
Expand Down Expand Up @@ -152,19 +149,11 @@
"type": "string"
}
},
"required": [
"source",
"created_at",
"sdk_version",
"event_name"
],
"required": ["source", "created_at", "sdk_version", "event_name"],
"title": "EventMessageHeaders",
"type": "object"
}
}
}
},
"status": {
"type": "string"
}
}
9 changes: 0 additions & 9 deletions examples/1_hello_world_amqp/hello_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ def simple_client_callback(
In most cases, everything under from_config_file should come from a configuration file, command line arguments, or environment variables.
"""
from_config_file = {
'data_stores': {
'minio': [
{
'username': 'AKIAIOSFODNN7EXAMPLE',
'password': 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
'port': 9000,
},
],
},
'brokers': [
{
'username': 'intersect_username',
Expand Down
12 changes: 2 additions & 10 deletions examples/1_hello_world_amqp/hello_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class HelloServiceCapabilityImplementation(IntersectBaseCapabilityImplementation
and will send a string back in its own payload.
"""

intersect_sdk_capability_name = 'HelloExample'

@intersect_status()
def status(self) -> str:
"""Basic status function which returns a hard-coded string."""
Expand All @@ -44,15 +46,6 @@ def say_hello_to_name(self, name: str) -> str:
In most cases, everything under from_config_file should come from a configuration file, command line arguments, or environment variables.
"""
from_config_file = {
'data_stores': {
'minio': [
{
'username': 'AKIAIOSFODNN7EXAMPLE',
'password': 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
'port': 9000,
},
],
},
'brokers': [
{
'username': 'intersect_username',
Expand Down Expand Up @@ -80,7 +73,6 @@ def say_hello_to_name(self, name: str) -> str:
@intersect_message and @intersect_status, and that these functions are appropriately type-annotated.
"""
capability = HelloServiceCapabilityImplementation()
capability.capability_name = 'HelloExample'

"""
step three - create service from both the configuration and your own capability
Expand Down
91 changes: 40 additions & 51 deletions examples/1_hello_world_amqp/hello_service_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,50 @@
"x-intersect-version": "0.7.0",
"info": {
"title": "hello-organization.hello-facility.hello-system.hello-subsystem.hello-service",
"version": "0.0.0",
"description": "Rudimentary capability implementation example.\n\nAll capability implementations are required to have an @intersect_status decorated function,\nbut we do not use it here.\n\nThe operation we are calling is `say_hello_to_name` , so the message being sent will need to have\nan operationId of `say_hello_to_name`. The operation expects a string sent to it in the payload,\nand will send a string back in its own payload."
"description": "INTERSECT schema",
"version": "0.0.0"
},
"defaultContentType": "application/json",
"channels": {
"say_hello_to_name": {
"publish": {
"message": {
"schemaFormat": "application/vnd.aai.asyncapi+json;version=2.6.0",
"contentType": "application/json",
"traits": {
"$ref": "#/components/messageTraits/commonHeaders"
"capabilities": {
"HelloExample": {
"channels": {
"say_hello_to_name": {
"publish": {
"message": {
"schemaFormat": "application/vnd.aai.asyncapi+json;version=2.6.0",
"contentType": "application/json",
"traits": {
"$ref": "#/components/messageTraits/commonHeaders"
},
"payload": {
"type": "string"
}
},
"description": "Takes in a string parameter and says 'Hello' to the parameter!"
},
"payload": {
"type": "string"
}
},
"description": "Takes in a string parameter and says 'Hello' to the parameter!"
},
"subscribe": {
"message": {
"schemaFormat": "application/vnd.aai.asyncapi+json;version=2.6.0",
"contentType": "application/json",
"traits": {
"$ref": "#/components/messageTraits/commonHeaders"
"subscribe": {
"message": {
"schemaFormat": "application/vnd.aai.asyncapi+json;version=2.6.0",
"contentType": "application/json",
"traits": {
"$ref": "#/components/messageTraits/commonHeaders"
},
"payload": {
"type": "string"
}
},
"description": "Takes in a string parameter and says 'Hello' to the parameter!"
},
"payload": {
"type": "string"
}
},
"description": "Takes in a string parameter and says 'Hello' to the parameter!"
"events": []
}
},
"events": []
"description": "Rudimentary capability implementation example.\n\nAll capability implementations are required to have an @intersect_status decorated function,\nbut we do not use it here.\n\nThe operation we are calling is `say_hello_to_name` , so the message being sent will need to have\nan operationId of `say_hello_to_name`. The operation expects a string sent to it in the payload,\nand will send a string back in its own payload."
}
},
"events": {},
"status": {
"type": "string"
},
"components": {
"schemas": {},
"messageTraits": {
Expand All @@ -47,10 +55,7 @@
"$defs": {
"IntersectDataHandler": {
"description": "What data transfer type do you want to use for handling the request/response?\n\nDefault: MESSAGE",
"enum": [
0,
1
],
"enum": [0, 1],
"title": "IntersectDataHandler",
"type": "integer"
}
Expand Down Expand Up @@ -97,23 +102,15 @@
"type": "boolean"
}
},
"required": [
"source",
"destination",
"created_at",
"sdk_version"
],
"required": ["source", "destination", "created_at", "sdk_version"],
"title": "UserspaceMessageHeader",
"type": "object"
},
"eventHeaders": {
"$defs": {
"IntersectDataHandler": {
"description": "What data transfer type do you want to use for handling the request/response?\n\nDefault: MESSAGE",
"enum": [
0,
1
],
"enum": [0, 1],
"title": "IntersectDataHandler",
"type": "integer"
}
Expand Down Expand Up @@ -152,19 +149,11 @@
"type": "string"
}
},
"required": [
"source",
"created_at",
"sdk_version",
"event_name"
],
"required": ["source", "created_at", "sdk_version", "event_name"],
"title": "EventMessageHeaders",
"type": "object"
}
}
}
},
"status": {
"type": "string"
}
}
9 changes: 0 additions & 9 deletions examples/1_hello_world_events/hello_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,6 @@ def simple_event_callback(
In most cases, everything under from_config_file should come from a configuration file, command line arguments, or environment variables.
"""
from_config_file = {
'data_stores': {
'minio': [
{
'username': 'AKIAIOSFODNN7EXAMPLE',
'password': 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
'port': 9000,
},
],
},
'brokers': [
{
'username': 'intersect_username',
Expand Down
Loading

0 comments on commit 1753a2c

Please sign in to comment.