Skip to content
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

MultiRegistry Beta API #944

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
18 changes: 18 additions & 0 deletions specification/DigitalOcean-public.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,24 @@ paths:
delete:
$ref: 'resources/registry/registry_delete.yml'

/v2/registries:
get:
$ref: 'resources/registry/multiregistry_get_all.yml'

/v2/registries/{registry_name}:
get:
$ref: 'resources/registry/multiregistry_get.yml'

post:
$ref: 'resources/registry/multiregistry_create.yml'

delete:
$ref: 'resources/registry/multiregistry_delete.yml'

/v2/registries/{registry_name}/docker-credentials:
get:
$ref: 'resources/registry/multiregistry_get_dockerCredentials.yml'

/v2/registry/subscription:
get:
$ref: 'resources/registry/registry_get_subscription.yml'
Expand Down
Original file line number Diff line number Diff line change
@@ -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/registry"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"https://api.digitalocean.com/v2/registry"
"https://api.digitalocean.com/v2/registries"

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
lang: cURL
source: |-
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-d '{"name": "example", "region": "fra1"}' \
"https://api.digitalocean.com/v2/registries"
Original file line number Diff line number Diff line change
@@ -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/registries/example"
Original file line number Diff line number Diff line change
@@ -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/registries"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"https://api.digitalocean.com/v2/registries"
"https://api.digitalocean.com/v2/registries/example"

Original file line number Diff line number Diff line change
@@ -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/registries"
Original file line number Diff line number Diff line change
@@ -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/registries/example/docker-credentials"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
lang: Python
source: |-
import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

req = {
"name": "example",
"region": "fra1"
}

resp = client.registry.create(body=req)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
resp = client.registry.create(body=req)
resp = client.registries.create(body=req)

As mentioned, these are generated from the operation ID. So at the moment, that would actually be client.multiregistry.create, but I think we really want client.registries.create.

39 changes: 39 additions & 0 deletions specification/resources/registry/models/multiregistry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
type: object
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nearly identical to the existing registry model. It's just missing the subscription piece. I wonder if we could do this in a way that doesn't require duplication?

Maybe something like rename this to models/registry_base.yml and update the models/registry.yml to be:

type: object

allOf:
  - $ref: 'registry_base.yml'
  - type: object
    properties:
      subscription:
        allOf:
          - readOnly: true
          - $ref: 'subscription.yml'


properties:
name:
type: string
maxLength: 63
pattern: '^[a-z0-9-]{1,63}$'
example: example
description: A globally unique name for the container registry. Must be
lowercase and be composed only of numbers, letters and `-`, up to a limit
of 63 characters.

created_at:
type: string
format: date-time
readOnly: true
example: '2020-03-21T16:02:37Z'
description: A time value given in ISO8601 combined date and time format
that represents when the registry was created.

region:
type: string
example: fra1
description: Slug of the region where registry data is stored

storage_usage_bytes:
type: integer
readOnly: true
example: 29393920
description: The amount of storage used in the registry in bytes.

storage_usage_bytes_updated_at:
type: string
format: date-time
readOnly: true
example: '2020-11-04T21:39:49.530562231Z'
description: The time at which the storage usage was updated. Storage usage
is calculated asynchronously, and may not immediately reflect pushes to
the registry.
28 changes: 28 additions & 0 deletions specification/resources/registry/models/multiregistry_create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
type: object

properties:
name:
type: string
maxLength: 63
pattern: '^[a-z0-9-]{1,63}$'
example: example
description: A globally unique name for the container registry. Must be
lowercase and be composed only of numbers, letters and `-`, up to a limit
of 63 characters.

region:
type: string
enum:
- nyc3
- sfo3
- sfo2
- ams3
- sgp1
- fra1
- blr1
- syd1
example: fra1
description: Slug of the region where registry data is stored. When not provided, a region will be selected.

required:
- name
51 changes: 51 additions & 0 deletions specification/resources/registry/multiregistry_create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
operationId: multiregistry_create
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
operationId: multiregistry_create
operationId: registries_create

The operation ID is used by generated clients to name methods. So that we are consistent with godo and other resources, we probably want to use registries here in place of multiregistry.


summary: Create Container Registry By Name (Beta)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
summary: Create Container Registry By Name (Beta)
summary: [Beta] Create Container Registry By Name

Let's put the beta tag up front for clarity.


description: |
To create your container registry, send a POST request to `/v2/registries`.

The `name` becomes part of the URL for images stored in the registry. For
example, if your registry is called `example`, an image in it will have the
URL `registry.digitalocean.com/example/image:tag`.

tags:
- Container Registry

parameters:
- $ref: 'parameters.yml#/registry_name'

requestBody:
required: true

content:
application/json:
schema:
$ref: 'models/multiregistry_create.yml'

responses:
'201':
$ref: 'responses/multiregistry_info.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/multiregistry_create.yml'
# - $ref: 'examples/python/multiregistry_create.yml'

security:
- bearer_auth:
- 'registry:create'
39 changes: 39 additions & 0 deletions specification/resources/registry/multiregistry_delete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
operationId: multiregistry_delete

summary: Delete Container Registry By Name (Beta)
Comment on lines +1 to +3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
operationId: multiregistry_delete
summary: Delete Container Registry By Name (Beta)
operationId: registries_delete
summary: [Beta] Delete Container Registry By Name


description: To delete your container registry, destroying all container image
data stored in it, send a DELETE request to `/v2/registries/{registry_name}`.

tags:
- Container Registry

parameters:
- $ref: 'parameters.yml#/registry_name'

responses:
'204':
$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/multiregistry_delete.yml'
# - $ref: 'examples/python/registry_delete.yml'

security:
- bearer_auth:
- 'registry:delete'
39 changes: 39 additions & 0 deletions specification/resources/registry/multiregistry_get.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
operationId: multiregistry_get

summary: Get Container Registry By Name (Beta)
Comment on lines +1 to +3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
operationId: multiregistry_get
summary: Get Container Registry By Name (Beta)
operationId: registries_get
summary: [Beta] Get a Container Registry By Name


description: To get information about any container registry in your account, send a GET
request to `/v2/registries/{registry_name}`.

tags:
- Container Registry

parameters:
- $ref: 'parameters.yml#/registry_name'

responses:
'200':
$ref: 'responses/multiregistry_info.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/multiregistry_get.yml'
# - $ref: 'examples/python/registry_get.yml'

security:
- bearer_auth:
- 'registry:read'
33 changes: 33 additions & 0 deletions specification/resources/registry/multiregistry_get_all.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
operationId: multiregistry_get_all

summary: Get All Container Registries (Beta)
Comment on lines +1 to +3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
operationId: multiregistry_get_all
summary: Get All Container Registries (Beta)
operationId: registries_list
summary: [Beta] List All Container Registries


description: To get information about any container registry in your account, send a GET
request to `/v2/registries/`.

tags:
- Container Registry

responses:
'200':
$ref: 'responses/all_registries_info.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/multiregistry_get_all.yml'
# - $ref: 'examples/python/registry_get.yml'

security:
- bearer_auth:
- 'registry:read'
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
operationId: multiregistry_get_dockerCredentials

summary: Get Docker Credentials By Registry Name (Beta)
Comment on lines +1 to +3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
operationId: multiregistry_get_dockerCredentials
summary: Get Docker Credentials By Registry Name (Beta)
operationId: registries_get_dockerCredentials
summary: [Beta] Get Docker Credentials By Registry Name


description: |
In order to access your container registry with the Docker client or from a
Kubernetes cluster, you will need to configure authentication. The necessary
JSON configuration can be retrieved by sending a GET request to
`/v2/registries/{registry_name}/docker-credentials`.

The response will be in the format of a Docker `config.json` file. To use the
config in your Kubernetes cluster, create a Secret with:

kubectl create secret generic docr \
--from-file=.dockerconfigjson=config.json \
--type=kubernetes.io/dockerconfigjson

By default, the returned credentials have read-only access to your registry
and cannot be used to push images. This is appropriate for most Kubernetes
clusters. To retrieve read/write credentials, suitable for use with the Docker
client or in a CI system, read_write may be provided as query parameter. For
example: `/v2/registries/{registry_name}/docker-credentials?read_write=true`

By default, the returned credentials will not expire. To retrieve credentials
with an expiry set, expiry_seconds may be provided as a query parameter. For
example: `/v2/registries/{registry_name}/docker-credentials?expiry_seconds=3600` will return
credentials that expire after one hour.

tags:
- Container Registry

parameters:
- $ref: 'parameters.yml#/registry_name'

responses:
'200':
$ref: 'responses/docker_credentials.yml'

'404':
$ref: '../../shared/responses/not_found.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/multiregistry_get_dockerCredentials.yml'
- $ref: 'examples/python/registry_get_dockerCredentials.yml'

security:
- bearer_auth:
- 'registry:read'
- 'registry:update'
20 changes: 20 additions & 0 deletions specification/resources/registry/responses/all_registries_info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
description: The response will be a JSON object with the key `registry`
containing information about your registry.

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:
registries:
type: array
items:
oneOf:
- $ref: '../models/registry.yml'
Loading
Loading