百度智能云

All Product Document

          Virtual Private Cloud

          VPC

          Acquire Endpoint

          When confirming the Endpoint configured when you use the SDK, you can first read the section on VPC Access Domain Name in the Developer Guide to understand the Endpoint concept. Baidu AI Cloud currently opens the multi-region (Region) support. Please refer to the part of network product VPC in Region Selection Introduction.

          Note: The VPC API supports both HTTP and HTTPS calling methods. HTTPS calling is recommended to improve data security.

          Acquire AK/SK

          To use Baidu AI Cloud VPC, you need to have a valid AK (Access Key ID) and SK (Secret Access Key) for signature authentication. AK/SK is assigned to users by the system and is a string to identify users and verify signatures for accessing sevice. You can obtain and understand your AK/SK information through the following steps:

          1.[Register Baidu AI Cloud Account](https://login.bce.baidu.com/reg.html? tpl=bceplat&from=portal)

          2.[Create AK/SK](https://console.bce.baidu.com/iam/? _=1513940574695#/iam/accesslist)

          Create VpcClient

          Being the client of the VPC service, VpcClient provides a series of methods for developers to interact with the VPC service. When creating VpcClient, you need to first use Endpoint, AK and SK to configure the BceClientConfigurationl type config instance, and then use the config instance to configure the VpcClient. The specific configuration method is as follows:

          HOST = b''
          AK = b''
          SK = b''
          config = BceClientConfiguration(credentials=BceCredentials(AK, SK), endpoint=HOST)
          self.the_client = vpc_client.VpcClient(config)

          Create VPC

          The function is defined as below:

          @required(name=(bytes, str), cidr=(bytes, str))
          def create_vpc(self, name, cidr, description=None, client_token=None, config=None):

          The parameters are described as follows:

          Parameter name Type Required or not Description
          name String Yes The vpc name cannot take the "default" value, with the length not exceeding 65 characters, and can be composed by numbers, characters and underlines.
          cidr String Yes cidr of vpc
          description String No vpc description, not exceeding 200 characters.
          client_token String No The idempotence Token is a ASCII string with the length of no more than 64 bits.
          config String No Instance of baidubce.BceClientConfiguration, the config of client is used if nothing is filled in.

          The example is as follows:

          vpc_name = 'test_vpc_name'
          vpc_cidr = '192.168.240.0/20'~~~~
          description = 'test_vpc_descrition'
          self.the_client.create_vpc(vpc_name, vpc_cidr, description))

          List VPC

          The function is defined as below:

          @required(marker=(bytes, str), max_Keys=int, is_Default=bool)
          def list_vpcs(self, marker=None, max_Keys=None, isDefault=None, config=None):

          The parameters are described as follows:

          Parameter name Type Required or not Description
          marker String No The starting location of query for batch acquisition of lists, and is one string generated by the system.
          max_keys Integer No The maximum quantity contained in each page. The maximum quantity usually does not exceed 1000. The default is 1000
          is_default Boolean No Default vpc? optional values: True, False; return all VPCs when this parameter is not filled in.
          config String No Instance of baidubce.BceClientConfiguration, the config of client is used if nothing is filled in.

          The example is as follows:

          self.the_client.list_vpcs()

          Query VPC

          The function is defined as below:

          @required(vpc_id=(bytes, str))
          def get_vpc(self, vpc_id, config=None):

          The parameters are described as follows:

          Parameter name Type Required or not Description
          vpc_id String Yes Id of vpc to be queried.
          config String No Instance of baidubce.BceClientConfiguration, the config of client is used if nothing is filled in.

          The example is as follows:

          self.the_client.get_vpc(vpc_id)

          Update VPC

          The function is defined as below:

          @required(vpc_id=(bytes, str), name=(bytes, str))
          def update_vpc(self, vpc_id, name, description=None, client_token=None, config=None):

          The parameters are described as follows:

          Parameter name Type Required or not Description
          vpc_id String Yes Id of vpc to be updated
          name String Yes The vpc name cannot take the "default" value, with the length not exceeding 65 characters, and can be composed by numbers, characters and underlines.
          description String No vpc description, not exceeding 200 characters.
          client_token String No The idempotence Token is a ASCII string with the length of no more than 64 bits.
          config String No Instance of baidubce.BceClientConfiguration, the config of client is used if nothing is filled in.

          The example is as follows:

          self.the_client.update_vpc(vpc_id, 'test_update_name', 'test_update_description')

          Note: The vpc name and description field can be updated only, and the cidr field cannot be updated.

          Delete VPC

          The function is defined as below:

          @required(vpc_id=(bytes, str))
          def delete_vpc(self, vpc_id, client_token=None, config=None):

          The parameters are described as follows:

          Parameter name Type Required or not Description
          vpc_id String Yes Id of vpc to be deleted.
          client_token String No The idempotence Token is a ASCII string with the length of no more than 64 bits.
          config String No Instance of baidubce.BceClientConfiguration, the config of client is used if nothing is filled in.

          The example is as follows:

          self.the_client.delete_vpc(vpc_id)
          Previous
          SDK Installation
          Next
          Subnet