Skip to content

Commit 1753a2c

Browse files
committed
validate capability names and incorporate them into schemas
also added a minio example and updated example schemas Signed-off-by: Lance Drane <[email protected]>
1 parent 2884001 commit 1753a2c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2094
-1619
lines changed

examples/1_hello_world/hello_client.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,6 @@ def simple_client_callback(
4343
In most cases, everything under from_config_file should come from a configuration file, command line arguments, or environment variables.
4444
"""
4545
from_config_file = {
46-
'data_stores': {
47-
'minio': [
48-
{
49-
'username': 'AKIAIOSFODNN7EXAMPLE',
50-
'password': 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
51-
'port': 9000,
52-
},
53-
],
54-
},
5546
'brokers': [
5647
{
5748
'username': 'intersect_username',

examples/1_hello_world/hello_service.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class HelloServiceCapabilityImplementation(IntersectBaseCapabilityImplementation
2525
and will send a string back in its own payload.
2626
"""
2727

28+
intersect_sdk_capability_name = 'HelloExample'
29+
2830
@intersect_status()
2931
def status(self) -> str:
3032
"""Basic status function which returns a hard-coded string."""
@@ -43,15 +45,6 @@ def say_hello_to_name(self, name: str) -> str:
4345
In most cases, everything under from_config_file should come from a configuration file, command line arguments, or environment variables.
4446
"""
4547
from_config_file = {
46-
'data_stores': {
47-
'minio': [
48-
{
49-
'username': 'AKIAIOSFODNN7EXAMPLE',
50-
'password': 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
51-
'port': 9000,
52-
},
53-
],
54-
},
5548
'brokers': [
5649
{
5750
'username': 'intersect_username',
@@ -79,7 +72,6 @@ def say_hello_to_name(self, name: str) -> str:
7972
@intersect_message and @intersect_status, and that these functions are appropriately type-annotated.
8073
"""
8174
capability = HelloServiceCapabilityImplementation()
82-
capability.capability_name = 'HelloExample'
8375

8476
"""
8577
step three - create service from both the configuration and your own capability

examples/1_hello_world/hello_service_schema.json

Lines changed: 40 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,50 @@
33
"x-intersect-version": "0.7.0",
44
"info": {
55
"title": "hello-organization.hello-facility.hello-system.hello-subsystem.hello-service",
6-
"version": "0.0.0",
7-
"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."
6+
"description": "INTERSECT schema",
7+
"version": "0.0.0"
88
},
99
"defaultContentType": "application/json",
10-
"channels": {
11-
"say_hello_to_name": {
12-
"publish": {
13-
"message": {
14-
"schemaFormat": "application/vnd.aai.asyncapi+json;version=2.6.0",
15-
"contentType": "application/json",
16-
"traits": {
17-
"$ref": "#/components/messageTraits/commonHeaders"
10+
"capabilities": {
11+
"HelloExample": {
12+
"channels": {
13+
"say_hello_to_name": {
14+
"publish": {
15+
"message": {
16+
"schemaFormat": "application/vnd.aai.asyncapi+json;version=2.6.0",
17+
"contentType": "application/json",
18+
"traits": {
19+
"$ref": "#/components/messageTraits/commonHeaders"
20+
},
21+
"payload": {
22+
"type": "string"
23+
}
24+
},
25+
"description": "Takes in a string parameter and says 'Hello' to the parameter!"
1826
},
19-
"payload": {
20-
"type": "string"
21-
}
22-
},
23-
"description": "Takes in a string parameter and says 'Hello' to the parameter!"
24-
},
25-
"subscribe": {
26-
"message": {
27-
"schemaFormat": "application/vnd.aai.asyncapi+json;version=2.6.0",
28-
"contentType": "application/json",
29-
"traits": {
30-
"$ref": "#/components/messageTraits/commonHeaders"
27+
"subscribe": {
28+
"message": {
29+
"schemaFormat": "application/vnd.aai.asyncapi+json;version=2.6.0",
30+
"contentType": "application/json",
31+
"traits": {
32+
"$ref": "#/components/messageTraits/commonHeaders"
33+
},
34+
"payload": {
35+
"type": "string"
36+
}
37+
},
38+
"description": "Takes in a string parameter and says 'Hello' to the parameter!"
3139
},
32-
"payload": {
33-
"type": "string"
34-
}
35-
},
36-
"description": "Takes in a string parameter and says 'Hello' to the parameter!"
40+
"events": []
41+
}
3742
},
38-
"events": []
43+
"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."
3944
}
4045
},
4146
"events": {},
47+
"status": {
48+
"type": "string"
49+
},
4250
"components": {
4351
"schemas": {},
4452
"messageTraits": {
@@ -47,10 +55,7 @@
4755
"$defs": {
4856
"IntersectDataHandler": {
4957
"description": "What data transfer type do you want to use for handling the request/response?\n\nDefault: MESSAGE",
50-
"enum": [
51-
0,
52-
1
53-
],
58+
"enum": [0, 1],
5459
"title": "IntersectDataHandler",
5560
"type": "integer"
5661
}
@@ -97,23 +102,15 @@
97102
"type": "boolean"
98103
}
99104
},
100-
"required": [
101-
"source",
102-
"destination",
103-
"created_at",
104-
"sdk_version"
105-
],
105+
"required": ["source", "destination", "created_at", "sdk_version"],
106106
"title": "UserspaceMessageHeader",
107107
"type": "object"
108108
},
109109
"eventHeaders": {
110110
"$defs": {
111111
"IntersectDataHandler": {
112112
"description": "What data transfer type do you want to use for handling the request/response?\n\nDefault: MESSAGE",
113-
"enum": [
114-
0,
115-
1
116-
],
113+
"enum": [0, 1],
117114
"title": "IntersectDataHandler",
118115
"type": "integer"
119116
}
@@ -152,19 +149,11 @@
152149
"type": "string"
153150
}
154151
},
155-
"required": [
156-
"source",
157-
"created_at",
158-
"sdk_version",
159-
"event_name"
160-
],
152+
"required": ["source", "created_at", "sdk_version", "event_name"],
161153
"title": "EventMessageHeaders",
162154
"type": "object"
163155
}
164156
}
165157
}
166-
},
167-
"status": {
168-
"type": "string"
169158
}
170159
}

examples/1_hello_world_amqp/hello_client.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,6 @@ def simple_client_callback(
4444
In most cases, everything under from_config_file should come from a configuration file, command line arguments, or environment variables.
4545
"""
4646
from_config_file = {
47-
'data_stores': {
48-
'minio': [
49-
{
50-
'username': 'AKIAIOSFODNN7EXAMPLE',
51-
'password': 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
52-
'port': 9000,
53-
},
54-
],
55-
},
5647
'brokers': [
5748
{
5849
'username': 'intersect_username',

examples/1_hello_world_amqp/hello_service.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class HelloServiceCapabilityImplementation(IntersectBaseCapabilityImplementation
2626
and will send a string back in its own payload.
2727
"""
2828

29+
intersect_sdk_capability_name = 'HelloExample'
30+
2931
@intersect_status()
3032
def status(self) -> str:
3133
"""Basic status function which returns a hard-coded string."""
@@ -44,15 +46,6 @@ def say_hello_to_name(self, name: str) -> str:
4446
In most cases, everything under from_config_file should come from a configuration file, command line arguments, or environment variables.
4547
"""
4648
from_config_file = {
47-
'data_stores': {
48-
'minio': [
49-
{
50-
'username': 'AKIAIOSFODNN7EXAMPLE',
51-
'password': 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
52-
'port': 9000,
53-
},
54-
],
55-
},
5649
'brokers': [
5750
{
5851
'username': 'intersect_username',
@@ -80,7 +73,6 @@ def say_hello_to_name(self, name: str) -> str:
8073
@intersect_message and @intersect_status, and that these functions are appropriately type-annotated.
8174
"""
8275
capability = HelloServiceCapabilityImplementation()
83-
capability.capability_name = 'HelloExample'
8476

8577
"""
8678
step three - create service from both the configuration and your own capability

examples/1_hello_world_amqp/hello_service_schema.json

Lines changed: 40 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,50 @@
33
"x-intersect-version": "0.7.0",
44
"info": {
55
"title": "hello-organization.hello-facility.hello-system.hello-subsystem.hello-service",
6-
"version": "0.0.0",
7-
"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."
6+
"description": "INTERSECT schema",
7+
"version": "0.0.0"
88
},
99
"defaultContentType": "application/json",
10-
"channels": {
11-
"say_hello_to_name": {
12-
"publish": {
13-
"message": {
14-
"schemaFormat": "application/vnd.aai.asyncapi+json;version=2.6.0",
15-
"contentType": "application/json",
16-
"traits": {
17-
"$ref": "#/components/messageTraits/commonHeaders"
10+
"capabilities": {
11+
"HelloExample": {
12+
"channels": {
13+
"say_hello_to_name": {
14+
"publish": {
15+
"message": {
16+
"schemaFormat": "application/vnd.aai.asyncapi+json;version=2.6.0",
17+
"contentType": "application/json",
18+
"traits": {
19+
"$ref": "#/components/messageTraits/commonHeaders"
20+
},
21+
"payload": {
22+
"type": "string"
23+
}
24+
},
25+
"description": "Takes in a string parameter and says 'Hello' to the parameter!"
1826
},
19-
"payload": {
20-
"type": "string"
21-
}
22-
},
23-
"description": "Takes in a string parameter and says 'Hello' to the parameter!"
24-
},
25-
"subscribe": {
26-
"message": {
27-
"schemaFormat": "application/vnd.aai.asyncapi+json;version=2.6.0",
28-
"contentType": "application/json",
29-
"traits": {
30-
"$ref": "#/components/messageTraits/commonHeaders"
27+
"subscribe": {
28+
"message": {
29+
"schemaFormat": "application/vnd.aai.asyncapi+json;version=2.6.0",
30+
"contentType": "application/json",
31+
"traits": {
32+
"$ref": "#/components/messageTraits/commonHeaders"
33+
},
34+
"payload": {
35+
"type": "string"
36+
}
37+
},
38+
"description": "Takes in a string parameter and says 'Hello' to the parameter!"
3139
},
32-
"payload": {
33-
"type": "string"
34-
}
35-
},
36-
"description": "Takes in a string parameter and says 'Hello' to the parameter!"
40+
"events": []
41+
}
3742
},
38-
"events": []
43+
"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."
3944
}
4045
},
4146
"events": {},
47+
"status": {
48+
"type": "string"
49+
},
4250
"components": {
4351
"schemas": {},
4452
"messageTraits": {
@@ -47,10 +55,7 @@
4755
"$defs": {
4856
"IntersectDataHandler": {
4957
"description": "What data transfer type do you want to use for handling the request/response?\n\nDefault: MESSAGE",
50-
"enum": [
51-
0,
52-
1
53-
],
58+
"enum": [0, 1],
5459
"title": "IntersectDataHandler",
5560
"type": "integer"
5661
}
@@ -97,23 +102,15 @@
97102
"type": "boolean"
98103
}
99104
},
100-
"required": [
101-
"source",
102-
"destination",
103-
"created_at",
104-
"sdk_version"
105-
],
105+
"required": ["source", "destination", "created_at", "sdk_version"],
106106
"title": "UserspaceMessageHeader",
107107
"type": "object"
108108
},
109109
"eventHeaders": {
110110
"$defs": {
111111
"IntersectDataHandler": {
112112
"description": "What data transfer type do you want to use for handling the request/response?\n\nDefault: MESSAGE",
113-
"enum": [
114-
0,
115-
1
116-
],
113+
"enum": [0, 1],
117114
"title": "IntersectDataHandler",
118115
"type": "integer"
119116
}
@@ -152,19 +149,11 @@
152149
"type": "string"
153150
}
154151
},
155-
"required": [
156-
"source",
157-
"created_at",
158-
"sdk_version",
159-
"event_name"
160-
],
152+
"required": ["source", "created_at", "sdk_version", "event_name"],
161153
"title": "EventMessageHeaders",
162154
"type": "object"
163155
}
164156
}
165157
}
166-
},
167-
"status": {
168-
"type": "string"
169158
}
170159
}

examples/1_hello_world_events/hello_client.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,6 @@ def simple_event_callback(
6464
In most cases, everything under from_config_file should come from a configuration file, command line arguments, or environment variables.
6565
"""
6666
from_config_file = {
67-
'data_stores': {
68-
'minio': [
69-
{
70-
'username': 'AKIAIOSFODNN7EXAMPLE',
71-
'password': 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
72-
'port': 9000,
73-
},
74-
],
75-
},
7667
'brokers': [
7768
{
7869
'username': 'intersect_username',

0 commit comments

Comments
 (0)