Package: gs-api-client
gridscale_api_client_pythonThis the official Python wrapper for gridscale'sAPI. Allowing you to manage your own infrastructure from your own applications.PrerequisitesFirst, the Python programming language needs to be installed. This can be done by using theofficial downloadspage.Once done, download and install viaPyPI$pip3installgs_api_clientIntroductionFirst, you will need yourAPI credentials.In theexamples.pyreplace theAUTH_TOKEN&USER_UUIDwith your credentials.AuthenticationThese imports and configs need to be setup before other commands can be run. If you do not need synchronous or asynchronous requests, you can leave outSyncGridscaleApiClient&GridscaleApiClientrespectively.fromgs_api_clientimportConfigurationfromgs_api_clientimportSyncGridscaleApiClient,GridscaleApiClient# Initiate the configurationconfig=Configuration()config.api_key['X-Auth-Token']="AUTH_TOKEN"config.api_key['X-Auth-UserId']="USER_UUID"# Setup the clientsync_api=SyncGridscaleApiClient(configuration=config)async_api=GridscaleApiClient(configuration=config)Async vs. sync clientWe provide two clientsSyncGridscaleApiClientandGridscaleApiClient. gridscale's API performs long running operations asynchronously in the background while returning a 202 response code, with the request identifier in thex-request-idresponse header.The main differences are:GridscaleApiClientexposes bare gridscale API functionality, whileSyncGridscaleApiClientadds a convenience layer on top.SyncGridscaleApiClientdetermines whether the request is sync or async.Makes asynchronous operations behave as if they were synchronous:The client will block until the request has finished, successful or not.Throws anAsynchronousApiErrorexception, in the case of failure.With mostPATCHandPOSTrequests, the synchronous client will return the resulting object instead of an empty body or just the reference.DebuggingAdding this line below, will output further information for debuggingconfig.debug=TrueAccess response headerAddinghttp_info=Truewhen instantiating the client, return value will be a tuple of response, response code and response headers (dict).sync_api=SyncGridscaleApiClient(http_info=True)async_api=GridscaleApiClient(http_info=True)Basic request examplesfrompprintimportpprint# Get all serverspprint(async_api.get_servers())# Create a serverpprint(async_api.create_server({'name':'test','cores':1,'memory':2}))# Update a serverpprint(async_api.update_server('<UUID>',{'name':'windows production Server','cores':2,'memory':4}))# Delete a serverpprint(client.delete_storage('<UUID>'))Exhaustive list of all functionsInside theexamples.pyfile, you can see some example requests to get your started. All endpoints are fully documented in ourAPIRequestsget_requestLocationsget_locationsget_locationServersget_serversget_servercreate_serverupdate_serverdelete_serverget_deleted_serversget_server_eventsget_server_metricsget_server_powerupdate_server_powerserver_power_shutdownServer relationsget_server_linked_ipget_server_linked_ipsget_server_linked_isoimageget_server_linked_isoimagesget_server_linked_networkget_server_linked_networksget_server_linked_storageget_server_linked_storageslink_ip_to_serverlink_isoimage_to_serverlink_network_to_serverlink_storage_to_serverupdate_server_linked_isoimageupdate_server_linked_networkupdate_server_linked_storageunlink_ip_from_serverunlink_isoimage_from_serverunlink_network_from_serverunlink_storage_from_serverStoragesget_storagesget_storagecreate_storagedelete_storageget_deleted_storagesstorage_clonestorage_rollbackupdate_storageget_storage_eventsBackupsget_storage_backupsdelete_storage_backuprollback_storage_backupStorage Backup Scheduleget_storage_backup_chedulescreate_storage_backup_scheduleget_storage_backup_scheduledelete_storage_backup_scheduleupdate_storage_backup_scheduleSnapshotsget_snapshotsget_snapshotcreate_snapshotdelete_snapshotget_snapshot_scheduleget_snapshot_schedulesupdate_snapshotcreate_snapshot_scheduleupdate_snapshot_scheduledelete_snapshot_schedulesnapshot_export_to_s3get_deleted_snapshotsTemplatesget_templatesget_templatecreate_templateupdate_templatedelete_templateget_template_eventsget_deleted_templatesMarketplace applicationsget_marketplace_applicationsget_marketplace_applicationcreate_marketplace_applicationupdate_marketplace_applicationdelete_marketplace_applicationget_marketplace_application_eventsNetworksget_networkget_networkscreate_networkupdate_networkdelete_networkget_network_eventsget_deleted_networksget_network_pinned_servers()update_network_pinned_server()delete_network_pinned_server()IP addressesget_ipsget_ipcreate_ipupdate_ipdelete_ipget_ip_eventsget_deleted_ipsLoad balancersget_loadbalancersget_loadbalancercreate_loadbalancerupdate_loadbalancerdelete_loadbalancerget_loadbalancer_eventsget_deleted_loadbalancersPaaSget_paas_servicesget_paas_servicecreate_paas_serviceupdate_paas_servicedelete_paas_servicerenew_paas_service_credentialsget_paas_service_metricsget_paas_security_zonesget_paas_security_zonecreate_paas_security_zoneupdate_paas_security_zonedelete_paas_security_zoneget_paas_service_templatesget_deleted_paas_servicesFirewallsget_firewallsget_firewallcreate_firewallupdate_firewalldelete_firewallget_firewall_eventsISO imagesget_isoimagesget_isoimagecreate_isoimageupdate_isoimagedelete_isoimageget_isoimage_eventsget_deleted_isoimagesLabelsget_labelsget_labelSSH keysget_ssh_keysget_ssh_keycreate_ssh_keyupdate_ssh_keydelete_ssh_keyget_ssh_key_eventsEventsevent_get_allObject storageget_bucketsget_access_keysget_access_keycreate_access_keydelete_access_keyCertificatesget_certificates()create_certificate()get_certificate()delete_certificate()Usagesproject_level_usage_get()project_level_server_usage_get()project_level_distributed_storage_usage_get()project_level_rocket_storage_usage_get()project_level_storage_backup_usage_get()project_level_snapshot_usage_get()project_level_template_usage_get()project_level_isoimage_usage_get()project_level_ip_usage_get()project_level_loadbalancer_usage_get()project_level_paas_service_usage_get()contract_level_usage_get()contract_level_server_usage_get()contract_level_distributed_storage_usage_get()contract_level_rocket_storage_usage_get()contract_level_storage_backup_usage_get()contract_level_snapshot_usage_get()contract_level_template_usage_get()contract_level_isoimage_usage_get()contract_level_ip_usage_get()contract_level_loadbalancer_usage_get()contract_level_paas_service_usage_get()DevelopmentCreate a virtual environment with all necessary dependencies and run the tests as follows:$python-mvenv.venv
$source.venv/bin/activate
$python-mpipinstall-rdev-requirements.txt
$pytestHave fun!