From e01ef429b4d44f0d4df267627df53dba8d682f4e Mon Sep 17 00:00:00 2001 From: Melvin Klein Date: Fri, 29 Nov 2024 12:29:57 +0000 Subject: [PATCH 1/2] improve examples for serviceaccount and sqlserverflex --- examples/serviceaccount/create_serviceaccount.py | 3 ++- examples/serviceaccount/delete_service_accounts.py | 8 +++----- examples/sqlserverflex/create_instances.py | 4 +++- examples/sqlserverflex/delete_instances.py | 9 +++------ 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/examples/serviceaccount/create_serviceaccount.py b/examples/serviceaccount/create_serviceaccount.py index 70774b699..66b2ec48f 100644 --- a/examples/serviceaccount/create_serviceaccount.py +++ b/examples/serviceaccount/create_serviceaccount.py @@ -18,4 +18,5 @@ create_serviceaccount_payload = CreateServiceAccountPayload( name="my-service-account", ) -client.create_service_account(project_id, create_serviceaccount_payload) +sa = client.create_service_account(project_id, create_serviceaccount_payload) +print(f"Created service-account with email {sa.email}") \ No newline at end of file diff --git a/examples/serviceaccount/delete_service_accounts.py b/examples/serviceaccount/delete_service_accounts.py index ecd50fd77..c13572b53 100644 --- a/examples/serviceaccount/delete_service_accounts.py +++ b/examples/serviceaccount/delete_service_accounts.py @@ -4,14 +4,12 @@ from stackit.core.configuration import Configuration project_id = os.getenv("PROJECT_ID") +account_mail = "SERVICE_ACCOUNT_MAIL" # Create a new API client, that uses default authentication and configuration config = Configuration() client = DefaultApi(config) -# List all serviceaccounts -response = client.list_service_accounts(project_id) -# Delete all accounts -for account in response.items: - client.delete_service_account(project_id, account.email) +# Delete service account +client.delete_service_account(project_id, account_email) diff --git a/examples/sqlserverflex/create_instances.py b/examples/sqlserverflex/create_instances.py index cdb46476c..4228f7923 100644 --- a/examples/sqlserverflex/create_instances.py +++ b/examples/sqlserverflex/create_instances.py @@ -19,4 +19,6 @@ name="my-instance", flavorId=flavor_response.flavors[0].id, ) -client.create_instance(project_id, create_instance_payload) +instance = client.create_instance(project_id, create_instance_payload) + +print(f"Created instance with ID: {instance.id}") diff --git a/examples/sqlserverflex/delete_instances.py b/examples/sqlserverflex/delete_instances.py index 828bf5af2..a0bcaa74a 100644 --- a/examples/sqlserverflex/delete_instances.py +++ b/examples/sqlserverflex/delete_instances.py @@ -4,14 +4,11 @@ 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 sqlserverflex instances -response = client.list_instances(project_id) - -# Delete all instances -for instance in response.items: - client.delete_instance(project_id, instance.id) +# Delete the instance +client.delete_instance(project_id, instance_id) From 41ab1e5d0f77e1a47e93ee17871e1a9c58f5b664 Mon Sep 17 00:00:00 2001 From: Melvin Klein Date: Fri, 29 Nov 2024 13:38:56 +0100 Subject: [PATCH 2/2] black --- examples/serviceaccount/create_serviceaccount.py | 2 +- examples/serviceaccount/delete_service_accounts.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/serviceaccount/create_serviceaccount.py b/examples/serviceaccount/create_serviceaccount.py index 66b2ec48f..8a4bb2d61 100644 --- a/examples/serviceaccount/create_serviceaccount.py +++ b/examples/serviceaccount/create_serviceaccount.py @@ -19,4 +19,4 @@ name="my-service-account", ) sa = client.create_service_account(project_id, create_serviceaccount_payload) -print(f"Created service-account with email {sa.email}") \ No newline at end of file +print(f"Created service-account with email {sa.email}") diff --git a/examples/serviceaccount/delete_service_accounts.py b/examples/serviceaccount/delete_service_accounts.py index c13572b53..fb6a98a42 100644 --- a/examples/serviceaccount/delete_service_accounts.py +++ b/examples/serviceaccount/delete_service_accounts.py @@ -12,4 +12,4 @@ # Delete service account -client.delete_service_account(project_id, account_email) +client.delete_service_account(project_id, account_mail)