예제 #1
0
    def get_eip_bp_detail(self, id, config=None):
        """
        get eip_bp's detail owned by the authenticated user and givened eip_bp_id.

        :type id: string
        :param eip: eip_bp's id.

        :type config: baidubce.BceClientConfiguration
        :param config:

        :return: detail of eip_bp, for example:
                {
                    "autoReleaseTime": "2020-05-30T06:46:44Z",
                    "name": "EIP_BP1588821183401",
                    "instanceId": "ip-9340430e",
                    "createTime": "2020-05-07T03:13:03Z",
                    "id": "bw-5fb3ce39",
                    "eips": [
                        "100.88.9.120"
                    ],
                    "instanceBandwidthInMbps": 1,
                    "bandwidthInMbps": 2,
                    "bindType": "eip"
                }
        """

        path = utils.append_uri(self._get_path(), id)
        return self._send_request(http_methods.GET,
                                  path,
                                  params=None,
                                  config=config)
예제 #2
0
    def delete_peerconn(self, peer_conn_id, client_token=None, config=None):
        """
        Delete peer connection.
        For peer connections between different accounts,
        only initiator can perform this operation.
        One cannot delete prepaid peer connections that are not expired.
        Consulting failed prepaid peer connections can be deleted.

        :param peer_conn_id:
            The id of specified peer connection.
        :type peer_conn_id: string

        :param client_token:
            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 user,
            a random String generated by default algorithm will be used.
        :type client_token: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        """
        path = utils.append_uri(self._get_path(), peer_conn_id)
        if client_token is None:
            client_token = generate_client_token()
        params = {b'clientToken': client_token}
        return self._send_request(http_methods.DELETE,
                                  path,
                                  params=params,
                                  config=config)
예제 #3
0
    def update_eip_bp_autoReleaseTime(self,
                                      id,
                                      auto_release_time,
                                      client_token=None,
                                      config=None):
        """
        Update eip_bp's auto_release_time

        :type id: string
        :param id: eip_bp's id

        :type auto_release_time: string (UTC format,like yyyy:mm:ddThh:mm:ssZ)
        :param auto_release_time: specify auto_release_time for eip_bp

        :type client_token: string
        :param client_token: if the clientToken is not specified by the user,
         a random string generated by default algorithm will be used.

        :type config: baidubce.BceClientConfiguration
        :param config:

        :return: BceResponse
        """
        body = {'autoReleaseTime': auto_release_time}
        path = utils.append_uri(self._get_path(), id)
        if client_token is None:
            client_token = self._generate_default_client_token()
        params = {b'retime': b'', b'clientToken': client_token}
        return self._send_request(http_methods.PUT,
                                  path,
                                  params=params,
                                  body=json.dumps(body),
                                  config=config)
예제 #4
0
    def unbind_eip(self, nat_id, eips, client_token=None, config=None):
        """
        Unbind EIPs of a specified nat gateway.

        :param nat_id:
            The id of specified nat-gateway.
        :type nat_id: string

        :param eips:
            EIP address list to be unbound
        :type eips: list<String>

        :param client_token:
            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 user,
            a random String generated by default algorithm will be used.
        :type client_token: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        """
        path = utils.append_uri(self.version, 'nat', nat_id)
        if client_token is None:
            client_token = generate_client_token()
        params = {b'unbind': None, b'clientToken': client_token}
        body = {'eips': eips}
        return self._send_request(http_methods.PUT,
                                  path,
                                  body=json.dumps(body),
                                  params=params,
                                  config=config)
예제 #5
0
    def rename_eip_bp(self, id, name, client_token=None, config=None):
        """
        Update eip_bp's name

        :type id: string
        :param id: eip_bp's id

        :type name: string
        :param name: eip_bp's name

        :type client_token: string
        :param client_token: if the clientToken is not specified by the user,
         a random string generated by default algorithm will be used.

        :type config: baidubce.BceClientConfiguration
        :param config:

        :return: BceResponse
        """
        body = {'name': name}
        path = utils.append_uri(self._get_path(), id)
        if client_token is None:
            client_token = self._generate_default_client_token()
        params = {b'rename': b'', b'clientToken': client_token}
        return self._send_request(http_methods.PUT,
                                  path,
                                  params=params,
                                  body=json.dumps(body),
                                  config=config)
예제 #6
0
    def delete_nat(self, nat_id, client_token=None, config=None):
        """
        Delete specified nat-gateway.
        If prepaid nat-gateway is not expired, it cannot be deleted.

        :param nat_id:
            The id of specified nat-gateway.
        :type nat_id: string

        :param client_token:
            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 user,
            a random String generated by default algorithm will be used.
        :type client_token: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        """
        path = utils.append_uri(self.version, 'nat', nat_id)
        if client_token is None:
            client_token = generate_client_token()
        params = {b'clientToken': client_token}
        return self._send_request(http_methods.DELETE,
                                  path,
                                  params=params,
                                  config=config)
예제 #7
0
    def resize_eip(self,
                   eip,
                   new_bandwidth_in_mbps,
                   client_token=None,
                   config=None):
        """
        Resizing eip

        :type eip: string
        :param eip: eip address to be resized

        :type new_bandwidth_in_mbps: int
        :param new_bandwidth_in_mbps: specify new bandwidth in Mbps for eip

        :type client_token: string
        :param client_token: if the clientToken is not specified by the user,
         a random String generated by default algorithm will be used.

        :type config: baidubce.BceClientConfiguration
        :param config:

        :return: BceResponse
        """
        body = {'newBandwidthInMbps': new_bandwidth_in_mbps}
        path = utils.append_uri(self._get_path(), eip)
        if client_token is None:
            client_token = self._generate_default_client_token()
        params = {b'resize': b'', b'clientToken': client_token}
        return self._send_request(http_methods.PUT,
                                  path,
                                  params=params,
                                  body=json.dumps(body),
                                  config=config)
예제 #8
0
    def release_eip(self, eip, client_token=None, config=None):
        """
        release the eip(delete operation)
        Only the Postpaid instance or Prepaid which is expired can be released.
        if the eip has been bound, must unbind before releasing.

        :type eip: string
        :param eip: eip address to be released

        :type client_token: string
        :param client_token: if the clientToken is not specified by the user,
         a random String generated by default algorithm will be used.

        :type config: baidubce.BceClientConfiguration
        :param config:

        :return: BceResponse
        """
        path = utils.append_uri(self._get_path(), eip)
        if client_token is None:
            client_token = self._generate_default_client_token()
        params = {b'clientToken': client_token}
        return self._send_request(http_methods.DELETE,
                                  path,
                                  params=params,
                                  config=config)
예제 #9
0
    def delete_acl(self, acl_rule_id, client_token=None, config=None):
        """
        Delete the  specific acl rule.

        :param acl_rule_id:
            The id of the specified acl.
        :type acl_rule_id: string

        :param client_token:
            If the clientToken is not specified by the user, a random String
            generated by default algorithm will be used.
        :type client_token: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        """
        path = utils.append_uri(self.prefix, 'acl', 'rule', acl_rule_id)
        params = {}
        if client_token is None:
            params[b'clientToken'] = generate_client_token()
        else:
            params[b'clientToken'] = client_token
        return self._send_request(http_methods.DELETE,
                                  path,
                                  params=params,
                                  config=config)
예제 #10
0
    def update_eip_group(self, id, name, client_token=None, config=None):
        """
        Update the name of specified EIP group.

        :param id:
            The id of specified EIP group.
        :type id: string

        :param name:
            The new name of the EIP group
        :type name: string

        :param client_token:
            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 user,
            a random String generated by default algorithm will be used.
        :type client_token: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        """
        path = utils.append_uri(self._get_path(), id)
        if client_token is None:
            client_token = generate_client_token()
        params = {b'update': None, b'clientToken': client_token}
        body = {'name': name}
        return self._send_request(http_methods.PUT,
                                  path,
                                  body=json.dumps(body),
                                  params=params,
                                  config=config)
예제 #11
0
 def _get_path(prefix=None):
     """
     :type prefix: string
     :param prefix: path prefix
     """
     if prefix is None:
         prefix = EipClient.prefix
     return utils.append_uri(EipClient.version, prefix)
예제 #12
0
    def update_peerconn(self,
                        peer_conn_id,
                        local_if_id,
                        description=None,
                        local_if_name=None,
                        client_token=None,
                        config=None):
        """
        Update the interface name or description of specified peer connection.

        :param peer_conn_id:
            The id of specified peer connection.
        :type peer_conn_id: string

        :param local_if_id:
            Local interface id of peer connection
        :type local_if_id: string

        :param description:
            Description of peer connection.
        :type description: string

        :param local_if_name:
            Name of local interface of peer connection.
        :type local_if_name: string

        :param client_token:
            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 user,
            a random String generated by default algorithm will be used.
        :type client_token: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        """
        path = utils.append_uri(self._get_path(), peer_conn_id)
        if client_token is None:
            client_token = generate_client_token()
        params = {b'clientToken': client_token}
        body = {'localIfId': local_if_id}
        if description is not None:
            body['description'] = description
        if local_if_name is not None:
            body['localIfName'] = local_if_name
        return self._send_request(http_methods.PUT,
                                  path,
                                  body=json.dumps(body),
                                  params=params,
                                  config=config)
예제 #13
0
    def _send_request(
            self, http_method, path,
            body=None, headers=None, params=None,
            config=None,
            body_parser=None):
        config = self._merge_config(self, config)
        if body_parser is None:
            body_parser = handler.parse_json

        return bce_http_client.send_request(
            config, bce_v1_signer.sign, [handler.parse_error, body_parser],
            http_method, utils.append_uri(CdnClient.prefix, path), body, headers, params)
예제 #14
0
    def purchase_reserved_eip(self,
                              eip,
                              billing=None,
                              client_token=None,
                              config=None):
        """
        PurchaseReserved eip with fixed duration,only Prepaid eip can do this

        :type eip: string
        :param eip: eip address to be renewed

        :type billing: Billing
        :param billing: billing information. The optional parameter,
         default reservationLength is 1

        :type client_token: string
        :param client_token: if the clientToken is not specified by the user,
         a random String generated by default algorithm will be used.

        :type config: baidubce.BceClientConfiguration
        :param config:

        :return: BceResponse
        """
        if billing is None:
            body = {
                'billing': {
                    'reservation': {
                        'reservationLength': 1,
                        'reservationTimeUnit': 'Month'
                    }
                }
            }
        else:
            body = {
                'billing': {
                    'reservation': {
                        'reservationLength': billing.reservation_length,
                        'reservationTimeUnit': billing.reservation_time_unit
                    }
                }
            }
        path = utils.append_uri(self._get_path(), eip)
        if client_token is None:
            client_token = self._generate_default_client_token()
        params = {b'purchaseReserved': b'', b'clientToken': client_token}
        return self._send_request(http_methods.PUT,
                                  path,
                                  params=params,
                                  body=json.dumps(body),
                                  config=config)
예제 #15
0
    def get_nat(self, nat_id, config=None):
        """
        Get the detail information of a specified nat-gateway.

        :param nat_id:
            The id of specified nat-gateway.
        :type nat_id: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        """
        path = utils.append_uri(self.version, 'nat', nat_id)
        return self._send_request(http_methods.GET, path, config=config)
예제 #16
0
    def get_peerconn(self, peer_conn_id, config=None):
        """
        Get the detail information of specified peer connection.

        :param peer_conn_id:
            The id of specified peer connection.
        :type peer_conn_id: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        """
        path = utils.append_uri(self._get_path(), peer_conn_id)
        return self._send_request(http_methods.GET, path, config=config)
예제 #17
0
    def list_subnet_acl(self,
                        subnet_id,
                        marker=None,
                        max_keys=None,
                        config=None):
        """
        Return a list of acl rules of specify subnet.

        :param subnet_id
            the id of subnet whhich the acl applied
        :type subnet_id: string

        :param 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.
        :type marker: string

        :param max_keys
            The optional parameter to specifies the max number of
            list result to return.
            The default value is 1000.
        :type max_keys: int

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
         """
        path = utils.append_uri(self.prefix, 'acl', 'rule')
        params = {}

        if marker is not None:
            params[b'marker'] = marker
        if max_keys is not None:
            params[b'maxKeys'] = max_keys

        params[b'subnetId'] = subnet_id
        return self._send_request(http_methods.GET,
                                  path,
                                  params=params,
                                  config=config)
예제 #18
0
    def _send_request(self,
                      http_method,
                      path,
                      body=None,
                      headers=None,
                      params=None,
                      config=None,
                      body_parser=None):
        config = self._merge_config(self, config)
        if body_parser is None:
            body_parser = handler.parse_json
        headers = headers or {}
        headers[http_headers.CONTENT_TYPE] = http_content_types.JSON

        return bce_http_client.send_request(
            config, bce_v1_signer.sign,
            [handler.parse_error, body_parser], http_method,
            utils.append_uri(CertClient.prefix, path), body, headers, params)
예제 #19
0
    def purchase_reserved_peerconn(self,
                                   peer_conn_id,
                                   client_token=None,
                                   billing=None,
                                   config=None):
        """
        Renew specified peer connection.
        Postpaid peer connection cannot be renewed.
        For peer connections between different accounts, only the initiator can
        perform this operation.

        :param peer_conn_id:
            The id of specified peer connection.
        :type peer_conn_id: string

        :param client_token:
            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 user,
            a random String generated by default algorithm will be used.
        :type client_token: string

        :param billing:
            Billing information.
        :type billing: peerconn_model.Billing

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        """
        path = utils.append_uri(self._get_path(), peer_conn_id)
        if client_token is None:
            client_token = generate_client_token()
        params = {b'purchaseReserved': None, b'clientToken': client_token}
        if billing is None:
            billing = default_billing_to_purchase_reserved
        body = {'billing': billing.__dict__}
        return self._send_request(http_methods.PUT,
                                  path,
                                  body=json.dumps(body),
                                  params=params,
                                  config=config)
예제 #20
0
    def resize_peerconn(self,
                        peer_conn_id,
                        new_bandwidth_in_mbps,
                        client_token=None,
                        config=None):
        """
        Scale down/up the bandwidth of specified peer connection.
        For peer connections between different accounts,
        only initiator can perform this operation.
        Prepaid peer connection can only scale up.
        Postpaid peer connection can scale up or down.

        :param peer_conn_id:
            The id of specified peer connection.
        :type peer_conn_id: string

        :param client_token:
            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 user,
            a random String generated by default algorithm will be used.
        :type client_token: string

        :param new_bandwidth_in_mbps:
            The new bandwidth of the peer connection.
        :type new_bandwidth_in_mbps: int

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        """
        path = utils.append_uri(self._get_path(), peer_conn_id)
        if client_token is None:
            client_token = generate_client_token()
        params = {b'resize': None, b'clientToken': client_token}
        body = {'newBandwidthInMbps': new_bandwidth_in_mbps}
        return self._send_request(http_methods.PUT,
                                  path,
                                  body=json.dumps(body),
                                  params=params,
                                  config=config)
예제 #21
0
    def purchase_reserved_eip_group(self,
                                    id,
                                    client_token=None,
                                    billing=None,
                                    config=None):
        """
        Renew specified EIP group.
        EIP groups cannot can not be renewed during resizing process.

        :param id:
            The id of EIP group.
        :type id: string

        :param client_token:
            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 user,
            a random String generated by default algorithm will be used.
        :type client_token: string

        :param billing:
            Billing information.
        :type billing: eip_group_model.Billing

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        """
        path = utils.append_uri(self._get_path(), id)
        if client_token is None:
            client_token = generate_client_token()
        params = {b'purchaseReserved': None, b'clientToken': client_token}
        if billing is None:
            billing = default_billing_to_purchase_reserved
        body = {'billing': billing.__dict__}
        return self._send_request(http_methods.PUT,
                                  path,
                                  body=json.dumps(body),
                                  params=params,
                                  config=config)
예제 #22
0
    def handle_peerconn(self,
                        peer_conn_id,
                        action,
                        client_token=None,
                        config=None):
        """
        Accept or reject peer connection request.
        Timeout period of connection request is 7 days.
        When timeout or the remote side rejects the connection,
        the status of peer connection on initiator side is consulting failed.

        :param peer_conn_id:
            The id of specified peer connection.
        :type peer_conn_id: string

        :param action:
            'accept': when accepting the peer connection.
            'reject': when rejecting the peer connection.
        :type action: string

        :param client_token:
            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 user,
            a random String generated by default algorithm will be used.
        :type client_token: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        """
        path = utils.append_uri(self._get_path(), peer_conn_id)
        if client_token is None:
            client_token = generate_client_token()
        params = {b'clientToken': client_token}
        params[action] = None
        return self._send_request(http_methods.PUT,
                                  path,
                                  params=params,
                                  config=config)
예제 #23
0
    def open_peerconn_dns_sync(self,
                               peer_conn_id,
                               role,
                               client_token=None,
                               config=None):
        """
        Open DNS sync between VPCs connected by peer connection.
        DNS sync can be opened only when the status of
        peer connection is available.
        DNS sync cannot be opened when the DNS status of
        peer connection is syncing or closing.

        :param peer_conn_id:
            The id of specified peer connection.
        :type peer_conn_id: string

        :param role:
            'initiator': for VPC where peer connection is initiated.
            'acceptor': for VPC where peer connection is accepted.
        :type role: string

        :param client_token:
            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 user,
            a random String generated by default algorithm will be used.
        :type client_token: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        """
        path = utils.append_uri(self._get_path(), peer_conn_id)
        if client_token is None:
            client_token = generate_client_token()
        params = {b'open': None, b'role': role, b'clientToken': client_token}
        return self._send_request(http_methods.PUT,
                                  path,
                                  params=params,
                                  config=config)
예제 #24
0
    def purchase_reserved_nat(self,
                              nat_id,
                              billing,
                              client_token=None,
                              config=None):
        """
        Renew specified nat-gateway. Postpaid NAT cannot be renewed

        :param nat_id:
            The id of specified nat-gateway.
        :type nat_id: string

        :param client_token:
            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 user,
            a random String generated by default algorithm will be used.
        :type client_token: string

        :param billing:
            Billing information.
        :type billing: nat_model.Billing

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        """
        path = utils.append_uri(self.version, 'nat', nat_id)
        if client_token is None:
            client_token = generate_client_token()
        params = {b'purchaseReserved': None, b'clientToken': client_token}
        if billing is None:
            billing = default_billing_to_purchase_reserved
        body = {'billing': billing.__dict__}
        return self._send_request(http_methods.PUT,
                                  path,
                                  body=json.dumps(body),
                                  params=params,
                                  config=config)
예제 #25
0
    def resize_eip_group_bandwidth(self,
                                   id,
                                   bandwidth_in_mbps,
                                   client_token=None,
                                   config=None):
        """
        Resize the bandwidth of a specified EIP group.

        :param id:
            The id of specified EIP group.
        :type id: string

        :param client_token:
            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 user,
            a random String generated by default algorithm will be used.
        :type client_token: string

        :param bandwidth_in_mbps:
            The new bandwidth of EIP group.
            For prepaid EIP groups, this value must be integer
            between 10 and 200.
        :type bandwidth_in_mbps: int

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        """
        path = utils.append_uri(self._get_path(), id)
        if client_token is None:
            client_token = generate_client_token()
        params = {b'resize': None, b'clientToken': client_token}
        body = {'bandwidthInMbps': bandwidth_in_mbps}
        return self._send_request(http_methods.PUT,
                                  path,
                                  body=json.dumps(body),
                                  params=params,
                                  config=config)
예제 #26
0
    def resize_eip_group_count(self,
                               id,
                               eip_add_count,
                               client_token=None,
                               config=None):
        """
        Resize the EIP count of a specified EIP group.

        :param id:
            The id of specified EIP group.
        :type id: string

        :param client_token:
            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 user,
            a random String generated by default algorithm will be used.
        :type client_token: string

        :param eip_add_count:
            The increase number of EIP addresses in the EIP group.
            This value must larger than zero, and the maximum number multiplies
            5Mbps mustn't exceed the total amount of shared bandwidth package.
        :type eip_add_count: int

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        """
        path = utils.append_uri(self._get_path(), id)
        if client_token is None:
            client_token = generate_client_token()
        params = {b'resize': None, b'clientToken': client_token}
        body = {'eipAddCount': eip_add_count}
        return self._send_request(http_methods.PUT,
                                  path,
                                  body=json.dumps(body),
                                  params=params,
                                  config=config)
예제 #27
0
    def bind_eip(self, nat_id, eips, client_token=None, config=None):
        """
        Bind EIPs to a specified nat gateway.
        If a EIP is already bound to the nat gateway, unbind it first.
        If a shared_bandwidth EIP is bound to the nat gateway,
        one can bind more shared_bandwidth EIPs.

        :param nat_id:
            The id of specified nat-gateway.
        :type nat_id: string

        :param eips:
            A public EIP or one/more EIPs in shared-bandwidth group,
            which will be bound with the nat-gateway.
        :type eips: list<String>

        :param client_token:
            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 user,
            a random String generated by default algorithm will be used.
        :type client_token: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        """
        path = utils.append_uri(self.version, 'nat', nat_id)
        if client_token is None:
            client_token = generate_client_token()
        params = {b'bind': None, b'clientToken': client_token}
        body = {'eips': eips}
        return self._send_request(http_methods.PUT,
                                  path,
                                  body=json.dumps(body),
                                  params=params,
                                  config=config)
예제 #28
0
    def list_acl_entrys(self, vpc_id, config=None):
        """
        Get the detail information of acl for specific vpc.

        :param vpc_id:
            the vpc id
        :type vpc_id: string

        :param config:
        :type config: baidubce.BceClientConfiguration

        :return:
        :rtype baidubce.bce_response.BceResponse
        """
        path = utils.append_uri(self.prefix, 'acl')
        params = {}
        params[b'vpcId'] = vpc_id

        return self._send_request(http_methods.GET,
                                  path,
                                  params=params,
                                  config=config)
예제 #29
0
    def bind_eip(self,
                 eip,
                 instance_type,
                 instance_id,
                 client_token=None,
                 config=None):
        """
        bind the eip to a specified instanceId and instanceType

        :type eip: string
        :param eip: eip address to be bound

        :type instance_type: string
        :param instance_type: type of instance to be bound(BCC BLB et.)

        :type instance_id: string
        :param instance_id: id of instance to be bound

        :type client_token: string
        :param client_token: if the clientToken is not specified by the user,
         a random String generated by default algorithm will be used.

        :type config: baidubce.BceClientConfiguration
        :param config:

        :return: BceResponse
        """
        body = {'instanceType': instance_type, 'instanceId': instance_id}
        path = utils.append_uri(self._get_path(), eip)
        if client_token is None:
            client_token = self._generate_default_client_token()
        params = {b'bind': b'', b'clientToken': client_token}
        return self._send_request(http_methods.PUT,
                                  path,
                                  params=params,
                                  body=json.dumps(body),
                                  config=config)
예제 #30
0
    def unbind_eip(self, eip, client_token=None, config=None):
        """
        unbind the eip from a specified instance

        :type eip: string
        :param eip: eip address to be unbound

        :type client_token: string
        :param client_token: if the clientToken is not specified by the user,
         a random String generated by default algorithm will be used.

        :type config: baidubce.BceClientConfiguration
        :param config:

        :return: BceResponse
        """
        path = utils.append_uri(self._get_path(), eip)
        if client_token is None:
            client_token = self._generate_default_client_token()
        params = {b'unbind': b'', b'clientToken': client_token}
        return self._send_request(http_methods.PUT,
                                  path,
                                  params=params,
                                  config=config)
예제 #31
0
파일: bos_client.py 프로젝트: lyhiving/bce
 def _get_path(config, bucket_name=None, key=None):
     return utils.append_uri(bos.URL_PREFIX, bucket_name, key)
예제 #32
0
 def _get_path(config, function_name=None, key=None):
     return utils.append_uri(sms.URL_PREFIX, function_name, key)