-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Improve SKE, Postgres, RabbitMQ, Redis examples
- Loading branch information
Showing
11 changed files
with
52 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 4 additions & 7 deletions
11
examples/postgresflex/delete_instances.py → examples/postgresflex/delete_instance.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
import os | ||
|
||
from stackit.postgresflex.api.default_api import DefaultApi | ||
from stackit.core.configuration import Configuration | ||
from stackit.postgresflex.api.default_api import DefaultApi | ||
|
||
project_id = os.getenv("PROJECT_ID") | ||
instance_id = "INSTANCE_ID" | ||
|
||
# Create a new API client, that uses default authentication and configuration | ||
config = Configuration() | ||
client = DefaultApi(config) | ||
|
||
# List all postgresflex instances | ||
response = client.list_instances(project_id) | ||
|
||
# Delete all instances | ||
for instance in response.items: | ||
client.delete_instance(project_id, instance.id) | ||
# Delete an instances | ||
client.delete_instance(project_id, instance_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 4 additions & 7 deletions
11
examples/rabbitmq/delete_instances.py → examples/rabbitmq/delete_instance.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
import os | ||
|
||
from stackit.rabbitmq.api.default_api import DefaultApi | ||
from stackit.core.configuration import Configuration | ||
from stackit.rabbitmq.api.default_api import DefaultApi | ||
|
||
project_id = os.getenv("PROJECT_ID") | ||
instance_id = "INSTANCE_ID" | ||
|
||
# Create a new API client, that uses default authentication and configuration | ||
config = Configuration() | ||
client = DefaultApi(config) | ||
|
||
# List all rabbitmq instances | ||
response = client.list_instances(project_id) | ||
|
||
# Delete all instances | ||
for instance in response.instances: | ||
client.delete_instance(project_id, instance.cf_guid) | ||
# Delete an instance | ||
client.delete_instance(project_id, instance_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
import os | ||
|
||
from stackit.core.configuration import Configuration | ||
from stackit.redis.api.default_api import DefaultApi | ||
from stackit.redis.models.create_instance_payload import CreateInstancePayload | ||
from stackit.core.configuration import Configuration | ||
|
||
project_id = os.getenv("PROJECT_ID") | ||
|
||
config = Configuration() | ||
client = DefaultApi(config) | ||
|
||
# check out all available offerings | ||
# Check out all available offerings | ||
available_offerings = client.list_offerings(project_id) | ||
|
||
# take the first available plan id | ||
# Take the first available plan id | ||
offering_id = available_offerings.offerings[0].plans[0].id | ||
payload = CreateInstancePayload( | ||
instance_name="Test Instance", | ||
instance_name="test-instance", | ||
plan_id=offering_id, | ||
) | ||
|
||
# create the instance | ||
response = client.create_instance(project_id, payload) | ||
instance_id = response.instance_id | ||
|
||
print(f"Instance with id:{instance_id} has been created.") | ||
# Create the instance | ||
instance = client.create_instance(project_id, payload) | ||
print("Created instance with ID: " + instance.instance_id) |
12 changes: 4 additions & 8 deletions
12
examples/redis/delete_instances.py → examples/redis/delete_instance.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,13 @@ | ||
import os | ||
|
||
from stackit.redis.api.default_api import DefaultApi | ||
from stackit.core.configuration import Configuration | ||
|
||
from stackit.redis.api.default_api import DefaultApi | ||
|
||
project_id = os.getenv("PROJECT_ID") | ||
instance_id = "INSTANCE_ID" | ||
|
||
config = Configuration() | ||
client = DefaultApi(config) | ||
|
||
# get all instances | ||
response = client.list_instances(project_id) | ||
|
||
# delete all instances | ||
for instance in response.instances: | ||
client.delete_instance(project_id=project_id, instance_id=instance.cf_guid) | ||
# Delete an instance | ||
client.delete_instance(project_id=project_id, instance_id=instance_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
import os | ||
|
||
from stackit.redis.api.default_api import DefaultApi | ||
from stackit.core.configuration import Configuration | ||
|
||
from stackit.redis.api.default_api import DefaultApi | ||
|
||
project_id = os.getenv("PROJECT_ID") | ||
|
||
config = Configuration() | ||
client = DefaultApi(config) | ||
|
||
# get all instances | ||
# Get all instances | ||
print(client.list_instances(project_id)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,47 @@ | ||
import os | ||
|
||
from stackit.core.configuration import Configuration | ||
from stackit.ske.api.default_api import DefaultApi | ||
from stackit.ske.models.create_or_update_cluster_payload import ( | ||
CreateOrUpdateClusterPayload, | ||
) | ||
from stackit.ske.models.image import Image | ||
from stackit.ske.models.kubernetes import Kubernetes | ||
from stackit.ske.models.nodepool import Nodepool | ||
from stackit.ske.models.machine import Machine | ||
from stackit.ske.models.nodepool import Nodepool | ||
from stackit.ske.models.volume import Volume | ||
from stackit.ske.models.image import Image | ||
|
||
from stackit.core.configuration import Configuration | ||
|
||
|
||
project_id = os.getenv("PROJECT_ID") | ||
volume_type = "storage_premium_perf0" | ||
|
||
# Create a new API client, that uses default authentication and configuration | ||
config = Configuration() | ||
client = DefaultApi(config) | ||
|
||
# Get available options | ||
options_resonse = client.list_provider_options() | ||
|
||
# Create a new instance using the first option for everything | ||
cluser_name = "cl-name" | ||
create_instance_payload = CreateOrUpdateClusterPayload( | ||
kubernetes=Kubernetes(version=options_resonse.kubernetes_versions[0].version), | ||
# Create a new cluster | ||
cluster_name = "my-cl" | ||
create_cluster_payload = CreateOrUpdateClusterPayload( | ||
kubernetes=Kubernetes(version="1.30.6"), | ||
nodepools=[ | ||
Nodepool( | ||
availability_zones=[options_resonse.availability_zones[0].name], | ||
availability_zones=["eu01-3"], | ||
machine=Machine( | ||
image=Image( | ||
name=options_resonse.machine_images[0].name, | ||
version=options_resonse.machine_images[0].versions[0].version, | ||
name="ubuntu", | ||
version="2204.20240912.0", | ||
), | ||
type=options_resonse.machine_types[0].name, | ||
type="b1.2", | ||
), | ||
maximum=3, | ||
minimum=2, | ||
name="my-nodepool", | ||
volume=Volume( | ||
size=20, | ||
type=volume_type, | ||
type="storage_premium_perf0", | ||
), | ||
) | ||
], | ||
) | ||
client.create_or_update_cluster(project_id, cluser_name, create_instance_payload) | ||
cluster = client.create_or_update_cluster( | ||
project_id, cluster_name, create_cluster_payload | ||
) | ||
print("Created cluster with name: " + cluster.name) |
11 changes: 4 additions & 7 deletions
11
examples/ske/delete_clusters.py → examples/ske/delete_cluster.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
import os | ||
|
||
from stackit.ske.api.default_api import DefaultApi | ||
from stackit.core.configuration import Configuration | ||
from stackit.ske.api.default_api import DefaultApi | ||
|
||
project_id = os.getenv("PROJECT_ID") | ||
cluster_name = "CLUSTER_NAME" | ||
|
||
# Create a new API client, that uses default authentication and configuration | ||
config = Configuration() | ||
client = DefaultApi(config) | ||
|
||
# List all ske clusters | ||
response = client.list_clusters(project_id) | ||
|
||
# Delete all cluster | ||
for cluster in response.items: | ||
client.delete_cluster(project_id, cluster.name) | ||
# Delete a cluster | ||
client.delete_cluster(project_id, cluster_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters