From 095c01d341defd4a3c817170814bbcac7ec5dbcd Mon Sep 17 00:00:00 2001 From: Vicente Pinto Date: Tue, 3 Dec 2024 10:43:28 +0000 Subject: [PATCH] Improve examples for mariadb, mongodbflex, objectstorage, observability and opensearch --- .../{delete_instances.py => delete_instance.py} | 7 ++----- .../{delete_instances.py => delete_instance.py} | 7 ++----- .../{delete_buckets.py => delete_bucket.py} | 8 ++------ examples/observability/delete_instance.py | 13 +++++++++++++ .../{delete_instances.py => delete_instance.py} | 8 ++------ 5 files changed, 21 insertions(+), 22 deletions(-) rename examples/mariadb/{delete_instances.py => delete_instance.py} (62%) rename examples/mongodbflex/{delete_instances.py => delete_instance.py} (64%) rename examples/objectstorage/{delete_buckets.py => delete_bucket.py} (58%) create mode 100644 examples/observability/delete_instance.py rename examples/opensearch/{delete_instances.py => delete_instance.py} (60%) diff --git a/examples/mariadb/delete_instances.py b/examples/mariadb/delete_instance.py similarity index 62% rename from examples/mariadb/delete_instances.py rename to examples/mariadb/delete_instance.py index faed6b49..120d7691 100644 --- a/examples/mariadb/delete_instances.py +++ b/examples/mariadb/delete_instance.py @@ -4,13 +4,10 @@ from stackit.core.configuration import Configuration 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) -# Get all MariaDB instances -response = client.list_instances(project_id) - -for instance in response.instances: - client.delete_instance(project_id, instance.instance_id) +client.delete_instance(project_id, instance_id) diff --git a/examples/mongodbflex/delete_instances.py b/examples/mongodbflex/delete_instance.py similarity index 64% rename from examples/mongodbflex/delete_instances.py rename to examples/mongodbflex/delete_instance.py index 91718582..333a3253 100644 --- a/examples/mongodbflex/delete_instances.py +++ b/examples/mongodbflex/delete_instance.py @@ -5,13 +5,10 @@ tag = "tag" 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) -# Get all MongoDBFlex instances -response = client.list_instances(project_id, tag) - -for instance in response.items: - client.delete_instance(project_id, instance.id) +client.delete_instance(project_id, instance_id) diff --git a/examples/objectstorage/delete_buckets.py b/examples/objectstorage/delete_bucket.py similarity index 58% rename from examples/objectstorage/delete_buckets.py rename to examples/objectstorage/delete_bucket.py index 7d8d0c71..f5c87b44 100644 --- a/examples/objectstorage/delete_buckets.py +++ b/examples/objectstorage/delete_bucket.py @@ -4,14 +4,10 @@ from stackit.core.configuration import Configuration project_id = os.getenv("PROJECT_ID") +bucket_name = "BUCKET_NAME" # Create a new API client, that uses default authentication and configuration config = Configuration() client = DefaultApi(config) -# List all ObjectStorage buckets instances -response = client.list_buckets(project_id) - -# Delete all ObjectStorage buckets -for instance in response.buckets: - client.delete_bucket(project_id, instance.name) +client.delete_bucket(project_id, bucket_name) diff --git a/examples/observability/delete_instance.py b/examples/observability/delete_instance.py new file mode 100644 index 00000000..96880d62 --- /dev/null +++ b/examples/observability/delete_instance.py @@ -0,0 +1,13 @@ +import os + +from stackit.observability.api.default_api import DefaultApi +from stackit.core.configuration import Configuration + +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) + +client.delete_instance(instance_id, project_id) diff --git a/examples/opensearch/delete_instances.py b/examples/opensearch/delete_instance.py similarity index 60% rename from examples/opensearch/delete_instances.py rename to examples/opensearch/delete_instance.py index 8e2c61c1..5c3a079c 100644 --- a/examples/opensearch/delete_instances.py +++ b/examples/opensearch/delete_instance.py @@ -4,14 +4,10 @@ from stackit.core.configuration import Configuration 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 opensearch instances -response = client.list_instances(project_id) - -# Delete all instances -for instance in response.instances: - client.delete_instance(project_id, instance.cf_guid) +client.delete_instance(project_id, instance_id)