Skip to content

capitalonline/cds-python-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

English|简体中文

CapitalOnline Cloud SDK for python

The project aim to build a python SDK for CapitalOnline Cloud Platform, which help users to access CapitalOnline Cloud Service such as GIC, GBS, GPN and manage the resource easily.

It is based on the official Open API.

Features

You can find all the available actions from here. List some of them below:

  • Instance Management

    • CreateInstance
    • DescribeInstance
    • DeleteInstance
    • ModifyInstanceName
    • ModifyInstanceSpec
    • CreateDisk
    • ResizeDisk
    • DeleteDisk
    • ModifyIpAddress
    • ExtendSystemDisk
    • ResetInstancesPassword
    • ResetImage
    • ModifyInstanceChargeType
    • StartInstance
    • StartInstances
    • StopInstances
    • RebootInstances
  • Vdc Management

    • DescribeVdc
    • CreateVdc
    • DeleteVdc
    • CreatePublicNetwork
    • CreatePrivateNetwork
    • ModifyPublicNetwork
    • AddPublicIp
    • DeletePublicIp
    • DeletePublicNetwork
    • DeletePrivateNetwork
    • RenewPublicNetwork
    • ModifyVdcName
  • HaProxy Management

    • DescribeZones
    • DescribeLoadBalancersSpec
    • CreateLoadBalancer
    • DescribeLoadBalancers
    • DescribeLoadBalancersModifySpec
    • ModifyLoadBalancerInstanceSpec
    • DeleteLoadBalancer
    • DescribeCACertificates
    • DescribeCACertificate
    • DeleteCACertificate
    • UploadCACertificate
    • DescribeLoadBalancerStrategys
    • ModifyLoadBalancerStrategys
    • ModifyLoadBalancerName

Installation

# git clone https://github.com/capitalonline/cds-python-sdk.git
# cd cds-python-sdk
# python setup.py install

Examples

#!/usr/bin/python
from capitalonline.instance.client import NewClient,NewAddInstanceRequest
from capitalonline.instance.models import DataDisk, PrivateIp, SystemDisk, OrderedIP
ak = ''
sk = ''
Beijing_region = 'Beijing'

def TestClient_CreateInstance():
    # Init a credential with Access Key Id and Secret Access Key
    # You can apply them from the CDS web portal
    #init a client
    client, err = NewClient(ak, sk, Beijing_region)
    if err:
        print(f'API request failed,err:{err}')
        return
    #init instance data
    request = NewAddInstanceRequest()
    request.RegionId = 'CN_Shanghai_C'         #region id must be set.
    request.VdcId = ''                         #vdc id must be set.
    request.Password = '********'              #password must be set.
    request.InstanceName = 'test1'             #instance name must be set.
    request.InstanceChargeType = 'PostPaid'
    request.AutoRenew = 0
    request.Cpu = 4                            #cpu must be set.
    request.Ram = 4                            #ram must be set.
    request.ImageId = 'Centos_7.6_64'
    request.PublicIp = ['auto']
    request.InstanceType = 'CCS.IC3V2'         #instance type must be set.
    request.UTC = False

    dd1 = DataDisk()
    dd1.Size = 200
    dd1.Type = 'high_disk'

    ip1 = PrivateIp()
    ip1.PrivateId = ''                         #if set private ip, private id must be set.
    ip1.IP = ['auto']

    request.DataDisks = [dd1]
    request.PrivateIp = [ip1]
    
    ordered_ip1 = OrderedIP()                  # if set ordered ip, pipe id must be set. And if this parameter is used, other parameters(such as PublicIp OR PrivateIp) do not take effect.
    ordered_ip1.PipeId = ''
    ordered_ip1.IP = ['auto']

    request.OrderedIP = [ordered_ip1]

    system_disk = SystemDisk()
    system_disk.IOPS = 5
    system_disk.Size = 20
    system_disk.Type = 'ssd_system_disk'

    request.SystemDisk = system_disk
    # send request get response.
    resp, err = client.CreateInstance(request)    
    print(f'Create instance response:{resp}, err:{err}')
    
if __name__ == '__main__':
    TestClient_CreateInstance()

Contributing

We work hard to provide a high-quality and useful SDK for CapitalOnline Cloud, and we greatly value feedback and contributions from our community. Please submit your issues or pull requests through GitHub.

References

License

Apache License v2.0

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages