class GenericRestClient(object): def __init__(self, credentials, subscription_id, base_url=None): self.config = GenericRestClientConfiguration(credentials, subscription_id, base_url) self._client = ServiceClient(self.config.credentials, self.config) self.models = None def query(self, url, method, query_parameters, header_parameters, body, expected_status_codes, polling_timeout, polling_interval): # Construct and send request operation_config = {} request = None if header_parameters is None: header_parameters = {} header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if method == 'GET': request = self._client.get(url, query_parameters) elif method == 'PUT': request = self._client.put(url, query_parameters) elif method == 'POST': request = self._client.post(url, query_parameters) elif method == 'HEAD': request = self._client.head(url, query_parameters) elif method == 'PATCH': request = self._client.patch(url, query_parameters) elif method == 'DELETE': request = self._client.delete(url, query_parameters) elif method == 'MERGE': request = self._client.merge(url, query_parameters) response = self._client.send(request, header_parameters, body, **operation_config) if response.status_code not in expected_status_codes: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp elif response.status_code == 202 and polling_timeout > 0: def get_long_running_output(response): return response poller = LROPoller( self._client, ClientRawResponse(None, response), get_long_running_output, ARMPolling(polling_interval, **operation_config)) response = self.get_poller_result(poller, polling_timeout) return response def get_poller_result(self, poller, timeout): try: poller.wait(timeout=timeout) return poller.result() except Exception as exc: raise
class GenericRestClient(object): def __init__(self, credentials, subscription_id, base_url=None): self.config = GenericRestClientConfiguration(credentials, subscription_id, base_url) self._client = ServiceClient(self.config.credentials, self.config) self.models = None def query(self, url, method, query_parameters, header_parameters, body, expected_status_codes): # Construct and send request operation_config = {} request = None if method == 'GET': request = self._client.get(url, query_parameters) elif method == 'PUT': request = self._client.put(url, query_parameters) elif method == 'POST': request = self._client.post(url, query_parameters) elif method == 'HEAD': request = self._client.head(url, query_parameters) elif method == 'PATCH': request = self._client.patch(url, query_parameters) elif method == 'DELETE': request = self._client.delete(url, query_parameters) elif method == 'MERGE': request = self._client.merge(url, query_parameters) response = self._client.send(request, header_parameters, body, **operation_config) if response.status_code not in expected_status_codes: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp return response
def run_example(): credentials = get_credentials() config = AzureConfiguration('https://management.azure.com') service_client = ServiceClient(credentials, config) query_parameters = {} query_parameters['api-version'] = API_VERSION header_parameters = {} header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) operation_config = {} request = service_client.delete( "/subscriptions/" + SUBSCRIPTION_ID + "/resourceGroups/" + RESOURCE_GROUP + "/providers/Microsoft.Databricks/workspaces/" + WORKSPACE_NAME, query_parameters) response = service_client.send(request, header_parameters, BODY, **operation_config) # if response.status_code == 202: # response = wait_poller(service_client, operation_config, response) print(response.text)
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') 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 update_pet( self, body=None, custom_headers=None, raw=False, **operation_config): """Update an existing pet. :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') 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 [405, 404, 400]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def find_pets_by_status( self, status=None, custom_headers=None, raw=False, **operation_config): """Finds Pets by status. Multiple status values can be provided with comma seperated strings. :param status: Status values that need to be considered for filter :type status: list of 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: list of :class:`Pet <Petstore.models.Pet>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/pet/findByStatus' # Construct parameters query_parameters = {} if status is not None: query_parameters['status'] = self._serialize.query("status", status, '[str]', div=',') # 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, 400]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[Pet]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def find_pets_by_tags( self, tags=None, custom_headers=None, raw=False, **operation_config): """Finds Pets by tags. Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. :param tags: Tags to filter by :type tags: list of 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: list of :class:`Pet <Petstore.models.Pet>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/pet/findByTags' # Construct parameters query_parameters = {} if tags is not None: query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') # 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, 400]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[Pet]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def find_pets_with_byte_array( self, pet_id, custom_headers=None, raw=False, **operation_config): """Fake endpoint to test byte array return by 'Find pet by ID'. Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions. :param pet_id: ID of pet that needs to be fetched :type pet_id: long :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: str :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/pet/{petId}' path_format_arguments = { 'petId': self._serialize.url("pet_id", pet_id, 'long') } url = self._client.format_url(url, **path_format_arguments) # 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 [404, 200, 400]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('str', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def get_pet_by_id( self, pet_id, custom_headers=None, raw=False, **operation_config): """Find pet by ID. Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions. :param pet_id: ID of pet that needs to be fetched :type pet_id: long :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: :class:`Pet <Petstore.models.Pet>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/pet/{petId}' path_format_arguments = { 'petId': self._serialize.url("pet_id", pet_id, 'long') } url = self._client.format_url(url, **path_format_arguments) # 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 [404, 200, 400]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Pet', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def update_pet_with_form( self, pet_id, name=None, status=None, custom_headers=None, raw=False, **operation_config): """Updates a pet in the store with form data. :param pet_id: ID of pet that needs to be updated :type pet_id: str :param name: Updated name of the pet :type name: str :param status: Updated status of the pet :type status: 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/{petId}' path_format_arguments = { 'petId': self._serialize.url("pet_id", pet_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/x-www-form-urlencoded' if custom_headers: header_parameters.update(custom_headers) # Construct form data form_data_content = { 'name': name, 'status': status, } # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send_formdata( request, header_parameters, form_data_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 delete_pet( self, pet_id, api_key=None, custom_headers=None, raw=False, **operation_config): """Deletes a pet. :param pet_id: Pet id to delete :type pet_id: long :param api_key: :type api_key: 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/{petId}' path_format_arguments = { 'petId': self._serialize.url("pet_id", pet_id, 'long') } url = self._client.format_url(url, **path_format_arguments) # 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) if api_key is not None: header_parameters['api_key'] = self._serialize.header("api_key", api_key, 'str') # Construct and send request request = self._client.delete(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [400]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def upload_file( self, pet_id, additional_metadata=None, file=None, custom_headers=None, raw=False, **operation_config): """uploads an image. :param pet_id: ID of pet to update :type pet_id: long :param additional_metadata: Additional data to pass to server :type additional_metadata: str :param file: file to upload :type file: Generator :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/{petId}/uploadImage' path_format_arguments = { 'petId': self._serialize.url("pet_id", pet_id, 'long') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'multipart/form-data' if custom_headers: header_parameters.update(custom_headers) # Construct form data form_data_content = { 'additionalMetadata': additional_metadata, 'file': file, } # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send_formdata( request, header_parameters, form_data_content, **operation_config) if response.status_code < 200 or response.status_code >= 300: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_inventory( self, custom_headers=None, raw=False, **operation_config): """Returns pet inventories by status. Returns a map of status codes to quantities. :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: dict :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/store/inventory' # 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 HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('{int}', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def place_order( self, body=None, custom_headers=None, raw=False, **operation_config): """Place an order for a pet. :param body: order placed for purchasing the pet :type body: :class:`Order <Petstore.models.Order>` :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: :class:`Order <Petstore.models.Order>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/store/order' # 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, 'Order') 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 [200, 400]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Order', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def get_order_by_id( self, order_id, custom_headers=None, raw=False, **operation_config): """Find purchase order by ID. For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions. :param order_id: ID of pet that needs to be fetched :type order_id: 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: :class:`Order <Petstore.models.Order>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/store/order/{orderId}' path_format_arguments = { 'orderId': self._serialize.url("order_id", order_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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 [404, 200, 400]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Order', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def delete_order( self, order_id, custom_headers=None, raw=False, **operation_config): """Delete purchase order by ID. For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors. :param order_id: ID of the order that needs to be deleted :type order_id: 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 = '/store/order/{orderId}' path_format_arguments = { 'orderId': self._serialize.url("order_id", order_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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.delete(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [404, 400]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def create_user( self, body=None, custom_headers=None, raw=False, **operation_config): """Create user. This can only be done by the logged in user. :param body: Created user object :type body: :class:`User <Petstore.models.User>` :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 = '/user' # 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, 'User') 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 < 200 or response.status_code >= 300: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def create_users_with_array_input( self, body=None, custom_headers=None, raw=False, **operation_config): """Creates list of users with given input array. :param body: List of user object :type body: list of :class:`User <Petstore.models.User>` :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 = '/user/createWithArray' # 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, '[User]') 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 < 200 or response.status_code >= 300: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def create_users_with_list_input( self, body=None, custom_headers=None, raw=False, **operation_config): """Creates list of users with given input array. :param body: List of user object :type body: list of :class:`User <Petstore.models.User>` :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 = '/user/createWithList' # 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, '[User]') 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 < 200 or response.status_code >= 300: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def login_user( self, username=None, password=None, custom_headers=None, raw=False, **operation_config): """Logs user into the system. :param username: The user name for login :type username: str :param password: The password for login in clear text :type password: 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: str :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/user/login' # Construct parameters query_parameters = {} if username is not None: query_parameters['username'] = self._serialize.query("username", username, 'str') if password is not None: query_parameters['password'] = self._serialize.query("password", password, '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, 400]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('str', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def logout_user( self, custom_headers=None, raw=False, **operation_config): """Logs out current logged in user session. :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 = '/user/logout' # 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 < 200 or response.status_code >= 300: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_user_by_name( self, username, custom_headers=None, raw=False, **operation_config): """Get user by user name. :param username: The name that needs to be fetched. Use user1 for testing. :type username: 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: :class:`User <Petstore.models.User>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/user/{username}' path_format_arguments = { 'username': self._serialize.url("username", username, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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 [404, 200, 400]: raise HttpOperationError(self._deserialize, response) 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 update_user( self, username, body=None, custom_headers=None, raw=False, **operation_config): """Updated user. This can only be done by the logged in user. :param username: name that need to be deleted :type username: str :param body: Updated user object :type body: :class:`User <Petstore.models.User>` :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 = '/user/{username}' path_format_arguments = { 'username': self._serialize.url("username", username, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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, 'User') 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 [404, 400]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def delete_user( self, username, custom_headers=None, raw=False, **operation_config): """Delete user. This can only be done by the logged in user. :param username: The name that needs to be deleted :type username: 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 = '/user/{username}' path_format_arguments = { 'username': self._serialize.url("username", username, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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.delete(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [404, 400]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response
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 """ def __init__(self, base_url=None): self.config = SwaggerPetstoreConfiguration(base_url) 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 :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # 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 :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # 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') 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 update_pet(self, body=None, custom_headers=None, raw=False, **operation_config): """Update an existing pet. :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 :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # 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') 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 [405, 404, 400]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def find_pets_by_status(self, status=None, custom_headers=None, raw=False, **operation_config): """Finds Pets by status. Multiple status values can be provided with comma seperated strings. :param status: Status values that need to be considered for filter :type status: list of 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: list of :class:`Pet <petstore.models.Pet>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/pet/findByStatus' # Construct parameters query_parameters = {} if status is not None: query_parameters['status'] = self._serialize.query("status", status, '[str]', div=',') # 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, 400]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[Pet]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def find_pets_by_tags(self, tags=None, custom_headers=None, raw=False, **operation_config): """Finds Pets by tags. Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. :param tags: Tags to filter by :type tags: list of 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: list of :class:`Pet <petstore.models.Pet>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/pet/findByTags' # Construct parameters query_parameters = {} if tags is not None: query_parameters['tags'] = self._serialize.query("tags", tags, '[str]', div=',') # 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, 400]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[Pet]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def find_pets_with_byte_array(self, pet_id, custom_headers=None, raw=False, **operation_config): """Fake endpoint to test byte array return by 'Find pet by ID'. Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions. :param pet_id: ID of pet that needs to be fetched :type pet_id: long :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: str :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/pet/{petId}' path_format_arguments = { 'petId': self._serialize.url("pet_id", pet_id, 'long') } url = self._client.format_url(url, **path_format_arguments) # 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 [404, 200, 400]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('str', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def get_pet_by_id(self, pet_id, custom_headers=None, raw=False, **operation_config): """Find pet by ID. Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions. :param pet_id: ID of pet that needs to be fetched :type pet_id: long :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: :class:`Pet <petstore.models.Pet>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/pet/{petId}' path_format_arguments = { 'petId': self._serialize.url("pet_id", pet_id, 'long') } url = self._client.format_url(url, **path_format_arguments) # 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 [404, 200, 400]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Pet', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def update_pet_with_form(self, pet_id, name=None, status=None, custom_headers=None, raw=False, **operation_config): """Updates a pet in the store with form data. :param pet_id: ID of pet that needs to be updated :type pet_id: str :param name: Updated name of the pet :type name: str :param status: Updated status of the pet :type status: 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 :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/pet/{petId}' path_format_arguments = { 'petId': self._serialize.url("pet_id", pet_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/x-www-form-urlencoded' if custom_headers: header_parameters.update(custom_headers) # Construct form data form_data_content = { 'name': name, 'status': status, } # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send_formdata(request, header_parameters, form_data_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 delete_pet(self, pet_id, api_key=None, custom_headers=None, raw=False, **operation_config): """Deletes a pet. :param pet_id: Pet id to delete :type pet_id: long :param api_key: :type api_key: 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 :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/pet/{petId}' path_format_arguments = { 'petId': self._serialize.url("pet_id", pet_id, 'long') } url = self._client.format_url(url, **path_format_arguments) # 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) if api_key is not None: header_parameters['api_key'] = self._serialize.header( "api_key", api_key, 'str') # Construct and send request request = self._client.delete(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [400]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def upload_file(self, pet_id, additional_metadata=None, file=None, custom_headers=None, raw=False, **operation_config): """uploads an image. :param pet_id: ID of pet to update :type pet_id: long :param additional_metadata: Additional data to pass to server :type additional_metadata: str :param file: file to upload :type file: Generator :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:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/pet/{petId}/uploadImage' path_format_arguments = { 'petId': self._serialize.url("pet_id", pet_id, 'long') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'multipart/form-data' if custom_headers: header_parameters.update(custom_headers) # Construct form data form_data_content = { 'additionalMetadata': additional_metadata, 'file': file, } # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send_formdata(request, header_parameters, form_data_content, **operation_config) if response.status_code < 200 or response.status_code >= 300: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_inventory(self, custom_headers=None, raw=False, **operation_config): """Returns pet inventories by status. Returns a map of status codes to quantities. :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: dict :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/store/inventory' # 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 HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('{int}', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def place_order(self, body=None, custom_headers=None, raw=False, **operation_config): """Place an order for a pet. :param body: order placed for purchasing the pet :type body: :class:`Order <petstore.models.Order>` :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: :class:`Order <petstore.models.Order>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/store/order' # 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, 'Order') 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 [200, 400]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Order', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def get_order_by_id(self, order_id, custom_headers=None, raw=False, **operation_config): """Find purchase order by ID. For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions. :param order_id: ID of pet that needs to be fetched :type order_id: 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: :class:`Order <petstore.models.Order>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/store/order/{orderId}' path_format_arguments = { 'orderId': self._serialize.url("order_id", order_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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 [404, 200, 400]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Order', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def delete_order(self, order_id, custom_headers=None, raw=False, **operation_config): """Delete purchase order by ID. For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors. :param order_id: ID of the order that needs to be deleted :type order_id: 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 :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/store/order/{orderId}' path_format_arguments = { 'orderId': self._serialize.url("order_id", order_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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.delete(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [404, 400]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def create_user(self, body=None, custom_headers=None, raw=False, **operation_config): """Create user. This can only be done by the logged in user. :param body: Created user object :type body: :class:`User <petstore.models.User>` :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:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/user' # 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, 'User') 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 < 200 or response.status_code >= 300: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def create_users_with_array_input(self, body=None, custom_headers=None, raw=False, **operation_config): """Creates list of users with given input array. :param body: List of user object :type body: list of :class:`User <petstore.models.User>` :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:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/user/createWithArray' # 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, '[User]') 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 < 200 or response.status_code >= 300: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def create_users_with_list_input(self, body=None, custom_headers=None, raw=False, **operation_config): """Creates list of users with given input array. :param body: List of user object :type body: list of :class:`User <petstore.models.User>` :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:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/user/createWithList' # 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, '[User]') 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 < 200 or response.status_code >= 300: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def login_user(self, username=None, password=None, custom_headers=None, raw=False, **operation_config): """Logs user into the system. :param username: The user name for login :type username: str :param password: The password for login in clear text :type password: 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: str :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/user/login' # Construct parameters query_parameters = {} if username is not None: query_parameters['username'] = self._serialize.query( "username", username, 'str') if password is not None: query_parameters['password'] = self._serialize.query( "password", password, '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, 400]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('str', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def logout_user(self, custom_headers=None, raw=False, **operation_config): """Logs out current logged in user session. :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:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/user/logout' # 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 < 200 or response.status_code >= 300: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_user_by_name(self, username, custom_headers=None, raw=False, **operation_config): """Get user by user name. :param username: The name that needs to be fetched. Use user1 for testing. :type username: 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: :class:`User <petstore.models.User>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/user/{username}' path_format_arguments = { 'username': self._serialize.url("username", username, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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 [404, 200, 400]: raise HttpOperationError(self._deserialize, response) 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 update_user(self, username, body=None, custom_headers=None, raw=False, **operation_config): """Updated user. This can only be done by the logged in user. :param username: name that need to be deleted :type username: str :param body: Updated user object :type body: :class:`User <petstore.models.User>` :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:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/user/{username}' path_format_arguments = { 'username': self._serialize.url("username", username, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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, 'User') 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 [404, 400]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def delete_user(self, username, custom_headers=None, raw=False, **operation_config): """Delete user. This can only be done by the logged in user. :param username: The name that needs to be deleted :type username: 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 :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/user/{username}' path_format_arguments = { 'username': self._serialize.url("username", username, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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.delete(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [404, 400]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response
class DigitalTwinRepositoryProvisioningService(object): """DigitalTwin Repository Control Plane Service. Provisions Repository and Access keys to a repository. :ivar config: Configuration for client. :vartype config: DigitalTwinRepositoryProvisioningServiceConfiguration :param str base_url: Service URL """ def __init__(self, base_url=None): self.config = DigitalTwinRepositoryProvisioningServiceConfiguration( 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 = '2019-07-01-Preview' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) def get_keys_async(self, repository_id, api_version, custom_headers=None, raw=False, **operation_config): """Gets all the keys associated to a repository. Connection String format: HostName=repository svc endpoint;RepositoryId=repository id(GUID);SharedAccessKeyName =access key id/name;SharedAccessKey=shared access key;. :param repository_id: Repository id :type repository_id: str :param api_version: API version. :type api_version: 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>`. :return: list or ClientRawResponse if raw=true :rtype: list[~digitaltwinrepositoryprovisioningservice.models.KeyMetadata] or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_keys_async.metadata['url'] path_format_arguments = { 'repositoryId': self._serialize.url("repository_id", repository_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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 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, stream=False, **operation_config) if response.status_code not in [200]: raise CloudError(response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[KeyMetadata]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_keys_async.metadata = {'url': '/repositories/{repositoryId}/authKeys'} def create_or_update_key_async(self, repository_id, api_version, properties=None, custom_headers=None, raw=False, **operation_config): """Creates or updates a key for the given repository. If Id present in the RepositoryKeyRequest's properties, it will update the key with new key. Otherwise return a new key. :param repository_id: Repository id :type repository_id: str :param api_version: API version. :type api_version: str :param properties: :type properties: ~digitaltwinrepositoryprovisioningservice.models.RepositoryKeyRequestProperties :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: KeyMetadata or ClientRawResponse if raw=true :rtype: ~digitaltwinrepositoryprovisioningservice.models.KeyMetadata or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ repository_key_request = None if properties is not None: repository_key_request = models.RepositoryKeyRequest( properties=properties) # Construct URL url = self.create_or_update_key_async.metadata['url'] path_format_arguments = { 'repositoryId': self._serialize.url("repository_id", repository_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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-patch+json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body if repository_key_request is not None: body_content = self._serialize.body(repository_key_request, 'RepositoryKeyRequest') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send(request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200, 404]: raise CloudError(response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('KeyMetadata', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized create_or_update_key_async.metadata = { 'url': '/repositories/{repositoryId}/authKeys' } def get_key_async(self, repository_id, id, api_version, custom_headers=None, raw=False, **operation_config): """Gets a key metadata information for the given key. Connection String format: HostName=repository svc endpoint;RepositoryId=repository id(GUID);SharedAccessKeyName =access key id/name;SharedAccessKey=shared access key;. :param repository_id: Repository Id :type repository_id: str :param id: Key Id. :type id: str :param api_version: API version. :type api_version: 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>`. :return: KeyMetadata or ClientRawResponse if raw=true :rtype: ~digitaltwinrepositoryprovisioningservice.models.KeyMetadata or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_key_async.metadata['url'] path_format_arguments = { 'repositoryId': self._serialize.url("repository_id", repository_id, 'str'), 'id': self._serialize.url("id", id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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 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, stream=False, **operation_config) if response.status_code not in [200, 404]: raise CloudError(response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('KeyMetadata', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_key_async.metadata = { 'url': '/repositories/{repositoryId}/authKeys/{id}' } def delete_key_async(self, id, repository_id, api_version, custom_headers=None, raw=False, **operation_config): """Deletes a key from the given repository. :param id: Key id. :type id: str :param repository_id: Repository id. :type repository_id: str :param api_version: API version. :type api_version: 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>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.delete_key_async.metadata['url'] path_format_arguments = { 'id': self._serialize.url("id", id, 'str'), 'repositoryId': self._serialize.url("repository_id", repository_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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 custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.delete(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [204]: raise CloudError(response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response delete_key_async.metadata = { 'url': '/repositories/{repositoryId}/authKeys/{id}' } def get_repositories_async(self, api_version, custom_headers=None, raw=False, **operation_config): """Gets all the repositories metadata belong to the user's tenant. :param api_version: API version. :type api_version: 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>`. :return: list or ClientRawResponse if raw=true :rtype: list[~digitaltwinrepositoryprovisioningservice.models.RepositoryMetadata] or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_repositories_async.metadata['url'] # 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 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, stream=False, **operation_config) if response.status_code not in [200]: raise CloudError(response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[RepositoryMetadata]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_repositories_async.metadata = {'url': '/repositories'} def create_or_update_repository_async(self, api_version, properties=None, custom_headers=None, raw=False, **operation_config): """Create or updates a repository. If Id is present in the RepositoryRequest properties object, service tries to update the repository. otherwise it will try to create repository. :param api_version: API version. :type api_version: str :param properties: :type properties: ~digitaltwinrepositoryprovisioningservice.models.RepositoryUpsertRequestProperties :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: RepositoryProvisionResponseBase or ClientRawResponse if raw=true :rtype: ~digitaltwinrepositoryprovisioningservice.models.RepositoryProvisionResponseBase or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ repository_upsert_request = None if properties is not None: repository_upsert_request = models.RepositoryUpsertRequest( properties=properties) # Construct URL url = self.create_or_update_repository_async.metadata['url'] # 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-patch+json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body if repository_upsert_request is not None: body_content = self._serialize.body(repository_upsert_request, 'RepositoryUpsertRequest') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send(request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200]: raise CloudError(response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('RepositoryProvisionResponseBase', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized create_or_update_repository_async.metadata = {'url': '/repositories'} def get_repository_async(self, repository_id, api_version, custom_headers=None, raw=False, **operation_config): """Gets the repository metadata for the given repository id. :param repository_id: Repository Id. :type repository_id: str :param api_version: API version. :type api_version: 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>`. :return: RepositoryMetadata or ClientRawResponse if raw=true :rtype: ~digitaltwinrepositoryprovisioningservice.models.RepositoryMetadata or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_repository_async.metadata['url'] path_format_arguments = { 'repositoryId': self._serialize.url("repository_id", repository_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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 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, stream=False, **operation_config) if response.status_code not in [200]: raise CloudError(response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('RepositoryMetadata', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_repository_async.metadata = {'url': '/repositories/{repositoryId}'} def delete_repository_async(self, repository_id, api_version, custom_headers=None, raw=False, **operation_config): """Deletes the repository for given id. :param repository_id: Repository Id :type repository_id: str :param api_version: API version. :type api_version: 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>`. :return: RepositoryProvisionResponseBase or ClientRawResponse if raw=true :rtype: ~digitaltwinrepositoryprovisioningservice.models.RepositoryProvisionResponseBase or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.delete_repository_async.metadata['url'] path_format_arguments = { 'repositoryId': self._serialize.url("repository_id", repository_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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 custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.delete(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise CloudError(response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('RepositoryProvisionResponseBase', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized delete_repository_async.metadata = {'url': '/repositories/{repositoryId}'} def get_provision_status(self, repository_id, tracking_id, api_version, custom_headers=None, raw=False, **operation_config): """Returns the repository provisioning status. :param repository_id: Repository id. :type repository_id: str :param tracking_id: Tracking id (provisioningState) :type tracking_id: str :param api_version: API version. :type api_version: 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>`. :return: RepositoryProvisionResponseBase or ClientRawResponse if raw=true :rtype: ~digitaltwinrepositoryprovisioningservice.models.RepositoryProvisionResponseBase or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_provision_status.metadata['url'] path_format_arguments = { 'repositoryId': self._serialize.url("repository_id", repository_id, 'str'), 'trackingId': self._serialize.url("tracking_id", tracking_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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 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, stream=False, **operation_config) if response.status_code not in [200, 404]: raise CloudError(response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('RepositoryProvisionResponseBase', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_provision_status.metadata = { 'url': '/repositories/{repositoryId}/status/{trackingId}' }
class CiqsApi(object): """Deployment service backend for solutions on quickstart.azure.ai :ivar config: Configuration for client. :vartype config: CiqsApiConfiguration :param str base_url: Service URL """ def __init__(self, creds=None, base_url=None): self.config = CiqsApiConfiguration(base_url) self._client = ServiceClient(creds, self.config) client_models = { k: v for k, v in models.__dict__.items() if isinstance(v, type) } self.api_version = 'Build_air_cloudai_machinelearning_cloudintelligencequickstart' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) def get_api_gallery(self, solution_storage_connection_string=None, category=None, partnername=None, owneremail=None, custom_headers=None, raw=False, **operation_config): """Get Gallery for current user. :param solution_storage_connection_string: A connection string for a private storage account. :type solution_storage_connection_string: str :param category: Category. :type category: str :param partnername: Partner Name. :type partnername: str :param owneremail: Owner Email. :type owneremail: 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>`. :return: list or ClientRawResponse if raw=true :rtype: list[~microsoft.swagger.codegen.cloudintelligencequickstart.models.MicrosoftCiqsModelsGalleryTemplate] or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_api_gallery.metadata['url'] # Construct parameters query_parameters = {} if category is not None: query_parameters['category'] = self._serialize.query( "category", category, 'str') if partnername is not None: query_parameters['partnername'] = self._serialize.query( "partnername", partnername, 'str') if owneremail is not None: query_parameters['owneremail'] = self._serialize.query( "owneremail", owneremail, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) if solution_storage_connection_string is not None: header_parameters[ 'SolutionStorageConnectionString'] = self._serialize.header( "solution_storage_connection_string", solution_storage_connection_string, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize( '[MicrosoftCiqsModelsGalleryTemplate]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_api_gallery.metadata = {'url': '/api/gallery'} def get_api_gallery_by_template_id(self, template_id, solution_storage_connection_string=None, custom_headers=None, raw=False, **operation_config): """Gets detailed information about a solution template. This includes: - Solution metadata such as splash image, decsription, and owners. - List of provisioning steps and deployments. :param template_id: Id of the solution template. :type template_id: str :param solution_storage_connection_string: A connection string for a private storage account. :type solution_storage_connection_string: 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>`. :return: MicrosoftCiqsModelsGalleryTemplate or ClientRawResponse if raw=true :rtype: ~microsoft.swagger.codegen.cloudintelligencequickstart.models.MicrosoftCiqsModelsGalleryTemplate or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_api_gallery_by_template_id.metadata['url'] path_format_arguments = { 'templateId': self._serialize.url("template_id", template_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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) if solution_storage_connection_string is not None: header_parameters[ 'SolutionStorageConnectionString'] = self._serialize.header( "solution_storage_connection_string", solution_storage_connection_string, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize( 'MicrosoftCiqsModelsGalleryTemplate', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_api_gallery_by_template_id.metadata = { 'url': '/api/gallery/{templateId}' } def get_api_deployments_by_subscription_id(self, subscription_id, custom_headers=None, raw=False, **operation_config): """Get a list of T:Microsoft.Ciqs.Models.Deployment.Deployment object representing deployments a user made within the provided subscription Id. :param subscription_id: Id of the subscription within which to query for existing deployments. :type subscription_id: 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>`. :return: list or ClientRawResponse if raw=true :rtype: list[~microsoft.swagger.codegen.cloudintelligencequickstart.models.MicrosoftCiqsModelsDeploymentDeployment] or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_api_deployments_by_subscription_id.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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, stream=False, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize( '[MicrosoftCiqsModelsDeploymentDeployment]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_api_deployments_by_subscription_id.metadata = { 'url': '/api/deployments/{subscriptionId}' } def post_api_deployments_by_subscription_id_by_template_id( self, subscription_id, template_id, body, ms_asm_refresh_token=None, custom_headers=None, raw=False, **operation_config): """Creates a new deployment of the requested solution template within the user's requested subscription and location. As part of creating a new deployment, this creates a resource group within the selected subscription of the same name as the deployment. The deployment is provisioned asynchronously so this API call will return before any T:Microsoft.Ciqs.Models.Deployment.DeploymentProvisioningStep has begun executing. Therefore, the list of provisioning steps, and provsioning logs will remain null until provisioning has begun. :param subscription_id: Id of the subscription within which to query for existing deployments. :type subscription_id: str :param template_id: Template Id. :type template_id: str :param body: :type body: ~microsoft.swagger.codegen.cloudintelligencequickstart.models.MicrosoftCiqsModelsDeploymentCreateDeploymentRequest :param ms_asm_refresh_token: The refresh token signed for a user in an Azure tenant. :type ms_asm_refresh_token: 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>`. :return: MicrosoftCiqsModelsDeploymentDeployment or ClientRawResponse if raw=true :rtype: ~microsoft.swagger.codegen.cloudintelligencequickstart.models.MicrosoftCiqsModelsDeploymentDeployment or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.post_api_deployments_by_subscription_id_by_template_id.metadata[ 'url'] path_format_arguments = { 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), 'templateId': self._serialize.url("template_id", template_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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) if ms_asm_refresh_token is not None: header_parameters['MS-AsmRefreshToken'] = self._serialize.header( "ms_asm_refresh_token", ms_asm_refresh_token, 'str') # Construct body body_content = self._serialize.body( body, 'MicrosoftCiqsModelsDeploymentCreateDeploymentRequest') # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send(request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize( 'MicrosoftCiqsModelsDeploymentDeployment', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized post_api_deployments_by_subscription_id_by_template_id.metadata = { 'url': '/api/deployments/{subscriptionId}/{templateId}' } def get_api_deployments_by_subscription_id_by_deployment_id( self, subscription_id, deployment_id, custom_headers=None, raw=False, **operation_config): """Get detailed information of a T:Microsoft.Ciqs.Models.Deployment.Deployment represented by the T:Microsoft.Ciqs.Models.Deployment.DeploymentDetails object. This details object contains information for each T:Microsoft.Ciqs.Models.Deployment.DeploymentProvisioningStep within the deployment. :param subscription_id: Id of the subscription within which to query for existing deployments. :type subscription_id: str :param deployment_id: A unique Id assigned to a deployment when it was created. :type deployment_id: 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>`. :return: MicrosoftCiqsModelsDeploymentDeploymentDetails or ClientRawResponse if raw=true :rtype: ~microsoft.swagger.codegen.cloudintelligencequickstart.models.MicrosoftCiqsModelsDeploymentDeploymentDetails or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_api_deployments_by_subscription_id_by_deployment_id.metadata[ 'url'] path_format_arguments = { 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), 'deploymentId': self._serialize.url("deployment_id", deployment_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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, stream=False, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize( 'MicrosoftCiqsModelsDeploymentDeploymentDetails', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_api_deployments_by_subscription_id_by_deployment_id.metadata = { 'url': '/api/deployments/{subscriptionId}/{deploymentId}' } def put_api_deployments_by_subscription_id_by_deployment_id( self, subscription_id, deployment_id, body, ms_asm_refresh_token=None, custom_headers=None, raw=False, **operation_config): """Resumes an already provisioning deployment. This can also be used to retry an existing step if it has failed. If the parameters provided are invalid, then the response status code will be 400 and the response will contain and error code from T:Microsoft.Ciqs.Models.ErrorCodes. If the provisioning step fails asynchronously due to a dependency after the provisioning had resumed, the details of the error will be available via the deployment details API. :param subscription_id: Id of the subscription within which to query for existing deployments. :type subscription_id: str :param deployment_id: A unique Id assigned to a deployment when it was created. :type deployment_id: str :param body: :type body: dict[str, str] :param ms_asm_refresh_token: The refresh token signed for a user in an Azure tenant. :type ms_asm_refresh_token: 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>`. :return: MicrosoftCiqsApiModelsExecuteProvisioningStepResponse or ClientRawResponse if raw=true :rtype: ~microsoft.swagger.codegen.cloudintelligencequickstart.models.MicrosoftCiqsApiModelsExecuteProvisioningStepResponse or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.put_api_deployments_by_subscription_id_by_deployment_id.metadata[ 'url'] path_format_arguments = { 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), 'deploymentId': self._serialize.url("deployment_id", deployment_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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) if ms_asm_refresh_token is not None: header_parameters['MS-AsmRefreshToken'] = self._serialize.header( "ms_asm_refresh_token", ms_asm_refresh_token, 'str') # Construct body body_content = json.dumps(body) # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send(request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize( 'MicrosoftCiqsApiModelsExecuteProvisioningStepResponse', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized put_api_deployments_by_subscription_id_by_deployment_id.metadata = { 'url': '/api/deployments/{subscriptionId}/{deploymentId}' } def delete_api_deployments_by_subscription_id_by_deployment_id( self, subscription_id, deployment_id, custom_headers=None, raw=False, **operation_config): """Initiates the deletion of a deployment. This essentially removes the resource group that was created when the deployment was done. Note: Any changes made to the resources post deployment will also be lost because all resources within the provisioning resource group will be deleted. If the deletion fails, the deplyoment details response will contain the details. :param subscription_id: Id of the subscription within which the deployment was done. :type subscription_id: str :param deployment_id: A unique Id assigned to a deployment when it was created. :type deployment_id: 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>`. :return: MicrosoftCiqsApiModelsDeleteDeploymentResult or ClientRawResponse if raw=true :rtype: ~microsoft.swagger.codegen.cloudintelligencequickstart.models.MicrosoftCiqsApiModelsDeleteDeploymentResult or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.delete_api_deployments_by_subscription_id_by_deployment_id.metadata[ 'url'] path_format_arguments = { 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str'), 'deploymentId': self._serialize.url("deployment_id", deployment_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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.delete(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize( 'MicrosoftCiqsApiModelsDeleteDeploymentResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized delete_api_deployments_by_subscription_id_by_deployment_id.metadata = { 'url': '/api/deployments/{subscriptionId}/{deploymentId}' } def get_api_locations_by_subscription_id_by_template_id( self, template_id, subscription_id, solution_storage_connection_string=None, custom_headers=None, raw=False, **operation_config): """Returns valid locations for a specific subscription and a template. It does so by validating availability of resources required by a solution template's ARM deployments and user's quota and picking the lowest common denominators. :param template_id: Id of the solution template for which the locations should be fetched. :type template_id: str :param subscription_id: The subscription the user intends to deploy the template into. :type subscription_id: str :param solution_storage_connection_string: A connection string for a private storage account. :type solution_storage_connection_string: 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>`. :return: list or ClientRawResponse if raw=true :rtype: list[str] or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_api_locations_by_subscription_id_by_template_id.metadata[ 'url'] path_format_arguments = { 'templateId': self._serialize.url("template_id", template_id, 'str'), 'subscriptionId': self._serialize.url("subscription_id", subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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) if solution_storage_connection_string is not None: header_parameters[ 'SolutionStorageConnectionString'] = self._serialize.header( "solution_storage_connection_string", solution_storage_connection_string, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[str]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_api_locations_by_subscription_id_by_template_id.metadata = { 'url': '/api/locations/{subscriptionId}/{templateId}' }
class IotHubGatewayDeviceAPIs(object): """IotHubGatewayDeviceAPIs :ivar config: Configuration for client. :vartype config: IotHubGatewayDeviceAPIsConfiguration :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object<msrestazure.azure_active_directory>` :param str base_url: Service URL """ def __init__(self, credentials, base_url=None): self.config = IotHubGatewayDeviceAPIsConfiguration( credentials, base_url) self._client = ServiceClient(self.config.credentials, self.config) client_models = { k: v for k, v in models.__dict__.items() if isinstance(v, type) } self.api_version = BASE_API_VERSION self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) # @digimaun - Altered to support request body parameter of object def send_device_event(self, id, message, custom_headers=None, raw=False, **operation_config): """Send a device-to-cloud message. :param id: Device ID. :type id: 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>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ # Construct URL url = self.send_device_event.metadata['url'] path_format_arguments = {'id': self._serialize.url("id", id, 'str')} url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query( "self.api_version", self.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(message, 'object') # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send(request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [204]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response send_device_event.metadata = {'url': '/devices/{id}/messages/events'} def receive_device_bound_notification(self, id, custom_headers=None, raw=False, **operation_config): """This method is used to retrieve a cloud-to-device message. :param id: Device ID. :type id: 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>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ # Construct URL url = self.receive_device_bound_notification.metadata['url'] path_format_arguments = {'id': self._serialize.url("id", id, 'str')} url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query( "self.api_version", self.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 and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200, 204]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp # @digimaun - Altered to support msg headers header_dict = {} if response.status_code == 200: header_dict = { 'ETag': 'str', 'iothub-sequencenumber': 'str', 'iothub-enqueuedtime': 'str', 'iothub-expiry': 'str', 'iothub-deliverycount': 'str', 'iothub-messageid': 'str', 'iothub-correlationid': 'str', 'iothub-userid': 'str', 'iothub-to': 'str', 'iothub-ack': 'str', 'Content-Type': 'str', 'Content-Encoding': 'str', } if raw: client_raw_response = ClientRawResponse(None, response) client_raw_response.add_headers(header_dict) return client_raw_response receive_device_bound_notification.metadata = { 'url': '/devices/{id}/messages/deviceBound' } def abandon_device_bound_notification(self, id, etag, custom_headers=None, raw=False, **operation_config): """This method abandons a cloud-to-device message. :param id: Device ID. :type id: str :param etag: :type etag: 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>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ # Construct URL url = self.abandon_device_bound_notification.metadata['url'] path_format_arguments = { 'id': self._serialize.url("id", id, 'str'), 'etag': self._serialize.url("etag", etag, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query( "self.api_version", self.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 and send request request = self._client.post(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [204]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response abandon_device_bound_notification.metadata = { 'url': '/devices/{id}/messages/deviceBound/{etag}/abandon' } def create_file_upload_sas_uri(self, device_id, file_upload_request, custom_headers=None, raw=False, **operation_config): """This method is used to retrieve a storage SAS URI to upload a file. :param device_id: Device ID. :type device_id: str :param file_upload_request: File upload request object. :type file_upload_request: ~device.models.FileUploadRequest :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: FileUploadResponse or ClientRawResponse if raw=true :rtype: ~device.models.FileUploadResponse or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ # Construct URL url = self.create_file_upload_sas_uri.metadata['url'] path_format_arguments = { 'deviceId': self._serialize.url("device_id", device_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query( "self.api_version", self.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(file_upload_request, 'FileUploadRequest') # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send(request, header_parameters, body_content, stream=False, **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('FileUploadResponse', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized create_file_upload_sas_uri.metadata = {'url': '/devices/{deviceId}/files'} def update_file_upload_status(self, device_id, file_upload_completion_status, custom_headers=None, raw=False, **operation_config): """This method is used to notify an IoT hub of a completed file upload. :param device_id: Device ID. :type device_id: str :param file_upload_completion_status: File upload completion status object. :type file_upload_completion_status: ~device.models.FileUploadCompletionStatus :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: FileUploadCompletionStatus or ClientRawResponse if raw=true :rtype: ~device.models.FileUploadCompletionStatus or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ # Construct URL url = self.update_file_upload_status.metadata['url'] path_format_arguments = { 'deviceId': self._serialize.url("device_id", device_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query( "self.api_version", self.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(file_upload_completion_status, 'FileUploadCompletionStatus') # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send(request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [204]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp deserialized = None if response.status_code == 204: deserialized = self._deserialize('FileUploadCompletionStatus', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized update_file_upload_status.metadata = { 'url': '/devices/{deviceId}/files/notifications' } def send_device_command(self, custom_headers=None, raw=False, **operation_config): """ :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: object or ClientRawResponse if raw=true :rtype: object or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ # Construct URL url = self.send_device_command.metadata['url'] # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query( "self.api_version", self.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 and send request request = self._client.post(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **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('object', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized send_device_command.metadata = {'url': '/messages/deviceBound'} # @digimaun - Altered to support reject via query param def complete_or_reject_device_bound_notification(self, id, etag, reject=None, custom_headers=None, raw=False, **operation_config): """This method completes or rejects a cloud-to-device message. :param id: Device ID. :type id: str :param etag: :type etag: 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>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ # Construct URL url = self.complete_or_reject_device_bound_notification.metadata['url'] path_format_arguments = { 'id': self._serialize.url("id", id, 'str'), 'etag': self._serialize.url("etag", etag, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query( "self.api_version", self.api_version, 'str') if reject is not None: query_parameters['reject'] = self._serialize.query( "reject", reject, '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 and send request request = self._client.delete(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [204]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response complete_or_reject_device_bound_notification.metadata = { 'url': '/devices/{id}/messages/deviceBound/{etag}' }
class AzureOpcPublisherClient(object): """Azure Industrial IoT OPC UA Publisher Service :ivar config: Configuration for client. :vartype config: AzureOpcPublisherClientConfiguration :param credentials: Subscription credentials which uniquely identify client subscription. :type credentials: None :param str base_url: Service URL """ def __init__(self, credentials, base_url=None): self.config = AzureOpcPublisherClientConfiguration( credentials, base_url) self._client = ServiceClient(self.config.credentials, self.config) client_models = { k: v for k, v in models.__dict__.items() if isinstance(v, type) } self.api_version = 'v2' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) def subscribe(self, endpoint_id, body=None, custom_headers=None, raw=False, **operation_config): """Subscribe to receive samples. Register a client to receive publisher samples through SignalR. :param endpoint_id: The endpoint to subscribe to :type endpoint_id: str :param body: The user id that will receive publisher samples. :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>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.subscribe.metadata['url'] path_format_arguments = { 'endpointId': self._serialize.url("endpoint_id", endpoint_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters[ 'Content-Type'] = 'application/json-patch+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.put(url, query_parameters) response = self._client.send(request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response subscribe.metadata = {'url': '/v2/monitor/{endpointId}/samples'} def unsubscribe(self, endpoint_id, user_id, custom_headers=None, raw=False, **operation_config): """Unsubscribe from receiving samples. Unregister a client and stop it from receiving samples. :param endpoint_id: The endpoint to unsubscribe from :type endpoint_id: str :param user_id: The user id that will not receive any more published samples :type user_id: 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>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.unsubscribe.metadata['url'] path_format_arguments = { 'endpointId': self._serialize.url("endpoint_id", endpoint_id, 'str'), 'userId': self._serialize.url("user_id", user_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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.delete(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response unsubscribe.metadata = {'url': '/v2/monitor/{endpointId}/samples/{userId}'} def start_publishing_values(self, endpoint_id, body, custom_headers=None, raw=False, **operation_config): """Start publishing node values. Start publishing variable node values to IoT Hub. The endpoint must be activated and connected and the module client and server must trust each other. :param endpoint_id: The identifier of the activated endpoint. :type endpoint_id: str :param body: The publish request :type body: ~azure-iiot-opc-publisher.models.PublishStartRequestApiModel :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: PublishStartResponseApiModel or ClientRawResponse if raw=true :rtype: ~azure-iiot-opc-publisher.models.PublishStartResponseApiModel or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.start_publishing_values.metadata['url'] path_format_arguments = { 'endpointId': self._serialize.url("endpoint_id", endpoint_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters[ 'Content-Type'] = 'application/json-patch+json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(body, 'PublishStartRequestApiModel') # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send(request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('PublishStartResponseApiModel', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized start_publishing_values.metadata = { 'url': '/v2/publish/{endpointId}/start' } def stop_publishing_values(self, endpoint_id, body, custom_headers=None, raw=False, **operation_config): """Stop publishing node values. Stop publishing variable node values to IoT Hub. The endpoint must be activated and connected and the module client and server must trust each other. :param endpoint_id: The identifier of the activated endpoint. :type endpoint_id: str :param body: The unpublish request :type body: ~azure-iiot-opc-publisher.models.PublishStopRequestApiModel :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: PublishStopResponseApiModel or ClientRawResponse if raw=true :rtype: ~azure-iiot-opc-publisher.models.PublishStopResponseApiModel or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.stop_publishing_values.metadata['url'] path_format_arguments = { 'endpointId': self._serialize.url("endpoint_id", endpoint_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters[ 'Content-Type'] = 'application/json-patch+json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(body, 'PublishStopRequestApiModel') # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send(request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('PublishStopResponseApiModel', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized stop_publishing_values.metadata = {'url': '/v2/publish/{endpointId}/stop'} def get_first_list_of_published_nodes(self, endpoint_id, body, custom_headers=None, raw=False, **operation_config): """Get currently published nodes. Returns currently published node ids for an endpoint. The endpoint must be activated and connected and the module client and server must trust each other. :param endpoint_id: The identifier of the activated endpoint. :type endpoint_id: str :param body: The list request :type body: ~azure-iiot-opc-publisher.models.PublishedItemListRequestApiModel :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: PublishedItemListResponseApiModel or ClientRawResponse if raw=true :rtype: ~azure-iiot-opc-publisher.models.PublishedItemListResponseApiModel or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_first_list_of_published_nodes.metadata['url'] path_format_arguments = { 'endpointId': self._serialize.url("endpoint_id", endpoint_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters[ 'Content-Type'] = 'application/json-patch+json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body( body, 'PublishedItemListRequestApiModel') # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send(request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize( 'PublishedItemListResponseApiModel', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_first_list_of_published_nodes.metadata = { 'url': '/v2/publish/{endpointId}' } def get_next_list_of_published_nodes(self, endpoint_id, continuation_token, custom_headers=None, raw=False, **operation_config): """Get next set of published nodes. Returns next set of currently published node ids for an endpoint. The endpoint must be activated and connected and the module client and server must trust each other. :param endpoint_id: The identifier of the activated endpoint. :type endpoint_id: str :param continuation_token: The continuation token to continue with :type continuation_token: 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>`. :return: PublishedItemListResponseApiModel or ClientRawResponse if raw=true :rtype: ~azure-iiot-opc-publisher.models.PublishedItemListResponseApiModel or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_next_list_of_published_nodes.metadata['url'] path_format_arguments = { 'endpointId': self._serialize.url("endpoint_id", endpoint_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['continuationToken'] = self._serialize.query( "continuation_token", continuation_token, '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, stream=False, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize( 'PublishedItemListResponseApiModel', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_next_list_of_published_nodes.metadata = { 'url': '/v2/publish/{endpointId}' }
class SoftheonSwitchboard(object): """SoftheonSwitchboard :ivar config: Configuration for client. :vartype config: SoftheonSwitchboardConfiguration :param str base_url: Service URL """ def __init__( self, base_url=None): self.config = SoftheonSwitchboardConfiguration(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' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) def get_board_by_id( self, id, custom_headers=None, raw=False, **operation_config): """Gets a board by the board id. :param id: The identifier. :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: BoardModel or ClientRawResponse if raw=true :rtype: ~swagger.models.BoardModel or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_board_by_id.metadata['url'] path_format_arguments = { 'id': self._serialize.url("id", id, 'int') } url = self._client.format_url(url, **path_format_arguments) # 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, stream=False, **operation_config) if response.status_code not in [200, 400, 401, 403]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('BoardModel', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_board_by_id.metadata = {'url': '/v1/Board/{id}'} def update_board( self, id, model=None, custom_headers=None, raw=False, **operation_config): """Puts the specified model. :param id: The identifier. :type id: int :param model: The model. :type model: ~swagger.models.BoardPutModel :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: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.update_board.metadata['url'] path_format_arguments = { 'id': self._serialize.url("id", id, 'int') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json-patch+json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body if model is not None: body_content = self._serialize.body(model, 'BoardPutModel') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [204, 400, 401, 403, 404]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response update_board.metadata = {'url': '/v1/Board/{id}'} def delete_board( self, id, custom_headers=None, raw=False, **operation_config): """Deletes the specified identifier. :param id: The identifier. :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: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.delete_board.metadata['url'] path_format_arguments = { 'id': self._serialize.url("id", id, 'int') } url = self._client.format_url(url, **path_format_arguments) # 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.delete(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [204, 400, 401, 403, 404]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response delete_board.metadata = {'url': '/v1/Board/{id}'} def get_all_boards( self, custom_headers=None, raw=False, **operation_config): """Gets all boards. :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: list or ClientRawResponse if raw=true :rtype: list[~swagger.models.BoardModel] or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_all_boards.metadata['url'] # 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, stream=False, **operation_config) if response.status_code not in [200, 400, 401, 403, 404]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[BoardModel]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_all_boards.metadata = {'url': '/v1/Board'} def create_board( self, model=None, custom_headers=None, raw=False, **operation_config): """Posts the specified model. :param model: The model. :type model: ~swagger.models.BoardPostModel :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: BoardModel or ClientRawResponse if raw=true :rtype: ~swagger.models.BoardModel or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.create_board.metadata['url'] # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json-patch+json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body if model is not None: body_content = self._serialize.body(model, 'BoardPostModel') else: body_content = None # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send( request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [201, 400, 401, 403]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 201: deserialized = self._deserialize('BoardModel', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized create_board.metadata = {'url': '/v1/Board'} def get_all_board_history_for_the_account( self, custom_headers=None, raw=False, **operation_config): """Gets all board history for account. :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: list or ClientRawResponse if raw=true :rtype: list[~swagger.models.BoardHistoryModel] or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_all_board_history_for_the_account.metadata['url'] # 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, stream=False, **operation_config) if response.status_code not in [200, 400, 401, 403, 404]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[BoardHistoryModel]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_all_board_history_for_the_account.metadata = {'url': '/v1/Board/History'} def get_board_history_by_id( self, id, custom_headers=None, raw=False, **operation_config): """Gets the board history. :param id: The identifier. :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: BoardHistoryModel or ClientRawResponse if raw=true :rtype: ~swagger.models.BoardHistoryModel or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_board_history_by_id.metadata['url'] path_format_arguments = { 'id': self._serialize.url("id", id, 'int') } url = self._client.format_url(url, **path_format_arguments) # 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, stream=False, **operation_config) if response.status_code not in [200, 400, 401, 403]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('BoardHistoryModel', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_board_history_by_id.metadata = {'url': '/v1/Board/History/{id}'} def get_boards_by_filter( self, model=None, custom_headers=None, raw=False, **operation_config): """Gets the boards by filter. :param model: The model. :type model: ~swagger.models.BoardFilterModel :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: list or ClientRawResponse if raw=true :rtype: list[~swagger.models.BoardModel] or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_boards_by_filter.metadata['url'] # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json-patch+json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body if model is not None: body_content = self._serialize.body(model, 'BoardFilterModel') else: body_content = None # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send( request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200, 401, 403]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[BoardModel]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_boards_by_filter.metadata = {'url': '/v1/Board/search'} def get_switches_by_board_id( self, board_id, custom_headers=None, raw=False, **operation_config): """Gets all switches associated with a specific board Id. :param board_id: The board identifier. :type board_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: list or ClientRawResponse if raw=true :rtype: list[~swagger.models.SwitchModel] or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_switches_by_board_id.metadata['url'] path_format_arguments = { 'boardId': self._serialize.url("board_id", board_id, 'int') } url = self._client.format_url(url, **path_format_arguments) # 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, stream=False, **operation_config) if response.status_code not in [200, 401, 403]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[SwitchModel]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_switches_by_board_id.metadata = {'url': '/v1/Board/{boardId}/Switch'} def create_switch( self, board_id, switch_post_model=None, custom_headers=None, raw=False, **operation_config): """Creates a new switch. :param board_id: The board identifier. :type board_id: int :param switch_post_model: The switch model. :type switch_post_model: ~swagger.models.SwitchPostModel :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: SwitchModel or ClientRawResponse if raw=true :rtype: ~swagger.models.SwitchModel or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.create_switch.metadata['url'] path_format_arguments = { 'boardId': self._serialize.url("board_id", board_id, 'int') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json-patch+json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body if switch_post_model is not None: body_content = self._serialize.body(switch_post_model, 'SwitchPostModel') else: body_content = None # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send( request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [201, 401, 403]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 201: deserialized = self._deserialize('SwitchModel', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized create_switch.metadata = {'url': '/v1/Board/{boardId}/Switch'} def get_switch( self, id, board_id, custom_headers=None, raw=False, **operation_config): """Gets a specific switch by the switch Id. :param id: The identifier. :type id: int :param board_id: :type board_id: 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>`. :return: SwitchModel or ClientRawResponse if raw=true :rtype: ~swagger.models.SwitchModel or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_switch.metadata['url'] path_format_arguments = { 'id': self._serialize.url("id", id, 'int'), 'boardId': self._serialize.url("board_id", board_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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, stream=False, **operation_config) if response.status_code not in [200, 401, 403, 404]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('SwitchModel', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_switch.metadata = {'url': '/v1/Board/{boardId}/Switch/{id}'} def update_switch( self, id, board_id, switch_put_model=None, custom_headers=None, raw=False, **operation_config): """Updates the switch and places the old version in the history table. :param id: The identifier. :type id: int :param board_id: :type board_id: str :param switch_put_model: The switch model. :type switch_put_model: ~swagger.models.SwitchPutModel :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: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.update_switch.metadata['url'] path_format_arguments = { 'id': self._serialize.url("id", id, 'int'), 'boardId': self._serialize.url("board_id", board_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json-patch+json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body if switch_put_model is not None: body_content = self._serialize.body(switch_put_model, 'SwitchPutModel') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [204, 401, 403, 404]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response update_switch.metadata = {'url': '/v1/Board/{boardId}/Switch/{id}'} def delete_switch_version( self, id, board_id, custom_headers=None, raw=False, **operation_config): """Deletes a switch and place it in the history table. :param id: The identifier. :type id: int :param board_id: :type board_id: 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>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.delete_switch_version.metadata['url'] path_format_arguments = { 'id': self._serialize.url("id", id, 'int'), 'boardId': self._serialize.url("board_id", board_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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.delete(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [204, 401, 403, 404]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response delete_switch_version.metadata = {'url': '/v1/Board/{boardId}/Switch/{id}'} def get_switch_history( self, id, board_id, custom_headers=None, raw=False, **operation_config): """Gets a specific previous switch version. :param id: The identifier. :type id: int :param board_id: :type board_id: 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>`. :return: SwitchHistoryModel or ClientRawResponse if raw=true :rtype: ~swagger.models.SwitchHistoryModel or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_switch_history.metadata['url'] path_format_arguments = { 'id': self._serialize.url("id", id, 'int'), 'boardId': self._serialize.url("board_id", board_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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, stream=False, **operation_config) if response.status_code not in [200, 401, 403, 404]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('SwitchHistoryModel', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_switch_history.metadata = {'url': '/v1/Board/{boardId}/Switch/History/{id}'} def get_all_switch_history_by_board( self, board_id, custom_headers=None, raw=False, **operation_config): """Gets all of the previous switches for a board. :param board_id: The board identifier. :type board_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: list or ClientRawResponse if raw=true :rtype: list[~swagger.models.SwitchHistoryModel] or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_all_switch_history_by_board.metadata['url'] path_format_arguments = { 'boardId': self._serialize.url("board_id", board_id, 'int') } url = self._client.format_url(url, **path_format_arguments) # 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, stream=False, **operation_config) if response.status_code not in [200, 401, 403]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[SwitchHistoryModel]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_all_switch_history_by_board.metadata = {'url': '/v1/Board/{boardId}/Switch/History'} def get_all_switch_history_by_switch( self, switch_id, board_id, custom_headers=None, raw=False, **operation_config): """Gets all of the previous switches for a switch. :param switch_id: The switch identifier. :type switch_id: int :param board_id: :type board_id: 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>`. :return: list or ClientRawResponse if raw=true :rtype: list[~swagger.models.SwitchHistoryModel] or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_all_switch_history_by_switch.metadata['url'] path_format_arguments = { 'switchId': self._serialize.url("switch_id", switch_id, 'int'), 'boardId': self._serialize.url("board_id", board_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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, stream=False, **operation_config) if response.status_code not in [200, 401, 403]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[SwitchHistoryModel]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_all_switch_history_by_switch.metadata = {'url': '/v1/Board/{boardId}/Switch/{switchId}/History'} def get_switches_by_filter( self, board_id, model=None, custom_headers=None, raw=False, **operation_config): """Gets the users by filter. :param board_id: The board identifier. :type board_id: int :param model: The model. :type model: ~swagger.models.SwitchFilterModel :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: list or ClientRawResponse if raw=true :rtype: list[~swagger.models.SwitchModel] or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_switches_by_filter.metadata['url'] path_format_arguments = { 'boardId': self._serialize.url("board_id", board_id, 'int') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json-patch+json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body if model is not None: body_content = self._serialize.body(model, 'SwitchFilterModel') else: body_content = None # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send( request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [200, 401, 403]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[SwitchModel]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_switches_by_filter.metadata = {'url': '/v1/Board/{boardId}/Switch/search'} def rollback_switch( self, switch_id, switch_history_id, board_id, custom_headers=None, raw=False, **operation_config): """Rollback to a previous switch. :param switch_id: The switch identifier. :type switch_id: int :param switch_history_id: The switch history identifier. :type switch_history_id: int :param board_id: :type board_id: 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>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.rollback_switch.metadata['url'] path_format_arguments = { 'switchId': self._serialize.url("switch_id", switch_id, 'int'), 'switchHistoryId': self._serialize.url("switch_history_id", switch_history_id, 'int'), 'boardId': self._serialize.url("board_id", board_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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.put(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [204, 401, 403, 404]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response rollback_switch.metadata = {'url': '/v1/Board/{boardId}/Switch/{switchId}/history/{switchHistoryId}'}
class UsersUser(object): """UsersUser :ivar config: Configuration for client. :vartype config: UsersUserConfiguration :ivar users: Users operations :vartype users: users.operations.UsersOperations :param top: Show only the first n items :type top: int :param search: Search items by search phrases :type search: str :param str base_url: Service URL """ def __init__( self, top=None, search=None, base_url=None): self.config = UsersUserConfiguration(top, search, 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 = 'v1.0-Beta' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.users = UsersOperations( self._client, self.config, self._serialize, self._deserialize) def list_user( self, orderby=None, select=None, custom_headers=None, raw=False, **operation_config): """Get entities from users. :param orderby: Order items by property values :type orderby: list[str] :param select: Select properties to be returned :type select: list[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>`. :return: Pathsusersgetresponses200contentapplicationJsonschema or ClientRawResponse if raw=true :rtype: ~users.models.Pathsusersgetresponses200contentapplicationJsonschema or ~msrest.pipeline.ClientRawResponse :raises: :class:`OdataerrorException<users.models.OdataerrorException>` """ # Construct URL url = self.list_user.metadata['url'] # Construct parameters query_parameters = {} if self.config.top is not None: query_parameters['$top'] = self._serialize.query("self.config.top", self.config.top, 'int', minimum=0) if self.config.search is not None: query_parameters['$search'] = self._serialize.query("self.config.search", self.config.search, 'str') if orderby is not None: query_parameters['$orderby'] = self._serialize.query("orderby", orderby, '[str]', div=',', unique=True) if select is not None: query_parameters['$select'] = self._serialize.query("select", select, '[str]', div=',', unique=True) # 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, stream=False, **operation_config) if response.status_code not in [200]: raise models.OdataerrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Pathsusersgetresponses200contentapplicationJsonschema', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized list_user.metadata = {'url': '/users'} def create_user( self, body, custom_headers=None, raw=False, **operation_config): """Add new entity to users. :param body: New entity :type body: ~users.models.Microsoftgraphuser :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: Microsoftgraphuser or ClientRawResponse if raw=true :rtype: ~users.models.Microsoftgraphuser or ~msrest.pipeline.ClientRawResponse :raises: :class:`OdataerrorException<users.models.OdataerrorException>` """ # Construct URL url = self.create_user.metadata['url'] # 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 body_content = self._serialize.body(body, 'Microsoftgraphuser') # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send( request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [201]: raise models.OdataerrorException(self._deserialize, response) deserialized = None if response.status_code == 201: deserialized = self._deserialize('Microsoftgraphuser', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized create_user.metadata = {'url': '/users'} def get_user( self, user_id, select=None, custom_headers=None, raw=False, **operation_config): """Get entity from users by key. :param user_id: key: user-id of user :type user_id: str :param select: Select properties to be returned :type select: list[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>`. :return: Microsoftgraphuser or ClientRawResponse if raw=true :rtype: ~users.models.Microsoftgraphuser or ~msrest.pipeline.ClientRawResponse :raises: :class:`OdataerrorException<users.models.OdataerrorException>` """ # Construct URL url = self.get_user.metadata['url'] path_format_arguments = { 'user-id': self._serialize.url("user_id", user_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if select is not None: query_parameters['$select'] = self._serialize.query("select", select, '[str]', div=',', unique=True) # 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, stream=False, **operation_config) if response.status_code not in [200]: raise models.OdataerrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Microsoftgraphuser', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized get_user.metadata = {'url': '/users/{user-id}'} def update_user( self, body, user_id, custom_headers=None, raw=False, **operation_config): """Update entity in users. :param body: New property values :type body: ~users.models.Microsoftgraphuser :param user_id: key: user-id of user :type user_id: 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>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`OdataerrorException<users.models.OdataerrorException>` """ # Construct URL url = self.update_user.metadata['url'] path_format_arguments = { 'user-id': self._serialize.url("user_id", user_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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 body_content = self._serialize.body(body, 'Microsoftgraphuser') # Construct and send request request = self._client.patch(url, query_parameters) response = self._client.send( request, header_parameters, body_content, stream=False, **operation_config) if response.status_code not in [204]: raise models.OdataerrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response update_user.metadata = {'url': '/users/{user-id}'} def delete_user( self, user_id, if_match=None, custom_headers=None, raw=False, **operation_config): """Delete entity from users. :param user_id: key: user-id of user :type user_id: str :param if_match: ETag :type if_match: 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>`. :return: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`OdataerrorException<users.models.OdataerrorException>` """ # Construct URL url = self.delete_user.metadata['url'] path_format_arguments = { 'user-id': self._serialize.url("user_id", user_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # 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) if if_match is not None: header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') # Construct and send request request = self._client.delete(url, query_parameters) response = self._client.send(request, header_parameters, stream=False, **operation_config) if response.status_code not in [204]: raise models.OdataerrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response delete_user.metadata = {'url': '/users/{user-id}'}