Skip to content

cudoventures/cudo-compute-python-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cudo Compute

To use this client install cudoctl and run ./cudoctl init follow the steps to enter your API key and choose your project.

Then when you call cudo_api in python it will grab your API key from the yaml file created by cudoctl.

pip install cudo-compute

To use the api key and project set in cudoctl command line tool:

vm_api = cudo_api.virtual_machines()
vms = vm_api.list_vms(cudo_api.project_id())

If you don't want to use the automatic key you can supply your own, but you must also supply the project id manually too.

from cudo_compute import cudo_api

api_key = "s8dhap8dha8a98a9e88ewe90w9e"
project = "my-project"    
vm_api = cudo_api.virtual_machines(api_key)
vms = vm_api.list_vms(project_id)

More examples of various api calls can be found in examples.

Documentation for API Endpoints

How to create each API, methods are below:

from cudo_compute import cudo_api

key_api = cudo_api.api_keys()
billing_api = cudo_api.billing()
dc_api = cudo_api.data_centers()
disk_api = cudo_api.disks()
mt_api = cudo_api.machine_types()
net_api = cudo_api.networks()
store_api = cudo_api.object_storage()
perm_api = cudo_api.permissions
projects_api = cudo_api.projects()
ssh_api = cudo_api.ssh_keys()
search_api = cudo_api.search()
vm_api = cudo_api.virtual_machines()
def_api = cudo_api.default()

All URIs are relative to https://rest.compute.cudo.org

Class Method HTTP request Description
APIKeysApi delete_api_key DELETE /v1/api-keys/{name} Delete
APIKeysApi generate_api_key POST /v1/api-keys Generate
APIKeysApi list_api_keys GET /v1/api-keys List
BillingApi create_billing_account POST /v1/billing-accounts Create a billing account
BillingApi create_billing_account_credit_payment POST /v1/billing-accounts/{id}/credit Add credit to billing account
BillingApi delete_billing_account DELETE /v1/billing-accounts/{id} Delete billing account
BillingApi get_billing_account GET /v1/billing-accounts/{id} Get a billing account
BillingApi get_billing_account_details GET /v1/billing-accounts/{id}/details Get billing account details
BillingApi get_billing_account_payment_methods GET /v1/billing-accounts/{id}/payment-methods Get payment methods
BillingApi get_billing_account_setup_intent GET /v1/billing-accounts/{id}/setup-intent Get setup intent
BillingApi get_billing_account_spend_details GET /v1/billing-accounts/{billingAccountId}/spend/details Get spend details
BillingApi list_billing_account_credit_balance_transactions GET /v1/billing-accounts/{id}/credit-balance-transactions List credit balance transactions on a billing account
BillingApi list_billing_account_invoices GET /v1/billing-accounts/invoices List invoices
BillingApi list_billing_account_transactions GET /v1/billing-accounts/{id}/transactions List transactions on a billing account
BillingApi list_billing_accounts GET /v1/billing-accounts List billing accounts
BillingApi list_outstanding_invoices GET /v1/billing-accounts/invoices/outstanding Get outstanding invoices
BillingApi remove_billing_account_payment_method DELETE /v1/billing-accounts/{id}/payment-methods/{paymentMethodId} Remove payment method
BillingApi set_billing_account_default_payment_method POST /v1/billing-accounts/{id}/payment-methods/{paymentMethodId}/set-default Set default payment method
BillingApi update_billing_account PATCH /v1/billing-accounts/{billingAccount.id} Update billing account
DataCentersApi count_hosts GET /v1/data-centers/{dataCenterId}/host-count Get host count
DataCentersApi create_data_center POST /v1/data-centers Create data center
DataCentersApi delete_data_center DELETE /v1/data-centers/{id} Delete data center
DataCentersApi get_data_center GET /v1/data-centers/{id} Get data center
DataCentersApi get_data_center_live_utilization GET /v1/data-centers/{id}/live-utilization Get live utilization
DataCentersApi get_data_center_revenue_by_resource GET /v1/data-centers/{id}/revenue-by-resource Get revenue by resource
DataCentersApi get_data_center_revenue_time_series GET /v1/data-centers/{id}/revenue Get revenue time series
DataCentersApi list_clusters GET /v1/data-centers/{dataCenterId}/clusters List clusters
DataCentersApi list_data_centers GET /v1/data-centers List data centers
DataCentersApi list_hosts GET /v1/data-centers/{dataCenterId}/hosts List hosts
DataCentersApi update_data_center PATCH /v1/data-centers/{dataCenter.id} Update data center
DisksApi attach_storage_disk PATCH /v1/projects/{projectId}/disk/{id}/attach Attach storage disk to VM
DisksApi create_disk_snapshot POST /v1/projects/{projectId}/disks/{id}/snapshots Create Disk Snapshot
DisksApi create_storage_disk POST /v1/projects/{projectId}/disks Create storage disk
DisksApi delete_disk_snapshot DELETE /v1/projects/{projectId}/disks/{id}/snapshots Delete Disk Snapshots
DisksApi delete_storage_disk DELETE /v1/projects/{projectId}/disks/{id} Delete storage disk
DisksApi detach_storage_disk PUT /v1/projects/{projectId}/disk/{id}/detach Detach storage disk from VM
DisksApi get_disk GET /v1/projects/{projectId}/disks/{id} List disks
DisksApi list_disk_snapshots GET /v1/projects/{projectId}/disks/{id}/snapshots List Disk Snapshots
DisksApi list_disks GET /v1/projects/{projectId}/disks List disks
DisksApi revert_disk POST /v1/projects/{projectId}/disks/{id}/revert Revert Disk to Snapshot
MachineTypesApi get_machine_type GET /v1/data-centers/{dataCenterId}/machine-types/{machineType} Get a machine type in a data center
MachineTypesApi get_machine_type_live_utilization GET /v1/data-centers/{dataCenterId}/machine-types/{machineType}/live-utilization Get the utilization for a machine type in a data center
MachineTypesApi list_machine_types GET /v1/data-centers/{dataCenterId}/machine-types List machine types for a data center
NetworksApi create_network POST /v1/projects/{projectId}/networks Create network
NetworksApi create_security_group POST /v1/projects/{securityGroup.projectId}/networks/security-groups Create security group
NetworksApi delete_network DELETE /v1/projects/{projectId}/networks/{id} Delete network
NetworksApi delete_security_group DELETE /v1/projects/{projectId}/networks/security-groups/{id} Delete security group
NetworksApi get_network GET /v1/projects/{projectId}/networks/{id} Get network
NetworksApi get_security_group GET /v1/projects/{projectId}/networks/security-groups/{id} Get a security group
NetworksApi list_networks GET /v1/projects/{projectId}/networks List networks
NetworksApi list_security_groups GET /v1/projects/{projectId}/networks/security-groups List security groups
NetworksApi start_network POST /v1/projects/{projectId}/networks/{id}/start Start network
NetworksApi stop_network POST /v1/projects/{projectId}/networks/{id}/stop Stop network
NetworksApi update_security_group PATCH /v1/projects/{securityGroup.projectId}/networks/security-groups/{securityGroup.id} Update security group
ObjectStorageApi activate POST /v1/projects/{projectId}/object-storage/activate/{dataCenterId} Allow the use of S3 compatible storage in a project
ObjectStorageApi create_object_storage_user POST /v1/projects/{projectId}/object-storage/users/{dataCenterId} Create user that stores keys for storage buckets
ObjectStorageApi delete_object_storage_key DELETE /v1/projects/{projectId}/object-storage/users/{dataCenterId}/{id}/keys/{accessKey} Delete object storage user key
ObjectStorageApi delete_object_storage_user DELETE /v1/projects/{projectId}/object-storage/users/{dataCenterId}/{id} Delete object storage user
ObjectStorageApi generate_object_storage_key POST /v1/projects/{projectId}/object-storage/users/{dataCenterId}/{id} Generate access key for storage buckets
ObjectStorageApi get_object_storage_bucket GET /v1/projects/{projectId}/object-storage/buckets/{dataCenterId}/{id} Get details for a bucket
ObjectStorageApi get_object_storage_session_key GET /v1/projects/{projectId}/object-storage/session-key/{dataCenterId} Generate temporary key for storage bucket access
ObjectStorageApi get_object_storage_user GET /v1/projects/{projectId}/object-storage/users/{dataCenterId}/{userId} Get details about an object storage user
ObjectStorageApi list_object_storage_buckets GET /v1/projects/{projectId}/object-storage/buckets List buckets
ObjectStorageApi list_object_storage_users GET /v1/projects/{projectId}/object-storage/users List storage users
PermissionsApi add_billing_account_user_permission POST /v1/billing-accounts/{billingAccountId}/add-user-permission Add billing account user
PermissionsApi add_data_center_user_permission POST /v1/data-centers/{dataCenterId}/add-user-permission Add data center user
PermissionsApi add_project_user_permission POST /v1/projects/{projectId}/add-user-permission Add project user
PermissionsApi list_user_permissions GET /v1/auth/permissions List
PermissionsApi remove_billing_account_user_permission POST /v1/billing-accounts/{billingAccountId}/remove-user-permission Remove billing account user
PermissionsApi remove_data_center_user_permission POST /v1/data-centers/{dataCenterId}/remove-user-permission Remove data center user
PermissionsApi remove_project_user_permission POST /v1/projects/{projectId}/remove-user-permission Remove project user
ProjectsApi create_project POST /v1/projects Create
ProjectsApi delete_project DELETE /v1/projects/{id} Delete
ProjectsApi get_project GET /v1/projects/{id} Get
ProjectsApi list_project_ssh_keys GET /v1/project/{projectId}/ssh-keys List SSH keys
ProjectsApi list_projects GET /v1/projects List
ProjectsApi update_project PATCH /v1/projects/{project.id} Update
SSHKeysApi create_ssh_key POST /v1/ssh-keys Create
SSHKeysApi delete_ssh_key DELETE /v1/ssh-keys/{id} Delete
SSHKeysApi get_ssh_key GET /v1/ssh-keys/{id} Get
SSHKeysApi list_ssh_keys GET /v1/ssh-keys List
SearchApi list_regions GET /v1/regions Regions
UserApi create_identity_verification_session GET /v1/auth/create-identity-verification-session Get identity verification session
UserApi delete_user DELETE /v1/auth Delete
UserApi get GET /v1/auth Get
VirtualMachinesApi attach_security_group PATCH /v1/projects/{projectId}/vm/{id}/security-group/attach Attach security group to VM
VirtualMachinesApi connect_vm GET /v1/projects/{projectId}/vms/{id}/connect Connect via VNC
VirtualMachinesApi count_vms GET /v1/projects/{projectId}/count-vms Count
VirtualMachinesApi create_private_vm_image POST /v1/projects/{projectId}/images Create private VM image
VirtualMachinesApi create_vm POST /v1/projects/{projectId}/vm Create virtual machine
VirtualMachinesApi delete_private_vm_image DELETE /v1/projects/{projectId}/images/{id} Delete private VM image
VirtualMachinesApi detach_security_group PATCH /v1/projects/{projectId}/vm/{id}/security-group/detach Attach security group to VM
VirtualMachinesApi get_private_vm_image GET /v1/projects/{projectId}/images/{id} Get private VM image
VirtualMachinesApi get_vm GET /v1/projects/{projectId}/vms/{id} Get
VirtualMachinesApi list_private_vm_images GET /v1/projects/{projectId}/images List private VM images
VirtualMachinesApi list_public_vm_images GET /v1/vms/public-images List public VM images
VirtualMachinesApi list_vm_data_centers GET /v1/vms/data-centers List data centers
VirtualMachinesApi list_vm_disks GET /v1/projects/{projectId}/vms/{id}/disks List disks attached to VM
VirtualMachinesApi list_vm_gpu_models GET /v1/vms/gpu-models List GPU models
VirtualMachinesApi list_vm_machine_types2 GET /v1/vms/machine-types-2 List machine types v2
VirtualMachinesApi list_vms GET /v1/projects/{projectId}/vms List
VirtualMachinesApi monitor_vm GET /v1/projects/{projectId}/vms/{id}/monitor Monitor
VirtualMachinesApi reboot_vm POST /v1/projects/{projectId}/vms/{id}/reboot Reboot
VirtualMachinesApi resize_vm POST /v1/projects/{projectId}/vms/{id}/resize Resize vCPU and memory of VM
VirtualMachinesApi resize_vm_disk PATCH /v1/projects/{projectId}/vms/{id}/disks Resize a VM's disk
VirtualMachinesApi start_vm POST /v1/projects/{projectId}/vms/{id}/start Start
VirtualMachinesApi stop_vm POST /v1/projects/{projectId}/vms/{id}/stop Stop
VirtualMachinesApi terminate_vm POST /v1/projects/{projectId}/vms/{id}/terminate Terminate
VirtualMachinesApi update_private_vm_image POST /v1/projects/{projectId}/images/{id} Update private VM image
VirtualMachinesApi update_vm_metadata POST /v1/projects/{projectId}/vm/{id}/metadata Update VM metadata
DefaultApi get_data_center_commitment_schedule GET /v1/data-centers/{dataCenterId}/commitment-schedule
DefaultApi get_data_center_commitment_time_series GET /v1/data-centers/{dataCenterId}/commitment-time-series
DefaultApi list_billing_account_projects GET /v1/billing-accounts/{id}/projects
DefaultApi list_data_center_machine_type_prices GET /v1/data-centers/{dataCenterId}/machine-type-prices
DefaultApi list_vm_machine_types GET /v1/vms/machine-types
DefaultApi search_resources GET /v1/resources/search
DefaultApi track POST /v1/auth/track
DefaultApi update_vm_expire_time POST /v1/projects/{projectId}/vm/{id}/expire-time
DefaultApi update_vm_password POST /v1/projects/{projectId}/vm/{id}/password

Documentation For Models

Advanced Users / Development

The code is generated by swagger codegen cli.

Most code is generated in github actions see .github/workflows the generated code is put into a /src/cudo_compute directory The code gets modified and the helpers get copied in from /helpers.

./codegen.sh generates docs directory with source code and documentation.

If you wish to customise how the API key or project is selected see the code in the helpers directory.

Install the latest test version:

pip install --upgrade --index-url https://test.pypi.org/simple/ cudo-compute