bce-python-sdk 0.9.19__py3-none-any.whl → 0.9.21__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
baidubce/__init__.py CHANGED
@@ -18,7 +18,7 @@ from builtins import bytes
18
18
  from . import protocol
19
19
 
20
20
 
21
- SDK_VERSION = b'0.9.19'
21
+ SDK_VERSION = b'0.9.21'
22
22
  DEFAULT_SERVICE_DOMAIN = b'bcebos.com'
23
23
  URL_PREFIX = b'/v1'
24
24
  DEFAULT_ENCODING = 'UTF-8'
@@ -70,7 +70,7 @@ class BbcClient(bce_base_client.BceBaseClient):
70
70
  def create_instance(self, flavor_id, image_id, raid_id, root_disk_size_in_gb=20, purchase_count=1,
71
71
  zone_name=None, subnet_id=None, billing=None, name=None, admin_pass=None,
72
72
  auto_renew_time_unit=None, auto_renew_time=0, deploy_set_id=None, enable_ht=False,
73
- security_group_id=None, client_token=None, config=None):
73
+ security_group_id=None, client_token=None, config=None, tags=None):
74
74
 
75
75
  """
76
76
  Create a bbc instance with the specified options.
@@ -159,6 +159,10 @@ class BbcClient(bce_base_client.BceBaseClient):
159
159
  https://bce.baidu.com/doc/BCC/API.html#.E5.B9.82.E7.AD.89.E6.80.A7
160
160
  :type client_token: string
161
161
 
162
+ :param tags:
163
+ List of tags to be bind
164
+ :type tags: list
165
+
162
166
  :return:
163
167
  :rtype baidubce.bce_response.BceResponse
164
168
  """
@@ -208,6 +212,8 @@ class BbcClient(bce_base_client.BceBaseClient):
208
212
  body['autoRenewTimeUnit'] = auto_renew_time_unit
209
213
  if auto_renew_time != 0:
210
214
  body['autoRenewTime'] = auto_renew_time
215
+ if tags is not None:
216
+ body['tags'] = tags
211
217
  return self._send_request(http_methods.POST, path, json.dumps(body),
212
218
  params=params, config=config)
213
219
 
@@ -707,6 +713,38 @@ class BbcClient(bce_base_client.BceBaseClient):
707
713
  return self._send_request(http_methods.PUT, path, body=json.dumps(body),
708
714
  params=params, config=config)
709
715
 
716
+ @required(instance_id=(bytes, str), change_tags = list)
717
+ def bind_tags(self, instance_id, change_tags, config=None):
718
+ """
719
+ bind the tags of existing instances
720
+
721
+ :param instance_id:
722
+ The id of instance.
723
+ :type instance_id: string
724
+
725
+ :param change_tags:
726
+ List of tags to be bind
727
+ :type change_tags: list
728
+
729
+ :return:
730
+ :rtype baidubce.bce_response.BceResponse
731
+
732
+ """
733
+ instance_id = compat.convert_to_bytes(instance_id)
734
+ path = b'/instance/%s/tag' % instance_id
735
+
736
+ params = {
737
+ 'bind': None
738
+ }
739
+
740
+ body = {
741
+ 'changeTags': change_tags
742
+ }
743
+
744
+ return self._send_request(http_methods.PUT, path, body=json.dumps(body),
745
+ params=params, config=config)
746
+
747
+
710
748
  @required(reserved_instance_ids=list,
711
749
  tags=list)
712
750
  def bind_reserved_instance_to_tags(self, reserved_instance_ids, tags, config=None):