百度智能云

All Product Document

          Virtual Private Cloud

          Subnet

          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 support. Please refer to the part of network product VPC in Region Selection Introduction.

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

          Acquire AK/SK

          To use Baidu AI Cloud Subnet, 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 service. 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/? _= 1569238111708#/iam/accesslist)

          Create SubnetClient

          Being the client of the Subnet service, SubnetClient provides a series of methods for developers to interact with the Subnet service.

          When creating SubnetClient, you need to first use Endpoint, AK and SK to configure the BceClientConfiguration type config instance, and then use the config instance to configure the SubnetClient. The specific configuration method is as follows:

          $configs = array(
              'credentials' => array(
              'ak' => '',
              'sk' => '',
              ),
              'endpoint' => 'bcc.bj.baidubce.com',  //bj
          );
          $client = new SubnetClient($configs)

          Create Subnet

          The function is defined as below:

          /**
           * Create a subnet with the specified options.
           * 
           * @param string $name
           *        The name of subnet that will be created.
           * @param string $zoneName
           *        the name of available zone which the subnet belong
           *        through listZones, we can get all available zone info at current region
           *        ee.g. "cn-gz-a"  "cn-gz-b"
           * @param string $cidr
           *        The CIDR of this subnet.
           * @param string $vpcId
           *        The id of vpc which this subnet belongs.
           * @param string $subnetType
           *        The option param to describe the type of subnet create
           * @param string $description
           *        The option param to describe the subnet
           * @param string $clientToken
           *        An ASCII string whose length is less than 64.
           *        The request will be idempotent if clientToken is provided.
           *        If the clientToken is not specified by the user, a random String generated by default algorithm will be used.
           * @param array $options
           * @return mixed
           */
          public function createSubnet($name, $zoneName, $cidr, $vpcId, $subnetType = null, $description = null,                                  $clientToken = null,  $options = array()) {
              ......
          }

          The parameters are described as follows:

          Parameter name Type Required or not Description
          name string Yes The subnet name cannot take the "default" value, with the length not exceeding 65 characters, and can be composed by numbers, characters and underlines.
          zoneName string Yes Available zone name
          cidr string Yes cidr of Subnet
          vpcId string Yes Id of vpc to which the subnet belongs
          subnetType string No Subnet type, "BCC" and "BBC".
          description string No Subnet description, not exceeding 200 characters.
          clientToken string No The idempotence Token is a ASCII string with the length of no more than 64 bits.
          options array No Additional options

          The example is as follows:

          // testCreateSubnet
          $subnetName = 'sbn-test'
          $zoneName = 'cn-bj-a'
          $cidr = '192.168.0.0/20'
          $vpcId = ''
          $resp = $client->createSubnet($subnetName, $zoneName, $cidr, $vpcId);
          print_r($resp);

          List Subnet

          The function is defined as below:

          /**
           * Return a list of subnets owned by the authenticated user.
           * 
           * @param string $marker
           *        The optional parameter marker specified in the original request to specify
           *        where in the results to begin listing.
           *        Together with the marker, specifies the list result which listing should begin.
           *        If the marker is not specified, the list result will listing from the first one.
           * @param int $maxKeys
           *        The optional parameter to specifies the max number of list result to return.
           *        The default value is 1000.
           * @param string $vpcId
           *        The id of the vpc
           * @param string $zoneName
           *        the name of available zone which the subnet belong
           *        through listZones, we can get all available zone info at current region
           *        ee.g. "cn-gz-a"  "cn-gz-b"
           * @param string $subnetType
           *        he option param to describe the type of subnet to be created
           * @param array $options
           * @return mixed
           */
          public function listSubnets($marker = null, $maxKeys = null, $vpcId = null, $zoneName = null, 
                                      $subnetType = null, $options = array()) {
              ......
          }

          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.
          maxKeys int No The maximum quantity contained in each page. The maximum quantity usually does not exceed 1000. The default is 1000
          vpcId string No Id of vpc to which the subnet belongs
          zoneName string No Available zone name
          subnetType string No Subnet type, "BCC" and "BBC".
          options array No Additional options

          The example is as follows:

          // testListSubnets
          $resp = $client->listSubnets();
          print_r($resp);

          Query Subnet

          The function is defined as below:

          /**
           * Get the detail information of a specified subnet.
           * 
           * @param string $subnetId
           *        the id of the subnet
           * @param array $options
           * @return mixed
           */
          public function getSubnet($subnetId, $options = array()) {
              ......
          }

          The parameters are described as follows:

          Parameter name Type Required or not Description
          SubnetId string Yes Id of subnet to be queried.
          options array No Additional options

          The example is as follows:

          // testGetSubnet
          $subnetId = ''
          $resp = $client->getSubnet($subnetId);
          print_r($resp);

          Update Subnet

          The function is defined as below:

          /**
           * Modify the special attribute to new value of the subnet owned by the user.
           * 
           * @param string $subnetId
           *        The id of the specific subnet to be updated
           * @param string $name
           *        The name of the subnet
           * @param string $description
           *        The option param to describe the subnet
           * @param string $clientToken
           *        An ASCII string whose length is less than 64.
           *        The request will be idempotent if clientToken is provided.
           *        If the clientToken is not specified by the user, a random String generated by default algorithm will be used.
           * @param array $options
           * @return mixed
           */
          public function updateSubnet($subnetId, $name, $description = null, $clientToken = null, $options = array()) {
              ......
          }

          The parameters are described as follows:

          Parameter name Type Required or not Description
          subnetId string Yes Id of subnet to be updated.
          name string Yes The subnet 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 Subnet description, not exceeding 200 characters.
          clientToken string No The idempotence Token is a ASCII string with the length of no more than 64 bits.
          options array No Additional options

          The example is as follows:

          // testUpdateSubnet
          $subnetId = ''
          $subnetName = 'sbn-test'
          $description = 'description-test'
          $resp = $client->updateSubnet($subnetId, $subnetName $description);
          print_r($resp);

          Delete Subnet

          The function is defined as below:

          /**
           * Delete the specified subnet owned by the user.
           * 
           * @param string $subnetId
           *        the id of the subnet to be deleted
           * @param string $clientToken
           *        An ASCII string whose length is less than 64.
           *        The request will be idempotent if clientToken is provided.
           *        If the clientToken is not specified by the user, a random String generated by default algorithm will be used.
           * @param array $options
           * @return mixed
           */
          public function deleteSubnet($subnetId, $clientToken = null, $options = array()) {
                ......
          }

          The parameters are described as follows:

          Parameter name Type Required or not Description
          subnetId string Yes Id of subnet to be deleted
          clientToken string No The idempotence Token is a ASCII string with the length of no more than 64 bits.
          options array No Additional options

          The example is as follows:

          // testDeleteSubnet
          $subnetId = ''
          $resp = $client->deleteSubnet($subnetId);
          print_r($resp);
          Previous
          Vpc
          Next
          Security Group