本文整理汇总了Python中msrest.service_client.ServiceClient.put方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceClient.put方法的具体用法?Python ServiceClient.put怎么用?Python ServiceClient.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类msrest.service_client.ServiceClient
的用法示例。
在下文中一共展示了ServiceClient.put方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SwaggerPetstore
# 需要导入模块: from msrest.service_client import ServiceClient [as 别名]
# 或者: from msrest.service_client.ServiceClient import put [as 别名]
class SwaggerPetstore(object):
"""This is a sample server Petstore server. You can find out more about Swagger at <a href="http://swagger.io">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key "special-key" to test the authorization filters
:ivar config: Configuration for client.
:vartype config: SwaggerPetstoreConfiguration
:param str base_url: Service URL
:param str filepath: Existing config
"""
def __init__(
self, base_url=None, filepath=None):
self.config = SwaggerPetstoreConfiguration(base_url, filepath)
self._client = ServiceClient(None, self.config)
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
def add_pet_using_byte_array(
self, body=None, custom_headers=None, raw=False, **operation_config):
"""Fake endpoint to test byte array in body parameter for adding a new
pet to the store.
:param body: Pet object in the form of byte array
:type body: str
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:rtype: None
:rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
if raw=true
"""
# Construct URL
url = '/pet'
# Construct parameters
query_parameters = {}
# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if custom_headers:
header_parameters.update(custom_headers)
# Construct body
if body is not None:
body_content = self._serialize.body(body, 'str')
else:
body_content = None
# Construct and send request
request = self._client.post(url, query_parameters)
response = self._client.send(
request, header_parameters, body_content, **operation_config)
if response.status_code not in [405]:
raise HttpOperationError(self._deserialize, response)
if raw:
client_raw_response = ClientRawResponse(None, response)
return client_raw_response
def add_pet(
self, body=None, custom_headers=None, raw=False, **operation_config):
"""Add a new pet to the store.
Adds a new pet to the store. You may receive an HTTP invalid input if
your pet is invalid.
:param body: Pet object that needs to be added to the store
:type body: :class:`Pet <Petstore.models.Pet>`
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:rtype: None
:rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
if raw=true
"""
# Construct URL
url = '/pet'
# Construct parameters
query_parameters = {}
# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if custom_headers:
header_parameters.update(custom_headers)
# Construct body
if body is not None:
body_content = self._serialize.body(body, 'Pet')
#.........这里部分代码省略.........
示例2: AutoRestResourceFlatteningTestService
# 需要导入模块: from msrest.service_client import ServiceClient [as 别名]
# 或者: from msrest.service_client.ServiceClient import put [as 别名]
class AutoRestResourceFlatteningTestService(object):
"""Resource Flattening for AutoRest
:ivar config: Configuration for client.
:vartype config: AutoRestResourceFlatteningTestServiceConfiguration
:param credentials: Credentials needed for the client to connect to Azure.
:type credentials: :mod:`A msrestazure Credentials
object<msrestazure.azure_active_directory>`
:param accept_language: Gets or sets the preferred language for the
response.
:type accept_language: str
:param long_running_operation_retry_timeout: Gets or sets the retry
timeout in seconds for Long Running Operations. Default value is 30.
:type long_running_operation_retry_timeout: int
:param generate_client_request_id: When set to true a unique
x-ms-client-request-id value is generated and included in each request.
Default is true.
:type generate_client_request_id: bool
:param str base_url: Service URL
:param str filepath: Existing config
"""
def __init__(
self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None):
self.config = AutoRestResourceFlatteningTestServiceConfiguration(credentials, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath)
self._client = ServiceClient(self.config.credentials, self.config)
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
def put_array(
self, resource_array=None, custom_headers=None, raw=False, **operation_config):
"""Put External Resource as an Array.
:param resource_array: External Resource as an Array to put
:type resource_array: list of :class:`Resource
<fixtures.acceptancetestsazureresource.models.Resource>`
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:rtype: None
:rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
if raw=true
:raises:
:class:`ErrorException<fixtures.acceptancetestsazureresource.models.ErrorException>`
"""
# Construct URL
url = '/azure/resource-flatten/array'
# Construct parameters
query_parameters = {}
# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
header_parameters.update(custom_headers)
if self.config.accept_language is not None:
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
# Construct body
if resource_array is not None:
body_content = self._serialize.body(resource_array, '[Resource]')
else:
body_content = None
# Construct and send request
request = self._client.put(url, query_parameters)
response = self._client.send(
request, header_parameters, body_content, **operation_config)
if response.status_code not in [200]:
raise models.ErrorException(self._deserialize, response)
if raw:
client_raw_response = ClientRawResponse(None, response)
return client_raw_response
def get_array(
self, custom_headers=None, raw=False, **operation_config):
"""Get External Resource as an Array.
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:rtype: list of :class:`FlattenedProduct
<fixtures.acceptancetestsazureresource.models.FlattenedProduct>`
:rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
if raw=true
:raises:
#.........这里部分代码省略.........
示例3: AutoRestResourceFlatteningTestService
# 需要导入模块: from msrest.service_client import ServiceClient [as 别名]
# 或者: from msrest.service_client.ServiceClient import put [as 别名]
class AutoRestResourceFlatteningTestService(object):
"""Resource Flattening for AutoRest
:param config: Configuration for client.
:type config: AutoRestResourceFlatteningTestServiceConfiguration
"""
def __init__(self, config):
self._client = ServiceClient(None, config)
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer()
self._deserialize = Deserializer(client_models)
self.config = config
def put_array(
self, resource_array=None, custom_headers={}, raw=False, **operation_config):
"""
Put External Resource as an Array
:param resource_array: External Resource as an Array to put
:type resource_array: list of :class:`Resource
<fixtures.acceptancetestsmodelflattening.models.Resource>`
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:rtype: None
:rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
if raw=true
"""
# Construct URL
url = '/model-flatten/array'
# Construct parameters
query_parameters = {}
# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if custom_headers:
header_parameters.update(custom_headers)
# Construct body
if resource_array is not None:
body_content = self._serialize.body(resource_array, '[Resource]')
else:
body_content = None
# Construct and send request
request = self._client.put(url, query_parameters)
response = self._client.send(
request, header_parameters, body_content, **operation_config)
if response.status_code not in [200]:
raise models.ErrorException(self._deserialize, response)
if raw:
client_raw_response = ClientRawResponse(None, response)
return client_raw_response
def get_array(
self, custom_headers={}, raw=False, **operation_config):
"""
Get External Resource as an Array
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:rtype: list of :class:`FlattenedProduct
<fixtures.acceptancetestsmodelflattening.models.FlattenedProduct>`
:rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
if raw=true
"""
# Construct URL
url = '/model-flatten/array'
# Construct parameters
query_parameters = {}
# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if custom_headers:
header_parameters.update(custom_headers)
# Construct and send request
request = self._client.get(url, query_parameters)
response = self._client.send(request, header_parameters, **operation_config)
if response.status_code not in [200]:
raise models.ErrorException(self._deserialize, response)
deserialized = None
#.........这里部分代码省略.........
示例4: AutoRestValidationTest
# 需要导入模块: from msrest.service_client import ServiceClient [as 别名]
# 或者: from msrest.service_client.ServiceClient import put [as 别名]
class AutoRestValidationTest(object):
"""Test Infrastructure for AutoRest. No server backend exists for these tests.
:param config: Configuration for client.
:type config: AutoRestValidationTestConfiguration
"""
def __init__(self, config):
self._client = ServiceClient(None, config)
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer()
self._deserialize = Deserializer(client_models)
self.config = config
def validation_of_method_parameters(
self, resource_group_name, id, custom_headers={}, raw=False, **operation_config):
"""
Validates input parameters on the method. See swagger for details.
:param resource_group_name: Required string between 3 and 10 chars
with pattern [a-zA-Z0-9]+.
:type resource_group_name: str
:param id: Required int multiple of 10 from 100 to 1000.
:type id: int
:param dict custom_headers: headers that will be added to the request
:param boolean raw: returns the direct response alongside the
deserialized response
:rtype: Product or msrest.pipeline.ClientRawResponse
"""
# Construct URL
url = '/fakepath/{subscriptionId}/{resourceGroupName}/{id}'
path_format_arguments = {
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'id': self._serialize.url("id", id, 'int')
}
url = url.format(**path_format_arguments)
# Construct parameters
query_parameters = {}
query_parameters['apiVersion'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str')
# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if custom_headers:
header_parameters.update(custom_headers)
# Construct and send request
request = self._client.get(url, query_parameters)
response = self._client.send(request, header_parameters, **operation_config)
if response.status_code not in [200]:
raise models.ErrorException(self._deserialize, response)
deserialized = None
if response.status_code == 200:
deserialized = self._deserialize('Product', response)
if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response
return deserialized
def validation_of_body(
self, resource_group_name, id, body=None, custom_headers={}, raw=False, **operation_config):
"""
Validates body parameters on the method. See swagger for details.
:param resource_group_name: Required string between 3 and 10 chars
with pattern [a-zA-Z0-9]+.
:type resource_group_name: str
:param id: Required int multiple of 10 from 100 to 1000.
:type id: int
:param body:
:type body: Product or None
:param dict custom_headers: headers that will be added to the request
:param boolean raw: returns the direct response alongside the
deserialized response
:rtype: Product or msrest.pipeline.ClientRawResponse
"""
# Construct URL
url = '/fakepath/{subscriptionId}/{resourceGroupName}/{id}'
path_format_arguments = {
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'id': self._serialize.url("id", id, 'int')
}
url = url.format(**path_format_arguments)
# Construct parameters
query_parameters = {}
query_parameters['apiVersion'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str')
# Construct headers
#.........这里部分代码省略.........
示例5: AutoRestResourceFlatteningTestService
# 需要导入模块: from msrest.service_client import ServiceClient [as 别名]
# 或者: from msrest.service_client.ServiceClient import put [as 别名]
class AutoRestResourceFlatteningTestService(object):
"""Resource Flattening for AutoRest
:param config: Configuration for client.
:type config: AutoRestResourceFlatteningTestServiceConfiguration
"""
def __init__(self, config):
self._client = ServiceClient(config.credentials, config)
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer()
self._deserialize = Deserializer(client_models)
self.config = config
def put_array(
self, resource_array=None, custom_headers={}, raw=False, **operation_config):
"""
Put External Resource as an Array
:param resource_array: External Resource as an Array to put
:type resource_array: list or None
:param dict custom_headers: headers that will be added to the request
:param boolean raw: returns the direct response alongside the
deserialized response
:rtype: None or msrest.pipeline.ClientRawResponse
"""
# Construct URL
url = '/azure/resource-flatten/array'
# Construct parameters
query_parameters = {}
# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
header_parameters.update(custom_headers)
if self.config.accept_language is not None:
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
# Construct body
if resource_array is not None:
body_content = self._serialize.body(resource_array, '[Resource]')
else:
body_content = None
# Construct and send request
request = self._client.put(url, query_parameters)
response = self._client.send(
request, header_parameters, body_content, **operation_config)
if response.status_code not in [200]:
raise models.ErrorException(self._deserialize, response)
if raw:
client_raw_response = ClientRawResponse(None, response)
return client_raw_response
def get_array(
self, custom_headers={}, raw=False, **operation_config):
"""
Get External Resource as an Array
:param dict custom_headers: headers that will be added to the request
:param boolean raw: returns the direct response alongside the
deserialized response
:rtype: list or msrest.pipeline.ClientRawResponse
"""
# Construct URL
url = '/azure/resource-flatten/array'
# Construct parameters
query_parameters = {}
# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
header_parameters.update(custom_headers)
if self.config.accept_language is not None:
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
# Construct and send request
request = self._client.get(url, query_parameters)
response = self._client.send(request, header_parameters, **operation_config)
if response.status_code not in [200]:
raise models.ErrorException(self._deserialize, response)
deserialized = None
if response.status_code == 200:
deserialized = self._deserialize('[FlattenedProduct]', response)
#.........这里部分代码省略.........
示例6: AutoRestValidationTest
# 需要导入模块: from msrest.service_client import ServiceClient [as 别名]
# 或者: from msrest.service_client.ServiceClient import put [as 别名]
class AutoRestValidationTest(object):
"""Test Infrastructure for AutoRest. No server backend exists for these tests.
:ivar config: Configuration for client.
:vartype config: AutoRestValidationTestConfiguration
:param subscription_id: Subscription ID.
:type subscription_id: str
:param str base_url: Service URL
"""
def __init__(
self, subscription_id, base_url=None):
self.config = AutoRestValidationTestConfiguration(subscription_id, base_url)
self._client = ServiceClient(None, self.config)
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self.api_version = '1.0.0'
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
def validation_of_method_parameters(
self, resource_group_name, id, custom_headers=None, raw=False, **operation_config):
"""Validates input parameters on the method. See swagger for details.
:param resource_group_name: Required string between 3 and 10 chars
with pattern [a-zA-Z0-9]+.
:type resource_group_name: str
:param id: Required int multiple of 10 from 100 to 1000.
:type id: int
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:return: :class:`Product
<fixtures.acceptancetestsvalidation.models.Product>` or
:class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if
raw=true
:rtype: :class:`Product
<fixtures.acceptancetestsvalidation.models.Product>` or
:class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>`
:raises:
:class:`ErrorException<fixtures.acceptancetestsvalidation.models.ErrorException>`
"""
# Construct URL
url = '/fakepath/{subscriptionId}/{resourceGroupName}/{id}'
path_format_arguments = {
'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'),
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=10, min_length=3, pattern=r'[a-zA-Z0-9]+'),
'id': self._serialize.url("id", id, 'int', maximum=1000, minimum=100, multiple=10)
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {}
query_parameters['apiVersion'] = self._serialize.query("self.api_version", self.api_version, 'str', pattern=r'\d{2}-\d{2}-\d{4}')
# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if custom_headers:
header_parameters.update(custom_headers)
# Construct and send request
request = self._client.get(url, query_parameters)
response = self._client.send(request, header_parameters, **operation_config)
if response.status_code not in [200]:
raise models.ErrorException(self._deserialize, response)
deserialized = None
if response.status_code == 200:
deserialized = self._deserialize('Product', response)
if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response
return deserialized
def validation_of_body(
self, resource_group_name, id, body=None, custom_headers=None, raw=False, **operation_config):
"""Validates body parameters on the method. See swagger for details.
:param resource_group_name: Required string between 3 and 10 chars
with pattern [a-zA-Z0-9]+.
:type resource_group_name: str
:param id: Required int multiple of 10 from 100 to 1000.
:type id: int
:param body:
:type body: :class:`Product
<fixtures.acceptancetestsvalidation.models.Product>`
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
#.........这里部分代码省略.........
示例7: WebSiteManagementClient
# 需要导入模块: from msrest.service_client import ServiceClient [as 别名]
# 或者: from msrest.service_client.ServiceClient import put [as 别名]
#.........这里部分代码省略.........
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:return: User or ClientRawResponse if raw=true
:rtype: ~azure.mgmt.web.models.User or
~msrest.pipeline.ClientRawResponse
:raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>`
"""
api_version = "2016-03-01"
# Construct URL
url = '/providers/Microsoft.Web/publishingUsers/web'
# Construct parameters
query_parameters = {}
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
# Construct headers
header_parameters = {}
header_parameters['Content-Type'] = 'application/json; charset=utf-8'
if self.config.generate_client_request_id:
header_parameters['x-ms-client-request-id'] = str(uuid.uuid1())
if custom_headers:
header_parameters.update(custom_headers)
if self.config.accept_language is not None:
header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str')
# Construct body
body_content = self._serialize.body(user_details, 'User')
# Construct and send request
request = self._client.put(url, query_parameters)
response = self._client.send(
request, header_parameters, body_content, **operation_config)
if response.status_code not in [200]:
exp = CloudError(response)
exp.request_id = response.headers.get('x-ms-request-id')
raise exp
deserialized = None
if response.status_code == 200:
deserialized = self._deserialize('User', response)
if raw:
client_raw_response = ClientRawResponse(deserialized, response)
return client_raw_response
return deserialized
def list_source_controls(
self, custom_headers=None, raw=False, **operation_config):
"""Gets the source controls available for Azure websites.
Gets the source controls available for Azure websites.
:param dict custom_headers: headers that will be added to the request
:param bool raw: returns the direct response alongside the
deserialized response
:param operation_config: :ref:`Operation configuration
overrides<msrest:optionsforoperations>`.
:return: An iterator like instance of SourceControl
:rtype: