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 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions specification/DigitalOcean-public.v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,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/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/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.

Copy link
Author

Choose a reason for hiding this comment

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

Got you @andrewsomething. Just for my information, is the python client generated automatically?

Copy link
Contributor

@loosla loosla Dec 3, 2024

Choose a reason for hiding this comment

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

👋 Python client is generated automatically as soon as openapi changes merged to main branch.

4 changes: 4 additions & 0 deletions specification/resources/registry/models/multiregistry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
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'

Copy link
Author

@nayanjd-do nayanjd-do Nov 18, 2024

Choose a reason for hiding this comment

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

Awesome suggestion @andrewsomething. I have created models/registry_base.yml and updated models/multiregistry.yml and models/registry.yml to import from it. Please lemme know if it looks good now.


allOf:
- $ref: 'registry_base.yml'
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
50 changes: 8 additions & 42 deletions specification/resources/registry/models/registry.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,10 @@
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.

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.

subscription:
allOf:
- readOnly: true
- $ref: 'subscription.yml'
allOf:
- $ref: 'registry_base.yml'
- type: object
properties:
subscription:
allOf:
- readOnly: true
- $ref: 'subscription.yml'
39 changes: 39 additions & 0 deletions specification/resources/registry/models/registry_base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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.

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.
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: registries_create

summary: "[Beta] Create Container Registry By Name"

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: 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: 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: 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'
Loading
Loading