Skip to content

Commit

Permalink
Add Pydo Examples part 2 (#812)
Browse files Browse the repository at this point in the history
  • Loading branch information
danaelhe authored Jul 3, 2023
1 parent 99fd47a commit ada3c2b
Show file tree
Hide file tree
Showing 268 changed files with 1,774 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
lang: Python
source: |-
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
req = {
"size": "s-1vcpu-2gb",
"count": 3,
"name": "new-pool",
"tags": [
"frontend"
],
"auto_scale": True,
"min_nodes": 3,
"max_nodes": 6
}
resp = client.kubernetes.add_node_pool(cluster_id="ba9d8da", body=req)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
lang: Python
source: |-
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
req = {
"cluster_uuids": [
"bd5f5959-5e1e-4205-a714-a914373942af",
"50c2f44c-011d-493e-aee5-361a4a0d1844"
]
}
resp = client.kubernetes.add_registry(body=req)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
lang: Python
source: |-
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
req = {
"name": "prod-cluster-01",
"region": "nyc1",
"version": "1.18.6-do.0",
"node_pools": [
{
"size": "s-1vcpu-2gb",
"count": 3,
"name": "worker-pool"
}
]
}
resp = client.kubernetes.create_cluster(body=req)
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.kubernetes.delete_cluster(cluster_id="da8fda8")
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.kubernetes.delete_node(cluster_id="da8fda8", node_pool_id="a8f3da", node_id="fa09daf")
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.kubernetes.delete_node_pool(cluster_id="da8fda8", node_pool_id="a8f3da")
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.kubernetes.destroy_associated_resources_dangerous(cluster_id="da8fda8")
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
lang: Python
source: |-
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
req = {
"load_balancers": [
"4de7ac8b-495b-4884-9a69-1050c6793cd6"
],
"volumes": [
"ba49449a-7435-11ea-b89e-0a58ac14480f"
],
"volume_snapshots": [
"edb0478d-7436-11ea-86e6-0a58ac144b91"
]
}
resp = client.kubernetes.destroy_associated_resources_selective(cluster_id="da8fda8", body=req)
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.kubernetes.get_available_upgrades(cluster_id="da8fda8")
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.kubernetes.get_cluster(cluster_id="da8fda8")
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.kubernetes.get_cluster_lint_results(cluster_id="da8fda8")
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.kubernetes.get_cluster_user(cluster_id="da8fda8")
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.kubernetes.get_credentials(cluster_id="da8fda8")
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.kubernetes.get_kubeconfig(cluster_id="da8fda8")
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.kubernetes.get_node_pool(cluster_id="da8fda8", node_pool_id="a8a8fsa")
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.kubernetes.list_associated_resources(cluster_id="da8fda8")
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.kubernetes.list_clusters()
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.kubernetes.list_node_pools(cluster_id="a8fsa8d")
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.kubernetes.list_options()
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
lang: Python
source: |-
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
req = {
"cluster_uuids": [
"bd5f5959-5e1e-4205-a714-a914373942af",
"50c2f44c-011d-493e-aee5-361a4a0d1844"
]
}
resp = client.kubernetes.remove_registry(body=req)
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
lang: Python
source: |-
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
req = {
"include_groups": [
"basic",
"doks",
"security"
],
"include_checks": [
"bare-pods",
"resource-requirements"
],
"exclude_groups": [
"workload-health"
],
"exclude_checks": [
"default-namespace"
]
}
resp = client.kubernetes.run_cluster_lint(cluster_id="1fd32a", body=req)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
lang: Python
source: |-
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
req = {
"name": "prod-cluster-01",
"tags": [
"k8s",
"k8s:bd5f5959-5e1e-4205-a714-a914373942af",
"production",
"web-team"
],
"maintenance_policy": {
"start_time": "12:00",
"day": "any"
},
"auto_upgrade": True,
"surge_upgrade": True,
"ha": True
}
resp = client.kubernetes.update_cluster(cluster_id="1fd32a", body=req)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
lang: Python
source: |-
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
req = {
"name": "frontend-pool",
"count": 3,
"tags": [
"k8s",
"k8s:bd5f5959-5e1e-4205-a714-a914373942af",
"k8s-worker",
"production",
"web-team"
],
"labels": None,
"taints": [
{
"key": "priority",
"value": "high",
"effect": "NoSchedule"
}
],
"auto_scale": True,
"min_nodes": 3,
"max_nodes": 6
}
resp = client.kubernetes.update_node_pool(cluster_id="1fd32a", node_pool_id="392fa3a", body=req)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
lang: Python
source: |-
import os
from pydo import Client
client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
req = {
"version": "1.16.13-do.0"
}
resp = client.kubernetes.upgrade_cluster(cluster_id="1fd32a", body=req)
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ x-codeSamples:
- $ref: 'examples/curl/kubernetes_add_nodePool.yml'
- $ref: 'examples/go/kubernetes_add_nodePool.yml'
- $ref: 'examples/ruby/kubernetes_add_nodePool.yml'
- $ref: 'examples/python/kubernetes_add_nodePool.yml'

security:
- bearer_auth:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ responses:
x-codeSamples:
- $ref: 'examples/curl/kubernetes_add_registry.yml'
- $ref: 'examples/go/kubernetes_add_registry.yml'
- $ref: 'examples/python/kubernetes_add_registry.yml'

security:
- bearer_auth:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ x-codeSamples:
- $ref: 'examples/curl/kubernetes_create_cluster.yml'
- $ref: 'examples/go/kubernetes_create_cluster.yml'
- $ref: 'examples/ruby/kubernetes_create_cluster.yml'
- $ref: 'examples/python/kubernetes_create_cluster.yml'

security:
- bearer_auth:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ x-codeSamples:
- $ref: 'examples/curl/kubernetes_delete_cluster.yml'
- $ref: 'examples/go/kubernetes_delete_cluster.yml'
- $ref: 'examples/ruby/kubernetes_delete_cluster.yml'
- $ref: 'examples/python/kubernetes_delete_cluster.yml'

security:
- bearer_auth:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ responses:
x-codeSamples:
- $ref: 'examples/curl/kubernetes_delete_node.yml'
- $ref: 'examples/go/kubernetes_delete_node.yml'
- $ref: 'examples/python/kubernetes_delete_node.yml'

security:
- bearer_auth:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ x-codeSamples:
- $ref: 'examples/curl/kubernetes_delete_nodePool.yml'
- $ref: 'examples/go/kubernetes_delete_nodePool.yml'
- $ref: 'examples/ruby/kubernetes_delete_nodePool.yml'
- $ref: 'examples/python/kubernetes_delete_nodePool.yml'

security:
- bearer_auth:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ responses:
x-codeSamples:
- $ref: 'examples/curl/kubernetes_destroy_associatedResourcesDangerous.yml'
- $ref: 'examples/go/kubernetes_destroy_associatedResourcesDangerous.yml'
- $ref: 'examples/python/kubernetes_destroy_associatedResourcesDangerous.yml'

security:
- bearer_auth:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ responses:
x-codeSamples:
- $ref: 'examples/curl/kubernetes_destroy_associatedResourcesSelective.yml'
- $ref: 'examples/go/kubernetes_destroy_associatedResourcesSelective.yml'
- $ref: 'examples/python/kubernetes_destroy_associatedResourcesSelective.yml'

security:
- bearer_auth:
Expand Down
Loading

0 comments on commit ada3c2b

Please sign in to comment.