Skip to content

Commit

Permalink
[droplets/backup-policy]: include go and py examples for droplet back…
Browse files Browse the repository at this point in the history
…up policy get, list and list supported (#950)
  • Loading branch information
loosla authored Nov 26, 2024
1 parent ed48680 commit d661057
Show file tree
Hide file tree
Showing 9 changed files with 123 additions and 42 deletions.
30 changes: 16 additions & 14 deletions specification/resources/droplets/droplets_get_backup_policy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,32 @@ tags:
- Droplets

parameters:
- $ref: 'parameters.yml#/droplet_id'
- $ref: "parameters.yml#/droplet_id"

responses:
'200':
$ref: 'responses/droplet_backup_policy.yml'
"200":
$ref: "responses/droplet_backup_policy.yml"

'401':
$ref: '../../shared/responses/unauthorized.yml'
"401":
$ref: "../../shared/responses/unauthorized.yml"

'404':
$ref: '../../shared/responses/not_found.yml'
"404":
$ref: "../../shared/responses/not_found.yml"

'429':
$ref: '../../shared/responses/too_many_requests.yml'
"429":
$ref: "../../shared/responses/too_many_requests.yml"

'500':
$ref: '../../shared/responses/server_error.yml'
"500":
$ref: "../../shared/responses/server_error.yml"

default:
$ref: '../../shared/responses/unexpected_error.yml'
$ref: "../../shared/responses/unexpected_error.yml"

x-codeSamples:
- $ref: 'examples/curl/droplets_get_backup_policy.yml'
- $ref: "examples/curl/droplets_get_backup_policy.yml"
- $ref: "examples/go/droplets_get_backup_policy.yml"
- $ref: "examples/python/droplets_get_backup_policy.yml"

security:
- bearer_auth:
- 'droplet:read'
- "droplet:read"
32 changes: 17 additions & 15 deletions specification/resources/droplets/droplets_list_backup_policies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,33 @@ tags:
- Droplets

parameters:
- $ref: '../../shared/parameters.yml#/per_page'
- $ref: '../../shared/parameters.yml#/page'
- $ref: "../../shared/parameters.yml#/per_page"
- $ref: "../../shared/parameters.yml#/page"

responses:
'200':
$ref: 'responses/all_droplet_backup_policies.yml'
"200":
$ref: "responses/all_droplet_backup_policies.yml"

'401':
$ref: '../../shared/responses/unauthorized.yml'
"401":
$ref: "../../shared/responses/unauthorized.yml"

'404':
$ref: '../../shared/responses/not_found.yml'
"404":
$ref: "../../shared/responses/not_found.yml"

'429':
$ref: '../../shared/responses/too_many_requests.yml'
"429":
$ref: "../../shared/responses/too_many_requests.yml"

'500':
$ref: '../../shared/responses/server_error.yml'
"500":
$ref: "../../shared/responses/server_error.yml"

default:
$ref: '../../shared/responses/unexpected_error.yml'
$ref: "../../shared/responses/unexpected_error.yml"

x-codeSamples:
- $ref: 'examples/curl/droplets_list_backup_policies.yml'
- $ref: "examples/curl/droplets_list_backup_policies.yml"
- $ref: "examples/go/droplets_list_backup_policies.yml"
- $ref: "examples/python/droplets_list_backup_policies.yml"

security:
- bearer_auth:
- 'droplet:read'
- "droplet:read"
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,29 @@ tags:
- Droplets

responses:
'200':
$ref: 'responses/droplets_supported_backup_policies.yml'
"200":
$ref: "responses/droplets_supported_backup_policies.yml"

'401':
$ref: '../../shared/responses/unauthorized.yml'
"401":
$ref: "../../shared/responses/unauthorized.yml"

'404':
$ref: '../../shared/responses/not_found.yml'
"404":
$ref: "../../shared/responses/not_found.yml"

'429':
$ref: '../../shared/responses/too_many_requests.yml'
"429":
$ref: "../../shared/responses/too_many_requests.yml"

'500':
$ref: '../../shared/responses/server_error.yml'
"500":
$ref: "../../shared/responses/server_error.yml"

default:
$ref: '../../shared/responses/unexpected_error.yml'
$ref: "../../shared/responses/unexpected_error.yml"

x-codeSamples:
- $ref: 'examples/curl/droplets_list_supported_backup_policies.yml'
- $ref: "examples/curl/droplets_list_supported_backup_policies.yml"
- $ref: "examples/go/droplets_list_supported_backup_policies.yml"
- $ref: "examples/python/droplets_list_supported_backup_policies.yml"

security:
- bearer_auth:
- 'droplet:read'
- "droplet:read"
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
lang: Go
source: |-
import (
"context"
"os"
"github.com/digitalocean/godo"
)
func main() {
token := os.Getenv("DIGITALOCEAN_TOKEN")
client := godo.NewFromToken(token)
ctx := context.TODO()
droplet, _, err := client.Droplets.GetBackupPolicy(ctx, 444909706)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
lang: Go
source: |-
import (
"context"
"os"
"github.com/digitalocean/godo"
)
func main() {
token := os.Getenv("DIGITALOCEAN_TOKEN")
client := godo.NewFromToken(token)
ctx := context.TODO()
droplet, _, err := client.Droplets.ListBackupPolicies(ctx)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
lang: Go
source: |-
import (
"context"
"os"
"github.com/digitalocean/godo"
)
func main() {
token := os.Getenv("DIGITALOCEAN_TOKEN")
client := godo.NewFromToken(token)
ctx := context.TODO()
droplet, _, err := client.Droplets.ListSupportedBackupPolicies(ctx)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
lang: Python
source: |-
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
resp = client.droplets.get_backup_policy(droplet_id=444909706)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
lang: Python
source: |-
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
resp = client.droplets.list_backup_policies()
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
lang: Python
source: |-
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
resp = client.droplets.list_supported_backup_policies()

0 comments on commit d661057

Please sign in to comment.