From 5daa5ea73108fe6c22a77ac607a225e50c84a43c Mon Sep 17 00:00:00 2001 From: Stephen Varela Date: Fri, 22 Nov 2024 17:15:59 -0500 Subject: [PATCH] Scaffold droplet autoscaler spec --- specification/DigitalOcean-public.v2.yaml | 34 ++++++++ .../autoscale_pools/autoscale_pool_create.yml | 46 ++++++++++ .../autoscale_pools/autoscale_pool_delete.yml | 42 ++++++++++ .../autoscale_pool_delete_dangerous.yml | 44 ++++++++++ .../autoscale_pools/autoscale_pool_get.yml | 39 +++++++++ .../autoscale_pools/autoscale_pool_list.yml | 41 +++++++++ .../autoscale_pool_list_history.yml | 40 +++++++++ .../autoscale_pool_list_members.yml | 40 +++++++++ .../autoscale_pools/autoscale_pool_update.yml | 46 ++++++++++ .../resources/autoscale_pools/examples.yml | 43 ++++++++++ .../examples/curl/autoscale_pool_create.yml | 30 +++++++ .../examples/curl/autoscale_pool_delete.yml | 6 ++ .../curl/autoscale_pool_delete_dangerous.yml | 7 ++ .../examples/curl/autoscale_pool_get.yml | 6 ++ .../curl/autoscale_pool_history_events.yml | 6 ++ .../examples/curl/autoscale_pool_members.yml | 6 ++ .../examples/curl/autoscale_pool_update.yml | 32 +++++++ .../examples/curl/autoscale_pools_list.yml | 6 ++ .../autoscale_pools/models/autoscale_pool.yml | 67 +++++++++++++++ .../models/autoscale_pool_create.yml | 22 +++++ .../autoscale_pool_droplet_template.yml | 80 ++++++++++++++++++ .../models/autoscale_pool_dynamic_config.yml | 36 ++++++++ .../models/autoscale_pool_static_config.yml | 11 +++ .../models/current_utilization.yml | 15 ++++ .../autoscale_pools/models/history.yml | 50 +++++++++++ .../autoscale_pools/models/member.yml | 41 +++++++++ .../models/member_current_utilization.yml | 11 +++ .../resources/autoscale_pools/parameters.yml | 17 ++++ .../responses/all_autoscale_pools.yml | 26 ++++++ .../autoscale_pools/responses/all_members.yml | 27 ++++++ .../responses/autoscale_pool_create.yml | 16 ++++ .../autoscale_pools/responses/examples.yml | 83 +++++++++++++++++++ .../responses/existing_autoscale_pool.yml | 21 +++++ .../responses/history_events.yml | 25 ++++++ 34 files changed, 1062 insertions(+) create mode 100644 specification/resources/autoscale_pools/autoscale_pool_create.yml create mode 100644 specification/resources/autoscale_pools/autoscale_pool_delete.yml create mode 100644 specification/resources/autoscale_pools/autoscale_pool_delete_dangerous.yml create mode 100644 specification/resources/autoscale_pools/autoscale_pool_get.yml create mode 100644 specification/resources/autoscale_pools/autoscale_pool_list.yml create mode 100644 specification/resources/autoscale_pools/autoscale_pool_list_history.yml create mode 100644 specification/resources/autoscale_pools/autoscale_pool_list_members.yml create mode 100644 specification/resources/autoscale_pools/autoscale_pool_update.yml create mode 100644 specification/resources/autoscale_pools/examples.yml create mode 100644 specification/resources/autoscale_pools/examples/curl/autoscale_pool_create.yml create mode 100644 specification/resources/autoscale_pools/examples/curl/autoscale_pool_delete.yml create mode 100644 specification/resources/autoscale_pools/examples/curl/autoscale_pool_delete_dangerous.yml create mode 100644 specification/resources/autoscale_pools/examples/curl/autoscale_pool_get.yml create mode 100644 specification/resources/autoscale_pools/examples/curl/autoscale_pool_history_events.yml create mode 100644 specification/resources/autoscale_pools/examples/curl/autoscale_pool_members.yml create mode 100644 specification/resources/autoscale_pools/examples/curl/autoscale_pool_update.yml create mode 100644 specification/resources/autoscale_pools/examples/curl/autoscale_pools_list.yml create mode 100644 specification/resources/autoscale_pools/models/autoscale_pool.yml create mode 100644 specification/resources/autoscale_pools/models/autoscale_pool_create.yml create mode 100644 specification/resources/autoscale_pools/models/autoscale_pool_droplet_template.yml create mode 100644 specification/resources/autoscale_pools/models/autoscale_pool_dynamic_config.yml create mode 100644 specification/resources/autoscale_pools/models/autoscale_pool_static_config.yml create mode 100644 specification/resources/autoscale_pools/models/current_utilization.yml create mode 100644 specification/resources/autoscale_pools/models/history.yml create mode 100644 specification/resources/autoscale_pools/models/member.yml create mode 100644 specification/resources/autoscale_pools/models/member_current_utilization.yml create mode 100644 specification/resources/autoscale_pools/parameters.yml create mode 100644 specification/resources/autoscale_pools/responses/all_autoscale_pools.yml create mode 100644 specification/resources/autoscale_pools/responses/all_members.yml create mode 100644 specification/resources/autoscale_pools/responses/autoscale_pool_create.yml create mode 100644 specification/resources/autoscale_pools/responses/examples.yml create mode 100644 specification/resources/autoscale_pools/responses/existing_autoscale_pool.yml create mode 100644 specification/resources/autoscale_pools/responses/history_events.yml diff --git a/specification/DigitalOcean-public.v2.yaml b/specification/DigitalOcean-public.v2.yaml index ea66dc4f..4df4e51a 100644 --- a/specification/DigitalOcean-public.v2.yaml +++ b/specification/DigitalOcean-public.v2.yaml @@ -58,6 +58,14 @@ tags: For documentation on app specifications (`AppSpec` objects), please refer to the [product documentation](https://docs.digitalocean.com/products/app-platform/reference/app-spec/)). + - name: Autoscale Pools + description: |- + Droplet Autoscaling is a new DigitalOcean product that manages the horizontal scaling of customers' applications based on resource usage or a static configuration. + Customers create one or many autoscaling pools. An autoscaling pool has 2 components, scaling configuration and a droplet template. + To use Autoscaling you will need to use an image that automatically runs your application when the Droplet starts or pass a cloud-config in the user_data parameter of the Droplet template. + + **Droplet autoscaling will only be supported with Dedicated CPU droplets** + - name: Billing description: |- The billing endpoints allow you to retrieve your account balance, invoices @@ -998,6 +1006,32 @@ paths: post: $ref: 'resources/droplets/droplets_destroy_retryWithAssociatedResources.yml' + /v2/droplets/autoscale: + get: + $ref: 'resources/autoscale_pools/autoscale_pool_list.yml' + post: + $ref: 'resources/autoscale_pools/autoscale_pool_create.yml' + + /v2/droplets/autoscale/{autoscale_pool_id}: + get: + $ref: 'resources/autoscale_pools/autoscale_pool_get.yml' + put: + $ref: 'resources/autoscale_pools/autoscale_pool_update.yml' + delete: + $ref: 'resources/autoscale_pools/autoscale_pool_delete.yml' + + /v2/droplets/autoscale/{autoscale_pool_id}/dangerous: + delete: + $ref: 'resources/autoscale_pools/autoscale_pool_delete_dangerous.yml' + + /v2/droplets/autoscale/{autoscale_pool_id}/members: + get: + $ref: 'resources/autoscale_pools/autoscale_pool_list_members.yml' + + /v2/droplets/autoscale/{autoscale_pool_id}/history: + get: + $ref: 'resources/autoscale_pools/autoscale_pool_list_history.yml' + /v2/firewalls: get: $ref: 'resources/firewalls/firewalls_list.yml' diff --git a/specification/resources/autoscale_pools/autoscale_pool_create.yml b/specification/resources/autoscale_pools/autoscale_pool_create.yml new file mode 100644 index 00000000..73fb460f --- /dev/null +++ b/specification/resources/autoscale_pools/autoscale_pool_create.yml @@ -0,0 +1,46 @@ +operationId: autoscale_pool_create + +summary: Create a New Autoscale Pool + +description: | + To create a new Autoscale Pool, send a POST request to `/v2/droplets/autoscale` setting the + required attributes. + + An Autoscale Pool will be created using the provided information. The response body + will contain a JSON object with a key called `autoscale_pool`. The value will be an + object containing the standard attributes for your new Autoscale Pool. + +tags: + - Autoscale Pools + +requestBody: + content: + application/json: + schema: + $ref: 'models/autoscale_pool_create.yml' + examples: + Autoscale Create Request: + $ref: 'examples.yml#/autoscale_create_request' + +responses: + '202': + $ref: 'responses/autoscale_pool_create.yml' + + '401': + $ref: '../../shared/responses/unauthorized.yml' + + '429': + $ref: '../../shared/responses/too_many_requests.yml' + + '500': + $ref: '../../shared/responses/server_error.yml' + + default: + $ref: '../../shared/responses/unexpected_error.yml' + +x-codeSamples: + - $ref: 'examples/curl/autoscale_pool_create.yml' + +security: + - bearer_auth: + - 'droplet:create' diff --git a/specification/resources/autoscale_pools/autoscale_pool_delete.yml b/specification/resources/autoscale_pools/autoscale_pool_delete.yml new file mode 100644 index 00000000..3e956f72 --- /dev/null +++ b/specification/resources/autoscale_pools/autoscale_pool_delete.yml @@ -0,0 +1,42 @@ +operationID: autoscale_delete + +summary: Delete autoscale pool + +description: | + To destroy an Autoscale Pool, send a + DELETE request to the `/v2/droplets/autoscale/$AUTOSCALE_POOL_ID` + endpoint. + + A successful response will include a 202 response code and no content. + +tags: + - Autoscale Pools + +parameters: + - $ref: 'parameters.yml#/autoscale_pool_id' + +responses: + '202': + $ref: '../../shared/responses/no_content.yml' + + '401': + $ref: '../../shared/responses/unauthorized.yml' + + '404': + $ref: '../../shared/responses/not_found.yml' + + '429': + $ref: '../../shared/responses/too_many_requests.yml' + + '500': + $ref: '../../shared/responses/server_error.yml' + + default: + $ref: '../../shared/responses/unexpected_error.yml' + +x-codeSamples: + - $ref: 'examples/curl/autoscale_pool_delete.yml' + +security: + - bearer_auth: + - 'droplet:delete' diff --git a/specification/resources/autoscale_pools/autoscale_pool_delete_dangerous.yml b/specification/resources/autoscale_pools/autoscale_pool_delete_dangerous.yml new file mode 100644 index 00000000..e358d4a5 --- /dev/null +++ b/specification/resources/autoscale_pools/autoscale_pool_delete_dangerous.yml @@ -0,0 +1,44 @@ +operationID: autoscale_delete_dangerouts + +summary: Delete autoscale pool and resources + +description: | + To destroy an Autoscale Pool, send a + DELETE request to the `/v2/droplets/autoscale/$AUTOSCALE_POOL_ID/dangerous` + endpoint. This will delete an autoscale pool and all of the underlying resources + (droplets) + + A successful response will include a 202 response code and no content. + +tags: + - Autoscale Pools + +parameters: + - $ref: 'parameters.yml#/autoscale_pool_id' + - $ref: 'parameters.yml#/x_dangerous' + +responses: + '202': + $ref: '../../shared/responses/no_content.yml' + + '401': + $ref: '../../shared/responses/unauthorized.yml' + + '404': + $ref: '../../shared/responses/not_found.yml' + + '429': + $ref: '../../shared/responses/too_many_requests.yml' + + '500': + $ref: '../../shared/responses/server_error.yml' + + default: + $ref: '../../shared/responses/unexpected_error.yml' + +x-codeSamples: + - $ref: 'examples/curl/autoscale_pool_delete_dangerous.yml' + +security: + - bearer_auth: + - 'droplet:delete' diff --git a/specification/resources/autoscale_pools/autoscale_pool_get.yml b/specification/resources/autoscale_pools/autoscale_pool_get.yml new file mode 100644 index 00000000..b18168a4 --- /dev/null +++ b/specification/resources/autoscale_pools/autoscale_pool_get.yml @@ -0,0 +1,39 @@ +operationId: autoscale_pool_get + +summary: Retrieve an Existing Autoscale Pool + +description: | + To show information about an individual autoscale pool, send a GET request to + `/v2/droplets/autoscale/$AUTOSCALE_POOL_ID`. + +tags: + - Autoscale Pools + +parameters: + - $ref: 'parameters.yml#/autoscale_pool_id' + +responses: + '200': + $ref: 'responses/existing_autoscale_pool.yml' + + '401': + $ref: '../../shared/responses/unauthorized.yml' + + '404': + $ref: '../../shared/responses/not_found.yml' + + '429': + $ref: '../../shared/responses/too_many_requests.yml' + + '500': + $ref: '../../shared/responses/server_error.yml' + + default: + $ref: '../../shared/responses/unexpected_error.yml' + +x-codeSamples: + - $ref: 'examples/curl/autoscale_pool_get.yml' + +security: + - bearer_auth: + - 'droplet:read' diff --git a/specification/resources/autoscale_pools/autoscale_pool_list.yml b/specification/resources/autoscale_pools/autoscale_pool_list.yml new file mode 100644 index 00000000..c1572227 --- /dev/null +++ b/specification/resources/autoscale_pools/autoscale_pool_list.yml @@ -0,0 +1,41 @@ +operationId: autoscale_pools_list + +summary: List All Autoscale Pools + +description: | + To list all Autoscale Pools in your account, send a GET request to `/v2/droplets/autoscale`. + + The response body will be a JSON object with a key of `autoscale_pools`. This will be + set to an array containing objects each representing an Autoscale Pool. These will + contain the standard Autoscale Pool attributes. + +tags: + - Autoscale Pools + +parameters: + - $ref: '../../shared/parameters.yml#/per_page' + - $ref: '../../shared/parameters.yml#/page' + +responses: + '200': + $ref: 'responses/all_autoscale_pools.yml' + + '401': + $ref: '../../shared/responses/unauthorized.yml' + + '429': + $ref: '../../shared/responses/too_many_requests.yml' + + '500': + $ref: '../../shared/responses/server_error.yml' + + default: + $ref: '../../shared/responses/unexpected_error.yml' + +x-codeSamples: + - $ref: 'examples/curl/autoscale_pools_list.yml' + + +security: + - bearer_auth: + - 'droplet:read' diff --git a/specification/resources/autoscale_pools/autoscale_pool_list_history.yml b/specification/resources/autoscale_pools/autoscale_pool_list_history.yml new file mode 100644 index 00000000..1717e86c --- /dev/null +++ b/specification/resources/autoscale_pools/autoscale_pool_list_history.yml @@ -0,0 +1,40 @@ +operationId: autoscale_pools_history_list + +summary: List history events + +description: | + To list all of the scaling history events of an autoscale pool, send a GET request to `/v2/droplets/autoscale/$AUTOSCALE_POOL_ID/history`. + + The response body will be a JSON object with a key of `history`. This will be + set to an array containing objects each representing a history event. + +tags: + - Autoscale Pools + +parameters: + - $ref: '../../shared/parameters.yml#/per_page' + - $ref: '../../shared/parameters.yml#/page' + +responses: + '200': + $ref: 'responses/history_events.yml' + + '401': + $ref: '../../shared/responses/unauthorized.yml' + + '429': + $ref: '../../shared/responses/too_many_requests.yml' + + '500': + $ref: '../../shared/responses/server_error.yml' + + default: + $ref: '../../shared/responses/unexpected_error.yml' + +x-codeSamples: + - $ref: 'examples/curl/autoscale_pool_history_events.yml' + + +security: + - bearer_auth: + - 'droplet:read' diff --git a/specification/resources/autoscale_pools/autoscale_pool_list_members.yml b/specification/resources/autoscale_pools/autoscale_pool_list_members.yml new file mode 100644 index 00000000..e66529bb --- /dev/null +++ b/specification/resources/autoscale_pools/autoscale_pool_list_members.yml @@ -0,0 +1,40 @@ +operationId: autoscale_pool_members_list + +summary: List members + +description: | + To list the members (resources) in an autoscale pool, send a GET request to `/v2/droplets/autoscale/$AUTOSCALE_POOL_ID/members`. + + The response body will be a JSON object with a key of `droplets`. This will be + set to an array containing information about each of the droplets in the autoscale pool. + +tags: + - Autoscale Pools + +parameters: + - $ref: '../../shared/parameters.yml#/per_page' + - $ref: '../../shared/parameters.yml#/page' + +responses: + '200': + $ref: 'responses/all_members.yml' + + '401': + $ref: '../../shared/responses/unauthorized.yml' + + '429': + $ref: '../../shared/responses/too_many_requests.yml' + + '500': + $ref: '../../shared/responses/server_error.yml' + + default: + $ref: '../../shared/responses/unexpected_error.yml' + +x-codeSamples: + - $ref: 'examples/curl/autoscale_pool_members.yml' + + +security: + - bearer_auth: + - 'droplet:read' diff --git a/specification/resources/autoscale_pools/autoscale_pool_update.yml b/specification/resources/autoscale_pools/autoscale_pool_update.yml new file mode 100644 index 00000000..623bab73 --- /dev/null +++ b/specification/resources/autoscale_pools/autoscale_pool_update.yml @@ -0,0 +1,46 @@ +operationId: autoscale_pool_update + +summary: Update Autoscale Pool + +description: | + To update the configuration of an existing autoscale pool, send a PUT request to + `/v2/droplets/autoscale/$AUTOSCALE_POOL_ID`. The request should contain a full representation + of the autoscale pool including existing attributes. + +tags: + - Autoscale Pools + +parameters: + - $ref: 'parameters.yml#/autoscale_pool_id' + +requestBody: + content: + application/json: + schema: + $ref: 'models/autoscale_pool_create.yml' + examples: + Autoscale Update Request: + $ref: 'examples.yml#/autoscale_update_request' + +responses: + '202': + $ref: 'responses/autoscale_pool_create.yml' + + '401': + $ref: '../../shared/responses/unauthorized.yml' + + '429': + $ref: '../../shared/responses/too_many_requests.yml' + + '500': + $ref: '../../shared/responses/server_error.yml' + + default: + $ref: '../../shared/responses/unexpected_error.yml' + +x-codeSamples: + - $ref: 'examples/curl/autoscale_pool_update.yml' + +security: + - bearer_auth: + - 'droplet:create' diff --git a/specification/resources/autoscale_pools/examples.yml b/specification/resources/autoscale_pools/examples.yml new file mode 100644 index 00000000..165e933b --- /dev/null +++ b/specification/resources/autoscale_pools/examples.yml @@ -0,0 +1,43 @@ +autoscale_create_request: + value: + name: "my-autoscale-pool" + config: + min_instances: 1 + max_instances: 5 + target_cpu_utilization: 0.5 + cooldown_minutes: 10 + droplet_template: + name: example.com + region: nyc3 + size: c-2 + image: ubuntu-20-04-x64 + ssh_keys: + - 3b:16:e4:bf:8b:00:8b:b8:59:8c:a9:d3:f0:19:fa:45 + backups: true + ipv6: true + monitoring: true + tags: + - env:prod + - web + user_data: "#cloud-config\nruncmd:\n - touch /test.txt\n" + vpc_uuid: 760e09ef-dc84-11e8-981e-3cfdfeaae000 +autoscale_update_request: + value: + name: "my-autoscale-pool" + config: + target_number_instances: 2 + droplet_template: + name: example.com + region: nyc3 + size: c-2 + image: ubuntu-20-04-x64 + ssh_keys: + - 3b:16:e4:bf:8b:00:8b:b8:59:8c:a9:d3:f0:19:fa:45 + backups: true + ipv6: true + monitoring: true + tags: + - env:prod + - web + user_data: "#cloud-config\nruncmd:\n - touch /test.txt\n" + vpc_uuid: 760e09ef-dc84-11e8-981e-3cfdfeaae000 diff --git a/specification/resources/autoscale_pools/examples/curl/autoscale_pool_create.yml b/specification/resources/autoscale_pools/examples/curl/autoscale_pool_create.yml new file mode 100644 index 00000000..cb96fac1 --- /dev/null +++ b/specification/resources/autoscale_pools/examples/curl/autoscale_pool_create.yml @@ -0,0 +1,30 @@ +lang: cURL +source: |- + curl -X POST \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + -d '{ + "name": "test-autoscalergroup", + "config": { + "min_instances": 1, + "max_instances": 5, + "target_cpu_utilization": 0.5, + "cooldown_minutes": 5 + }, + "droplet_template": { + "size": "c-2", + "region": "tor1", + "image": 'ubuntu-20-04-x64', + "tags": [ + "test-ag-01" + ], + "ssh_keys": [ + "392594", + "385255" + ], + "vpc_uuid": "c472520a-831e-4770-8135-542c57a69daa", + "ipv6": true, + "user_data": "\n#cloud-config\nruncmd:\n- apt-get update\n" + } + }' \ + "https://api.digitalocean.com/v2/droplets/autoscale" diff --git a/specification/resources/autoscale_pools/examples/curl/autoscale_pool_delete.yml b/specification/resources/autoscale_pools/examples/curl/autoscale_pool_delete.yml new file mode 100644 index 00000000..9db34579 --- /dev/null +++ b/specification/resources/autoscale_pools/examples/curl/autoscale_pool_delete.yml @@ -0,0 +1,6 @@ +lang: cURL +source: |- + curl -X DELETE \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + "https://api.digitalocean.com/v2/droplets/autoscale/880fee37-d07a-4f94-94a0-f07d9fc7bbb4" diff --git a/specification/resources/autoscale_pools/examples/curl/autoscale_pool_delete_dangerous.yml b/specification/resources/autoscale_pools/examples/curl/autoscale_pool_delete_dangerous.yml new file mode 100644 index 00000000..db76f5b7 --- /dev/null +++ b/specification/resources/autoscale_pools/examples/curl/autoscale_pool_delete_dangerous.yml @@ -0,0 +1,7 @@ +lang: cURL +source: |- + curl -X DELETE \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + -H "X-Dangerous: true" \ + "https://api.digitalocean.com/v2/droplets/autoscale/880fee37-d07a-4f94-94a0-f07d9fc7bbb4/dangerous" diff --git a/specification/resources/autoscale_pools/examples/curl/autoscale_pool_get.yml b/specification/resources/autoscale_pools/examples/curl/autoscale_pool_get.yml new file mode 100644 index 00000000..219256d7 --- /dev/null +++ b/specification/resources/autoscale_pools/examples/curl/autoscale_pool_get.yml @@ -0,0 +1,6 @@ +lang: cURL +source: |- + curl -X GET \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + "https://api.digitalocean.com/v2/droplets/autoscale/880fee37-d07a-4f94-94a0-f07d9fc7bbb4" diff --git a/specification/resources/autoscale_pools/examples/curl/autoscale_pool_history_events.yml b/specification/resources/autoscale_pools/examples/curl/autoscale_pool_history_events.yml new file mode 100644 index 00000000..f4ddb63a --- /dev/null +++ b/specification/resources/autoscale_pools/examples/curl/autoscale_pool_history_events.yml @@ -0,0 +1,6 @@ +lang: cURL +source: |- + curl -X GET \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + "https://api.digitalocean.com/v2/droplets/autoscale/07445b1b-1dc1-414d-b0a7-239ac66a9148/history" diff --git a/specification/resources/autoscale_pools/examples/curl/autoscale_pool_members.yml b/specification/resources/autoscale_pools/examples/curl/autoscale_pool_members.yml new file mode 100644 index 00000000..72ab0a9a --- /dev/null +++ b/specification/resources/autoscale_pools/examples/curl/autoscale_pool_members.yml @@ -0,0 +1,6 @@ +lang: cURL +source: |- + curl -X GET \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + "https://api.digitalocean.com/v2/droplets/autoscale/d0067f19-c9bd-4d8c-b28b-e464fd1fb250/members" diff --git a/specification/resources/autoscale_pools/examples/curl/autoscale_pool_update.yml b/specification/resources/autoscale_pools/examples/curl/autoscale_pool_update.yml new file mode 100644 index 00000000..d667e3e7 --- /dev/null +++ b/specification/resources/autoscale_pools/examples/curl/autoscale_pool_update.yml @@ -0,0 +1,32 @@ +lang: cURL +source: |- + curl -X PUT \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + -d '{ + "name": "test-autoscalergroup-01", + "config": { + "min_instances": 1, + "max_instances": 5, + "target_cpu_utilization": 0.5, + "cooldown_minutes": 10 + }, + "droplet_template": { + "size": "c-2", + "region": "tor1", + "image": 'ubuntu-20-04-x64', + "tags": [ + "test-ag-01" + ], + "ssh_keys": [ + "372862", + "367582", + "355790" + ], + "vpc_uuid": "4637280e-3842-4661-a628-a6f0392959d3", + "with_droplet_agent": true, + "ipv6": true, + "user_data": "\n#cloud-config\nruncmd:\n- apt-get update\n" + } + }' \ + "https://api.digitalocean.com/v2/droplets/autoscale/d0067f19-c9bd-4d8c-b28b-e464fd1fb250" diff --git a/specification/resources/autoscale_pools/examples/curl/autoscale_pools_list.yml b/specification/resources/autoscale_pools/examples/curl/autoscale_pools_list.yml new file mode 100644 index 00000000..137d297c --- /dev/null +++ b/specification/resources/autoscale_pools/examples/curl/autoscale_pools_list.yml @@ -0,0 +1,6 @@ +lang: cURL +source: |- + curl -X GET \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \ + "https://api.digitalocean.com/v2/droplets/autoscale?page=1&per_page=1" diff --git a/specification/resources/autoscale_pools/models/autoscale_pool.yml b/specification/resources/autoscale_pools/models/autoscale_pool.yml new file mode 100644 index 00000000..00013991 --- /dev/null +++ b/specification/resources/autoscale_pools/models/autoscale_pool.yml @@ -0,0 +1,67 @@ +type: object + +properties: + id: + type: string + example: 0d3db13e-a604-4944-9827-7ec2642d32ac + description: A unique identifier for each Autoscale pool instance. This is + automatically generated upon Autoscale Pool creation. + + name: + type: string + example: my-autoscale-pool + description: The human-readable name set for the Autoscale Pool. + + config: + oneOf: + - $ref: ../models/autoscale_pool_static_config.yml + - $ref: ../models/autoscale_pool_dynamic_config.yml + type: object + description: This is the scaling configuration for an autoscale pool + Currently 2 methods are supported for how an autoscaling pool scales up and down. + Additional methods may be added in future releases. + + droplet_template: + $ref: ../models/autoscale_pool_droplet_template.yml + + current_utilization: + $ref: ../models/current_utilization.yml + + created_at: + format: date-time + title: The creation time of the autoscale pool + type: string + example: 2020-07-28T18:00:00Z + description: A time value given in ISO8601 combined date and time format + that represents when the Autoscale Pool was created. + + updated_at: + format: date-time + title: When the autoscale pool was last updated + type: string + example: 2020-07-28T18:00:00Z + description: A time value given in ISO8601 combined date and time format + that represents when the Autoscale Pool was last updated. + + status: + type: string + enum: + - active + - deleting + - error + description: The current status of the autoscale pool. + + active_resources_count: + type: integer + example: 1 + description: The number of active resources in the autoscale pool. + +required: + - id + - name + - config + - droplet_template + - created_at + - updated_at + - status + - active_resources_count diff --git a/specification/resources/autoscale_pools/models/autoscale_pool_create.yml b/specification/resources/autoscale_pools/models/autoscale_pool_create.yml new file mode 100644 index 00000000..06163b0e --- /dev/null +++ b/specification/resources/autoscale_pools/models/autoscale_pool_create.yml @@ -0,0 +1,22 @@ +type: object + +properties: + name: + example: "my-autoscaler-group" + type: string + description: "The human-readable name of the autoscaler group." + config: + oneOf: + - $ref: ../models/autoscale_pool_static_config.yml + - $ref: ../models/autoscale_pool_dynamic_config.yml + type: object + description: This is the scaling configuration for an autoscale pool + Currently 2 methods are supported for how an autoscaling pool scales up and down. + Additional methods may be added in future releases. + droplet_template: + $ref: ../models/autoscale_pool_droplet_template.yml + +required: + - name + - config + - droplet_template diff --git a/specification/resources/autoscale_pools/models/autoscale_pool_droplet_template.yml b/specification/resources/autoscale_pools/models/autoscale_pool_droplet_template.yml new file mode 100644 index 00000000..b265d3c5 --- /dev/null +++ b/specification/resources/autoscale_pools/models/autoscale_pool_droplet_template.yml @@ -0,0 +1,80 @@ +properties: + name: + type: string + example: my-droplet-name + description: "The name(s) to be applied to all droplets in the autoscale pool." + + region: + type: string + enum: + - nyc1 + - nyc2 + - nyc3 + - ams2 + - ams3 + - sfo1 + - sfo2 + - sfo3 + - sgp1 + - lon1 + - fra1 + - tor1 + - blr1 + - syd1 + description: The datacenter in which all of the droplets will be created. + + size: + type: string + example: c-2 + description: The droplet size to be used for all droplets in the autoscale pool. + You may specify the slug or the image id. **Note that only dedicated cpus will be supported with autoscale pools.** + + ssh_keys: + type: array + items: + type: string + example: "88:66:90:d2:68:d5:b5:85:e3:26:26:11:31:57:e6:f8" + description: Used to specify which keys should be installed on the droplets. You can either specify the key id or the fingerprint. + + tags: + type: array + items: + type: string + example: my-tag + description: Used to apply tags to each of the droplets in the autoscale pool. + + vpc_uuid: + type: string + description: Used to specify the VPC where the droplets will be created. Note that the VPC needs to exist in the region you intend to create the droplets in. + + with_droplet_agent: + type: boolean + description: Installs the droplet agent. In order for DO to monitor the droplet utilization used for the resource utilization scaling this needs to be set to true. + + project_id: + type: string + description: Allows you to specify which project the droplets will belong to. + + ipv6: + type: boolean + description: Will assign a unique IPV6 to each of the droplets. + + user_data: + type: string + example: | + #cloud-config + runcmd: + - touch /test.txt + description: A string containing 'user data' which may be used to configure + the Droplet on first boot, often a 'cloud-config' file or Bash script. + It must be plain text and may not exceed 64 KiB in size. + +required: + - name + - region + - size + - ssh_keys + - tags + - vpc_uuid + - with_droplet_agent + - user_data diff --git a/specification/resources/autoscale_pools/models/autoscale_pool_dynamic_config.yml b/specification/resources/autoscale_pools/models/autoscale_pool_dynamic_config.yml new file mode 100644 index 00000000..8515954b --- /dev/null +++ b/specification/resources/autoscale_pools/models/autoscale_pool_dynamic_config.yml @@ -0,0 +1,36 @@ +properties: + min_instances: + type: integer + example: 5 + description: The lower bound of the number of resources in a dynamically scaling pool. + minimum: 0 + maximum: 500 + max_instances: + type: integer + example: 10 + description: The upper bound of the number of resources in a dynamically scaling pool. + minimum: 0 + maximum: 1000 + target_cpu_utilization: + type: float + example: 0.6 + description: Target cpu utilization as a decimal. + minimum: 0 + maximum: 1 + target_memory_utilization: + type: float + example: 0.6 + description: Target memory utilization as a decimal. + minimum: 0 + maximum: 1 + cooldown_minutes: + type: integer + example: 5 + description: To prevent thrashing there is a cool down period which may be provided + this will default to 10 minutes if not provided. + minimum: 5 + maximum: 20 + +required: + - min_instances + - max_instances diff --git a/specification/resources/autoscale_pools/models/autoscale_pool_static_config.yml b/specification/resources/autoscale_pools/models/autoscale_pool_static_config.yml new file mode 100644 index 00000000..a4d8872c --- /dev/null +++ b/specification/resources/autoscale_pools/models/autoscale_pool_static_config.yml @@ -0,0 +1,11 @@ +properties: + target_number_instances: + title: static config + type: integer + example: 3 + description: Fixed number of instances in an autoscale pool. + minimum: 1 + maximum: 1000 + +required: + - target_number_instances diff --git a/specification/resources/autoscale_pools/models/current_utilization.yml b/specification/resources/autoscale_pools/models/current_utilization.yml new file mode 100644 index 00000000..2da34689 --- /dev/null +++ b/specification/resources/autoscale_pools/models/current_utilization.yml @@ -0,0 +1,15 @@ +type: object + +properties: + memory: + type: float + example: 0.3588531587713522 + description: The average memory utilization of the autoscale pool. + minimum: 0 + maximum: 1 + cpu: + type: float + example: 0.0007338008770232183 + description: The average cpu utilization the autoscale pool. + minimum: 0 + maximum: 1 diff --git a/specification/resources/autoscale_pools/models/history.yml b/specification/resources/autoscale_pools/models/history.yml new file mode 100644 index 00000000..d5c91916 --- /dev/null +++ b/specification/resources/autoscale_pools/models/history.yml @@ -0,0 +1,50 @@ +type: object + +properties: + history_event_id: + type: string + example: 01936530-4471-7b86-9634-32d8fcfecbc6 + description: the unique identifier of the history event + current_instance_count: + type: integer + example: 2 + description: the current number of instances in the autoscale pool + desired_instance_count: + type: integer + example: 2 + description: the desired instances for the autoscale pool + reason: + type: string + enum: + - CONFIGURATION_CHANGE + - SCALE_UP + - SCALE_DOWN + description: the reason for the scaling event + status: + type: string + enum: + - in_progress + - success + - error + description: status of the scaling event + created_at: + format: date-time + description: A time value given in ISO8601 combined date and time format + that represents when the History Event was created. + type: string + example: 2020-07-28T18:00:00Z + updated_at: + format: date-time + description: A time value given in ISO8601 combined date and time format + that represents when the History Event was last updated. + type: string + example: 2020-07-28T18:00:00Z + +required: + - history_event_id + - current_instance_count + - desired_instance_count + - reason + - status + - created_at + - updated_at diff --git a/specification/resources/autoscale_pools/models/member.yml b/specification/resources/autoscale_pools/models/member.yml new file mode 100644 index 00000000..03c83036 --- /dev/null +++ b/specification/resources/autoscale_pools/models/member.yml @@ -0,0 +1,41 @@ +type: object + +properties: + droplet_id: + type: integer + example: 459903570 + description: The unique identifier of the droplet. + created_at: + format: date-time + description: A time value given in ISO8601 combined date and time format + that represents when the Resource was created. + type: string + example: 2020-07-28T18:00:00Z + updated_at: + format: date-time + description: A time value given in ISO8601 combined date and time format + that represents when the Resource was last updated. + type: string + example: 2020-07-28T18:00:00Z + health_status: + type: string + example: 'active' + description: The health status of the resource. + status: + type: string + enum: + - provisioning + - active + - deleting + - "off" + description: The status of the resource (droplet). + current_utilization: + $ref: ../models/member_current_utilization.yml + +required: + - droplet_id + - created_at + - updated_at + - health_status + - status + - current_utilization diff --git a/specification/resources/autoscale_pools/models/member_current_utilization.yml b/specification/resources/autoscale_pools/models/member_current_utilization.yml new file mode 100644 index 00000000..275527ef --- /dev/null +++ b/specification/resources/autoscale_pools/models/member_current_utilization.yml @@ -0,0 +1,11 @@ +type: object + +properties: + memory: + type: float + example: 0.3588531587713522 + description: The memory utilization average of the individual resource. + cpu: + type: float + example: 0.0007338008770232183 + description: The cpu utilization average of the individual resource. diff --git a/specification/resources/autoscale_pools/parameters.yml b/specification/resources/autoscale_pools/parameters.yml new file mode 100644 index 00000000..8849396d --- /dev/null +++ b/specification/resources/autoscale_pools/parameters.yml @@ -0,0 +1,17 @@ +autoscale_pool_id: + in: path + name: autoscale_pool_id + description: A unique identifier for a Autoscale Pool instance. + required: true + schema: + type: string + example: 0d3db13e-a604-4944-9827-7ec2642d32ac +x_dangerous: + in: header + name: X-Dangerous + description: Acknowledge this action will destroy the autoscale pool and its + associated resources and _can not_ be reversed. + schema: + type: boolean + example: true + required: true diff --git a/specification/resources/autoscale_pools/responses/all_autoscale_pools.yml b/specification/resources/autoscale_pools/responses/all_autoscale_pools.yml new file mode 100644 index 00000000..704f1c83 --- /dev/null +++ b/specification/resources/autoscale_pools/responses/all_autoscale_pools.yml @@ -0,0 +1,26 @@ +description: A JSON object with a key of `autoscale_pools`. + +headers: + ratelimit-limit: + $ref: '../../../shared/headers.yml#/ratelimit-limit' + ratelimit-remaining: + $ref: '../../../shared/headers.yml#/ratelimit-remaining' + ratelimit-reset: + $ref: '../../../shared/headers.yml#/ratelimit-reset' + + +content: + application/json: + schema: + allOf: + - type: object + properties: + autoscale_pools: + type: array + items: + $ref: '../models/autoscale_pool.yml' + - $ref: '../../../shared/pages.yml#/pagination' + - $ref: '../../../shared/meta.yml' + examples: + All Autoscale Pools: + $ref: 'examples.yml#/autoscale_pools_all' diff --git a/specification/resources/autoscale_pools/responses/all_members.yml b/specification/resources/autoscale_pools/responses/all_members.yml new file mode 100644 index 00000000..6d5dac88 --- /dev/null +++ b/specification/resources/autoscale_pools/responses/all_members.yml @@ -0,0 +1,27 @@ +description: A JSON object with a key of `droplets`. + +headers: + ratelimit-limit: + $ref: '../../../shared/headers.yml#/ratelimit-limit' + ratelimit-remaining: + $ref: '../../../shared/headers.yml#/ratelimit-remaining' + ratelimit-reset: + $ref: '../../../shared/headers.yml#/ratelimit-reset' + + +content: + application/json: + schema: + allOf: + - type: object + properties: + droplets: + type: array + items: + $ref: '../models/member.yml' + - $ref: '../../../shared/pages.yml#/pagination' + - $ref: '../../../shared/meta.yml' + examples: + All members: + $ref: 'examples.yml#/members_all' + diff --git a/specification/resources/autoscale_pools/responses/autoscale_pool_create.yml b/specification/resources/autoscale_pools/responses/autoscale_pool_create.yml new file mode 100644 index 00000000..f40b6a77 --- /dev/null +++ b/specification/resources/autoscale_pools/responses/autoscale_pool_create.yml @@ -0,0 +1,16 @@ +description: Accepted + +headers: + ratelimit-limit: + $ref: '../../../shared/headers.yml#/ratelimit-limit' + ratelimit-remaining: + $ref: '../../../shared/headers.yml#/ratelimit-remaining' + ratelimit-reset: + $ref: '../../../shared/headers.yml#/ratelimit-reset' + +content: + application/json: + schema: + properties: + autoscale_pool: + $ref: '../models/autoscale_pool.yml' diff --git a/specification/resources/autoscale_pools/responses/examples.yml b/specification/resources/autoscale_pools/responses/examples.yml new file mode 100644 index 00000000..ce02cd89 --- /dev/null +++ b/specification/resources/autoscale_pools/responses/examples.yml @@ -0,0 +1,83 @@ +autoscale_pools_all: + value: + autoscale_pools: + - id: 0d3db13e-a604-4944-9827-7ec2642d32ac + name: "test-autoscaler-group-01" + config: + min_instances: 1 + max_instances: 5 + target_cpu_utilization: 0.5 + cooldown_minutes: 10 + droplet_template: + size: c-2 + region: tor1 + image: ubuntu-20-04-x64 + tags: + - my-tag + ssh_keys: + - 289794 + - 3b:16:e4:bf:8b:00:8b:b8:59:8c:a9:d3:f0:19:fa:45 + vpc_uuid: 760e09ef-dc84-11e8-981e-3cfdfeaae000 + with_droplet_agent: true + project_id: 746c6152-2fa2-11ed-92d3-27aaa54e4988 + ipv6: true + user_data: "#cloud-config\nruncmd:\n - touch /test.txt\n" + created_at: 2020-11-19T20:27:18Z + updated_at: 2020-12-01T00:42:16Z + current_utilization: + memory: 0.3588531587713522 + cpu: 0.0007338008770232183 + status: active + active_resources_count: 1 +autoscale_pool_single: + value: + autoscale_pool: + id: 0d3db13e-a604-4944-9827-7ec2642d32ac + name: "test-autoscaler-group-01" + config: + min_instances: 1 + max_instances: 5 + target_cpu_utilization: 0.5 + cooldown_minutes: 10 + droplet_template: + size: c-2 + region: tor1 + image: 'ubuntu-20-04-x64' + tags: + - my-tag + ssh_keys: + - 289794 + - 3b:16:e4:bf:8b:00:8b:b8:59:8c:a9:d3:f0:19:fa:45 + vpc_uuid: 760e09ef-dc84-11e8-981e-3cfdfeaae000 + with_droplet_agent: true + project_id: 746c6152-2fa2-11ed-92d3-27aaa54e4988 + ipv6: true + user_data: "#cloud-config\nruncmd:\n - touch /test.txt\n" + created_at: 2020-11-19T20:27:18Z + updated_at: 2020-12-01T00:42:16Z + current_utilization: + memory: 0.3588531587713522 + cpu: 0.0007338008770232183 + status: active + active_resources_count: 1 +members_all: + value: + droplets: + - id: 123456 + created_at: 2020-11-19T20:27:18Z + updated_at: 2020-12-01T00:42:16Z + health_status: "healthy" + status: "active" + current_utilization: + memory: 0.3588531587713522 + cpu: 0.0007338008770232183 +history_all: + value: + history: + - history_event_id: 01936530-4471-7b86-9634-32d8fcfecbc6 + current_instance_count: 2 + desired_instance_count: 2 + reason: "CONFIGURATION_CHANGE" + status: "success" + created_at: 2020-11-19T20:27:18Z + updated_at: 2020-12-01T00:42:16Z diff --git a/specification/resources/autoscale_pools/responses/existing_autoscale_pool.yml b/specification/resources/autoscale_pools/responses/existing_autoscale_pool.yml new file mode 100644 index 00000000..b22e096c --- /dev/null +++ b/specification/resources/autoscale_pools/responses/existing_autoscale_pool.yml @@ -0,0 +1,21 @@ +description: | + The response will be a JSON object with a key called `autoscale_pool`. This will be + set to a JSON object that contains the standard Autoscale Pool attributes. + +headers: + ratelimit-limit: + $ref: '../../../shared/headers.yml#/ratelimit-limit' + ratelimit-remaining: + $ref: '../../../shared/headers.yml#/ratelimit-remaining' + ratelimit-reset: + $ref: '../../../shared/headers.yml#/ratelimit-reset' + +content: + application/json: + schema: + properties: + autoscale_pool: + $ref: '../models/autoscale_pool.yml' + examples: + Single Autoscale Pool: + $ref: 'examples.yml#/autoscale_pool_single' diff --git a/specification/resources/autoscale_pools/responses/history_events.yml b/specification/resources/autoscale_pools/responses/history_events.yml new file mode 100644 index 00000000..d26b711a --- /dev/null +++ b/specification/resources/autoscale_pools/responses/history_events.yml @@ -0,0 +1,25 @@ +description: A JSON object with a key of `autoscale_pools`. + +headers: + ratelimit-limit: + $ref: '../../../shared/headers.yml#/ratelimit-limit' + ratelimit-remaining: + $ref: '../../../shared/headers.yml#/ratelimit-remaining' + ratelimit-reset: + $ref: '../../../shared/headers.yml#/ratelimit-reset' + +content: + application/json: + schema: + allOf: + - type: object + properties: + history: + type: array + items: + $ref: '../models/history.yml' + - $ref: '../../../shared/pages.yml#/pagination' + - $ref: '../../../shared/meta.yml' + examples: + All History Events: + $ref: 'examples.yml#/history_all'