Skip to content

Commit 679b954

Browse files
authored
Improve composition (#1383)
1 parent 5d17df8 commit 679b954

Some content is hidden

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

49 files changed

+3627
-307
lines changed

packages/openapi-typescript/examples/digital-ocean-api.ts

+613-28
Large diffs are not rendered by default.

packages/openapi-typescript/examples/digital-ocean-api/DigitalOcean-public.v2.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,20 @@ paths:
862862
put:
863863
$ref: 'resources/databases/databases_upgrade_major_version.yml'
864864

865+
/v2/databases/{database_cluster_uuid}/topics:
866+
get:
867+
$ref: 'resources/databases/databases_list_kafka_topics.yml'
868+
post:
869+
$ref: 'resources/databases/databases_create_kafka_topic.yml'
870+
871+
/v2/databases/{database_cluster_uuid}/topics/{topic_name}:
872+
get:
873+
$ref: 'resources/databases/databases_get_kafka_topic.yml'
874+
put:
875+
$ref: 'resources/databases/databases_update_kafka_topic.yml'
876+
delete:
877+
$ref: 'resources/databases/databases_delete_kafka_topic.yml'
878+
865879
/v2/domains:
866880
get:
867881
$ref: 'resources/domains/domains_list.yml'

packages/openapi-typescript/examples/digital-ocean-api/resources/databases/databases_add_user.yml

+18
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ description: |
1111
When adding a user to a MySQL cluster, additional options can be configured in the
1212
`mysql_settings` object.
1313
14+
When adding a user to a Kafka cluster, additional options can be configured in
15+
the `settings` object.
16+
1417
The response will be a JSON object with a key called `user`. The value of this will be an
1518
object that contains the standard attributes associated with a database user including
1619
its randomly generated password.
@@ -52,6 +55,21 @@ requestBody:
5255
name: my-readonly
5356
readonly: true
5457

58+
Add New User with Kafka ACLs:
59+
value:
60+
name: app-03
61+
settings:
62+
acl:
63+
- id: acl128aaaa99239
64+
permission: produceconsume
65+
topic: customer-events
66+
- id: acl293098flskdf
67+
permission: produce
68+
topic: customer-events.*
69+
- id: acl128ajei20123
70+
permission: consume
71+
topic: customer-events
72+
5573
responses:
5674
'201':
5775
$ref: 'responses/user.yml'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
operationId: databases_create_kafka_topic
2+
3+
summary: Create Topic for a Kafka Cluster
4+
5+
description: |
6+
To create a topic attached to a Kafka cluster, send a POST request to
7+
`/v2/databases/$DATABASE_ID/topics`.
8+
9+
The result will be a JSON object with a `topic` key.
10+
11+
tags:
12+
- Databases
13+
14+
parameters:
15+
- $ref: 'parameters.yml#/database_cluster_uuid'
16+
17+
requestBody:
18+
content:
19+
application/json:
20+
schema:
21+
allOf:
22+
- $ref: 'models/kafka_topic_create.yml'
23+
required:
24+
- name
25+
example:
26+
name: customer-events
27+
partitions: 3
28+
replication: 2
29+
config:
30+
retention_bytes: -1
31+
retention_ms: 100000
32+
33+
responses:
34+
'201':
35+
$ref: 'responses/kafka_topic.yml'
36+
37+
'401':
38+
$ref: '../../shared/responses/unauthorized.yml'
39+
40+
'404':
41+
$ref: '../../shared/responses/not_found.yml'
42+
43+
'429':
44+
$ref: '../../shared/responses/too_many_requests.yml'
45+
46+
'500':
47+
$ref: '../../shared/responses/server_error.yml'
48+
49+
default:
50+
$ref: '../../shared/responses/unexpected_error.yml'
51+
52+
x-codeSamples:
53+
- $ref: 'examples/curl/databases_create_topic.yml'
54+
55+
security:
56+
- bearer_auth:
57+
- 'write'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
operationId: databases_delete_kafka_topic
2+
3+
summary: Delete Topic for a Kafka Cluster
4+
5+
description: |
6+
To delete a single topic within a Kafka cluster, send a DELETE request
7+
to `/v2/databases/$DATABASE_ID/topics/$TOPIC_NAME`.
8+
9+
A status of 204 will be given. This indicates that the request was
10+
processed successfully, but that no response body is needed.
11+
12+
tags:
13+
- Databases
14+
15+
parameters:
16+
- $ref: 'parameters.yml#/database_cluster_uuid'
17+
- $ref: 'parameters.yml#/kafka_topic_name'
18+
19+
responses:
20+
'204':
21+
$ref: '../../shared/responses/no_content.yml'
22+
23+
'401':
24+
$ref: '../../shared/responses/unauthorized.yml'
25+
26+
'404':
27+
$ref: '../../shared/responses/not_found.yml'
28+
29+
'429':
30+
$ref: '../../shared/responses/too_many_requests.yml'
31+
32+
'500':
33+
$ref: '../../shared/responses/server_error.yml'
34+
35+
default:
36+
$ref: '../../shared/responses/unexpected_error.yml'
37+
38+
x-codeSamples:
39+
- $ref: 'examples/curl/databases_delete_topic.yml'
40+
41+
security:
42+
- bearer_auth:
43+
- 'write'
44+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
operationId: databases_get_kafka_topic
2+
3+
summary: Get Topic for a Kafka Cluster
4+
5+
description: |
6+
To retrieve a given topic by name from the set of a Kafka cluster's topics,
7+
send a GET request to `/v2/databases/$DATABASE_ID/topics/$TOPIC_NAME`.
8+
9+
The result will be a JSON object with a `topic` key.
10+
11+
tags:
12+
- Databases
13+
14+
parameters:
15+
- $ref: 'parameters.yml#/database_cluster_uuid'
16+
- $ref: 'parameters.yml#/kafka_topic_name'
17+
18+
responses:
19+
'200':
20+
$ref: 'responses/kafka_topic.yml'
21+
22+
'401':
23+
$ref: '../../shared/responses/unauthorized.yml'
24+
25+
'404':
26+
$ref: '../../shared/responses/not_found.yml'
27+
28+
'429':
29+
$ref: '../../shared/responses/too_many_requests.yml'
30+
31+
'500':
32+
$ref: '../../shared/responses/server_error.yml'
33+
34+
default:
35+
$ref: '../../shared/responses/unexpected_error.yml'
36+
37+
x-codeSamples:
38+
- $ref: 'examples/curl/databases_get_topic.yml'
39+
40+
security:
41+
- bearer_auth:
42+
- 'read'
43+

packages/openapi-typescript/examples/digital-ocean-api/resources/databases/databases_get_user.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ description: |
1111
The response will be a JSON object with a `user` key. This will be set to an object
1212
containing the standard database user attributes.
1313
14-
For MySQL clusters, additional options will be contained in the mysql_settings
14+
For MySQL clusters, additional options will be contained in the `mysql_settings`
1515
object.
1616
17+
For Kafka clusters, additional options will be contained in the `settings` object.
18+
1719
tags:
1820
- Databases
1921

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
operationId: databases_list_kafka_topics
2+
3+
summary: List Topics for a Kafka Cluster
4+
5+
description: |
6+
To list all of a Kafka cluster's topics, send a GET request to
7+
`/v2/databases/$DATABASE_ID/topics`.
8+
9+
The result will be a JSON object with a `topics` key.
10+
11+
tags:
12+
- Databases
13+
14+
parameters:
15+
- $ref: 'parameters.yml#/database_cluster_uuid'
16+
17+
responses:
18+
'200':
19+
$ref: 'responses/kafka_topics.yml'
20+
21+
'401':
22+
$ref: '../../shared/responses/unauthorized.yml'
23+
24+
'404':
25+
$ref: '../../shared/responses/not_found.yml'
26+
27+
'429':
28+
$ref: '../../shared/responses/too_many_requests.yml'
29+
30+
'500':
31+
$ref: '../../shared/responses/server_error.yml'
32+
33+
default:
34+
$ref: '../../shared/responses/unexpected_error.yml'
35+
36+
x-codeSamples:
37+
- $ref: 'examples/curl/databases_list_topics.yml'
38+
39+
security:
40+
- bearer_auth:
41+
- 'read'
42+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
operationId: databases_update_kafka_topic
2+
3+
summary: Update Topic for a Kafka Cluster
4+
5+
description: |
6+
To update a topic attached to a Kafka cluster, send a PUT request to
7+
`/v2/databases/$DATABASE_ID/topics/$TOPIC_NAME`.
8+
9+
The result will be a JSON object with a `topic` key.
10+
11+
tags:
12+
- Databases
13+
14+
parameters:
15+
- $ref: 'parameters.yml#/database_cluster_uuid'
16+
- $ref: 'parameters.yml#/kafka_topic_name'
17+
18+
requestBody:
19+
content:
20+
application/json:
21+
schema:
22+
allOf:
23+
- $ref: 'models/kafka_topic_update.yml'
24+
required:
25+
- topic
26+
example:
27+
topic:
28+
name: customer-events
29+
partitions: 3
30+
replication: 2
31+
config:
32+
retention_bytes: -1
33+
retention_ms: 100000
34+
35+
responses:
36+
'200':
37+
$ref: 'responses/kafka_topic.yml'
38+
39+
'401':
40+
$ref: '../../shared/responses/unauthorized.yml'
41+
42+
'404':
43+
$ref: '../../shared/responses/not_found.yml'
44+
45+
'429':
46+
$ref: '../../shared/responses/too_many_requests.yml'
47+
48+
'500':
49+
$ref: '../../shared/responses/server_error.yml'
50+
51+
default:
52+
$ref: '../../shared/responses/unexpected_error.yml'
53+
54+
x-codeSamples:
55+
- $ref: 'examples/curl/databases_update_topic.yml'
56+
57+
security:
58+
- bearer_auth:
59+
- 'write'
60+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
lang: cURL
2+
source: |-
3+
curl -X POST \
4+
-H "Content-Type: application/json" \
5+
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
6+
-d '{"name":"customer-events", "partition_count":3, "replication_factor": 3, "config": {"retentionMS": 1000000}}' \
7+
"https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30/topics"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
lang: cURL
2+
source: |-
3+
curl -X DELETE \
4+
-H "Content-Type: application/json" \
5+
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
6+
"https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30/topics/customer-events"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
lang: cURL
2+
source: |-
3+
curl -X GET \
4+
-H "Content-Type: application/json" \
5+
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
6+
"https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30/topics/customer-events"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
lang: cURL
2+
source: |-
3+
curl -X GET \
4+
-H "Content-Type: application/json" \
5+
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
6+
"https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30/topics"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
lang: cURL
2+
source: |-
3+
curl -X PUT \
4+
-H "Content-Type: application/json" \
5+
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
6+
-d '{"topic":{"name":"customer-events", "partition_count":3, "replication_factor": 3, "config": {"retentionMS": 1000000}}}' \
7+
"https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30/topics/customer-events"

packages/openapi-typescript/examples/digital-ocean-api/resources/databases/models/database_cluster.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ properties:
1919
- mysql
2020
- redis
2121
- mongodb
22+
- kafka
2223
description: >-
2324
A slug representing the database engine used for the cluster. The possible values
24-
are: "pg" for PostgreSQL, "mysql" for MySQL, "redis" for Redis, and "mongodb" for MongoDB.
25+
are: "pg" for PostgreSQL, "mysql" for MySQL, "redis" for Redis, "mongodb" for MongoDB,
26+
and "kafka" for Kafka.
2527
version:
2628
type: string
2729
example: '8'

packages/openapi-typescript/examples/digital-ocean-api/resources/databases/models/database_user.yml

+15
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,23 @@ properties:
2323
description: A randomly generated password for the database user.
2424
readOnly: true
2525

26+
access_cert:
27+
type: string
28+
example: "-----BEGIN CERTIFICATE-----\nMIIFFjCCA/6gAwIBAgISA0AznUJmXhu08/89ZuSPC/kRMA0GCSqGSIb3DQEBCwUA\nMEoxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1MZXQncyBFbmNyeXB0MSMwIQYDVQQD\nExpMZXQncyBFbmNyeXB0IEF1dGhvcml0eSBYMzAeFw0xNjExMjQwMDIzMDBaFw0x\nNzAyMjIwMDIzMDBaMCQxIjAgBgNVBAMTGWNsb3VkLmFuZHJld3NvbWV0aGluZy5j\nb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDBIZMz8pnK6V52SVf+\nCYssOfCQHAx5f0Ou5rYbq3xNh8VWHIYJCQ1QxQIxKSP6+uODSYrb2KWyurP1DwGb\n8OYm0J3syEDtCUQik1cpCzpeNlAZ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9FJpfScYG1JzVuCj/SoaPaK34G4x/e\niXwlwOXtMOtqjQYzNu2Pr2C+I+rVmaxIrCUXFmC205IMuUBEeWXG9Y/HvXQLPabD\nD3Gdl5+Feink9SDRP7G0HaAwq13hI7ARxkL9p+UIY39X0dV3WOboW2Re8nrkFXJ7\nq9Z6shK5QgpBfsLjtjNsQzaGV3ve1gOg25aTJGearBWOvEjJNA1wGMoKVXOtYwm/\nWyWoVdCQ8HmconcbJB6xc0UZ1EjvzRr5ZIvSa5uHZD0L3m7/kpPWlAlFJ7hHASPu\nUlF1zblDmg2Iaw==\n-----END CERTIFICATE-----"
29+
description: Access certificate for TLS client authentication. (Kafka only)
30+
readOnly: true
31+
32+
access_key:
33+
type: string
34+
example: "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDBIZMz8pnK6V52\nSVf+CYssOfCQHAx5f0Ou5rYbq3xNh8VHAIYJCQ1QxQIxKSP6+uODSYrb2KWyurP1\nDwGb8OYm0J3syEDtCUQik1cpCzpeNlAZ2f8FzXyYQAqPopxdRpsFz8DtZnVvu86X\nwrE4oFPl9MReICmZfBNWylpV5qgFPoXyJ70ZAsTm3cEe3n+LBXEnY4YrVDRWxA3w\nZ2mzZ03HZ1hHrxK9CMnS829U+8sK+UneZpCO7yLRPuxwhmps0wpK/YuZZfRAKF1F\nZRnak/SIQ28rnWufmdg16YqqHgl5JOgnb3aslKRvL4dI2Gwnkd2IHtpZnTR0gxFX\nfqqbQwuRAgMBAAECggEBAILLmkW0JzOkmLTDNzR0giyRkLoIROqDpfLtjKdwm95l\n9NUBJcU4vCvXQITKt/NhtnNTexcowg8pInb0ksJpg3UGE+4oMNBXVi2UW5MQZ5cm\ncVkQqgXkBF2YAY8FMaB6EML+0En2+dGR/3gIAr221xsFiXe1kHbB8Nb2c/d5HpFt\neRpLVJnK+TxSr78PcZA8DDGlSgwvgimdAaFUNO2OqB9/0E9UPyKk2ycdff/Z6ldF\n0hkCLtdYTTl8Kf/OwjcuTgmA2O3Y8/CoQX/L+oP9Rvt9pWCEfuebiOmHJVPO6Y6x\ngtQVEXwmF1pDHH4Qtz/e6UZTdYeMl9G4aNO2CawwcaYECgYEA57imgSOG4XsJLRh\nGGncV9R/xhy4AbDWLtAMzQRX4ktvKCaHWyQV2XK2we/cu29NLv2Y89WmerTNPOU+\nP8+pB31uty2ELySVn15QhKpQClVEAlxCnnNjXYrii5LOM80+lVmxvQwxVd8Yz8nj\nIntyioXNBEnYS7V2RxxFGgFun1cCgYEA1V3W+Uyamhq8JS5EY0FhyGcXdHd70K49\nW1ou7McIpncf9tM9acLS1hkI98rd2T69Zo8mKoV1V2hjFaKUYfNys6tTkYWeZCcJ\n3rW44j9DTD+FmmjcX6b8DzfybGLehfNbCw6n67/r45DXIV/fk6XZfkx6IEGO4ODt\nNfnvx4TuI1cCgYBACDiKqwSUvmkUuweOo4IuCxyb5Ee8v98P5JIE/VRDxlCbKbpx\npxEam6aBBQVcDi+n8o0H3WjjlKc6UqbW/01YMoMrvzotxNBLz8Y0QtQHZvR6KoCG\nRKCKstxTcWflzKuknbqN4RapAhNbKBDJ8PMSWfyDWNyaXzSmBdvaidbF1QKBgDI0\no4oD0Xkjg1QIYAUu9FBQmb9JAjRnW36saNBEQS/SZg4RRKknM683MtoDvVIKJk0E\nsAlfX+4SXQZRPDMUMtA+Jyrd0xhj6zmhbwClvDMr20crF3fWdgcqtft1BEFmsuyW\nJUMe5OWmRkjPI2+9ncDPRAllA7a8lnSV/Crph5N/AoGBAIK249temKrGe9pmsmAo\nQbNuYSmwpnMoAqdHTrl70HEmK7ob6SIVmsR8QFAkH7xkYZc4Bxbx4h1bdpozGB+/\nAangbiaYJcAOD1QyfiFbflvI1RFeHgrk7VIafeSeQv6qu0LLMi2zUbpgVzxt78Wg\neTuK2xNR0PIM8OI7pRpgyj1I\n-----END PRIVATE KEY-----"
35+
description: Access key for TLS client authentication. (Kafka only)
36+
readOnly: true
37+
2638
mysql_settings:
2739
$ref: './mysql_settings.yml'
2840

41+
settings:
42+
$ref: './user_settings.yml'
43+
2944
required:
3045
- name

0 commit comments

Comments
 (0)