@@ -7316,6 +7316,63 @@ def ci_update_media_queue(self, Bucket, QueueId, Request={}, UrlPath="/queue/",
73167316 format_dict (data , ['Queue' ])
73177317 return data
73187318
7319+ def ci_open_pic_bucket (self , Bucket , ** kwargs ):
7320+ """ 开通图片处理异步服务 https://cloud.tencent.com/document/product/460/95749
7321+
7322+ :param Bucket(string) 存储桶名称.
7323+ :param kwargs:(dict) 设置上传的headers.
7324+ :return(dict): response header.
7325+ :return(dict): 请求成功返回的结果, dict类型.
7326+
7327+ . code-block:: python
7328+
7329+ config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token) # 获取配置对象
7330+ client = CosS3Client(config)
7331+ # 开通图片处理异步服务
7332+ response, data = client.ci_open_pic_bucket(
7333+ Bucket='bucket')
7334+ print data
7335+ print response
7336+ """
7337+ headers = mapped (kwargs )
7338+ final_headers = {}
7339+ params = {}
7340+ for key in headers :
7341+ if key .startswith ("response" ):
7342+ params [key ] = headers [key ]
7343+ else :
7344+ final_headers [key ] = headers [key ]
7345+ headers = final_headers
7346+
7347+ params = format_values (params )
7348+
7349+ path = "/" + "picbucket"
7350+ url = self ._conf .uri (bucket = Bucket , path = path , endpoint = self ._conf ._endpoint_ci )
7351+
7352+ logger .info ("ci_open_pic_bucket result, url=:{url} ,headers=:{headers}, params=:{params}" .format (
7353+ url = url ,
7354+ headers = headers ,
7355+ params = params ))
7356+ rt = self .send_request (
7357+ method = 'POST' ,
7358+ url = url ,
7359+ auth = CosS3Auth (self ._conf , path , params = params ),
7360+ params = params ,
7361+ headers = headers ,
7362+ ci_request = True )
7363+
7364+ data = rt .content
7365+ response = dict (** rt .headers )
7366+ if 'Content-Type' in response :
7367+ if response ['Content-Type' ] == 'application/xml' and 'Content-Length' in response and \
7368+ response ['Content-Length' ] != 0 :
7369+ data = xml_to_dict (rt .content )
7370+ format_dict (data , ['Response' ])
7371+ elif response ['Content-Type' ].startswith ('application/json' ):
7372+ data = rt .json ()
7373+
7374+ return response , data
7375+
73197376 def ci_get_pic_bucket (self , Regions = '' , BucketName = '' , BucketNames = '' , PageNumber = '' , PageSize = '' , ** kwargs ):
73207377 """查询图片异步处理开通状态接口
73217378
@@ -7345,6 +7402,63 @@ def ci_get_pic_bucket(self, Regions='', BucketName='', BucketNames='', PageNumbe
73457402 BucketNames = BucketNames , PageNumber = PageNumber ,
73467403 PageSize = PageSize , Path = '/picbucket' , ** kwargs )
73477404
7405+ def ci_close_pic_bucket (self , Bucket , ** kwargs ):
7406+ """ 关闭图片处理异步服务 https://cloud.tencent.com/document/product/460/95751
7407+
7408+ :param Bucket(string) 存储桶名称.
7409+ :param kwargs:(dict) 设置上传的headers.
7410+ :return(dict): response header.
7411+ :return(dict): 请求成功返回的结果, dict类型.
7412+
7413+ . code-block:: python
7414+
7415+ config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token) # 获取配置对象
7416+ client = CosS3Client(config)
7417+ # 关闭图片处理异步服务
7418+ response, data = client.ci_close_pic_bucket(
7419+ Bucket='bucket')
7420+ print data
7421+ print response
7422+ """
7423+ headers = mapped (kwargs )
7424+ final_headers = {}
7425+ params = {}
7426+ for key in headers :
7427+ if key .startswith ("response" ):
7428+ params [key ] = headers [key ]
7429+ else :
7430+ final_headers [key ] = headers [key ]
7431+ headers = final_headers
7432+
7433+ params = format_values (params )
7434+
7435+ path = "/" + "picbucket"
7436+ url = self ._conf .uri (bucket = Bucket , path = path , endpoint = self ._conf ._endpoint_ci )
7437+
7438+ logger .info ("ci_close_pic_bucket result, url=:{url} ,headers=:{headers}, params=:{params}" .format (
7439+ url = url ,
7440+ headers = headers ,
7441+ params = params ))
7442+ rt = self .send_request (
7443+ method = 'DELETE' ,
7444+ url = url ,
7445+ auth = CosS3Auth (self ._conf , path , params = params ),
7446+ params = params ,
7447+ headers = headers ,
7448+ ci_request = True )
7449+
7450+ data = rt .content
7451+ response = dict (** rt .headers )
7452+ if 'Content-Type' in response :
7453+ if response ['Content-Type' ] == 'application/xml' and 'Content-Length' in response and \
7454+ response ['Content-Length' ] != 0 :
7455+ data = xml_to_dict (rt .content )
7456+ format_dict (data , ['Response' ])
7457+ elif response ['Content-Type' ].startswith ('application/json' ):
7458+ data = rt .json ()
7459+
7460+ return response , data
7461+
73487462 def ci_update_media_pic_queue (self , Bucket , QueueId , Request = {}, ** kwargs ):
73497463 """ 更新图片处理队列接口
73507464
0 commit comments