def get_no_model_error( self, custom_headers=None, raw=False, **operation_config): """Get empty error form server. :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: bool :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/http/failure/nomodel/error' # 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('bool', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def get_empty_child_element( self, custom_headers=None, raw=False, **operation_config): """Gets an XML document with an empty child element. :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: Banana or ClientRawResponse if raw=true :rtype: ~xmlservice.models.Banana or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_empty_child_element.metadata['url'] # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/xml' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters, header_parameters) response = self._client.send(request, 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('Banana', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
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
def get_service_version_metadata( self, custom_headers=None, raw=False, **operation_config): """version. :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: MetaApiVersionResponse or ClientRawResponse if raw=true :rtype: ~_restclient.models.MetaApiVersionResponse or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_service_version_metadata.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]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('MetaApiVersionResponse', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def greeting_using_get( self, custom_headers=None, raw=False, **operation_config): """greeting. :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: str or ClientRawResponse if raw=true :rtype: str or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.greeting_using_get.metadata['url'] # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters, header_parameters) response = self._client.send(request, 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('str', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
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
def set(self, value, custom_headers=None, raw=False, **operation_config): """Create or update FaultInjection entity. :param value: :type value: ~protocol.models.FaultInjectionProperties :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.set.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 custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(value, "FaultInjectionProperties") # Construct and send request request = self._client.put(url, query_parameters, header_parameters, body_content) response = self._client.send(request, 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
def get_with_constant_in_path( 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>`. :rtype: None :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ constant_param = "constant" # Construct URL url = '/validation/constantsInPath/{constantParam}/value' path_format_arguments = { 'constantParam': self._serialize.url("constant_param", constant_param, '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 [200]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response
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
def enable_methods( self, connection_id, custom_headers=None, raw=False, **operation_config): """Enable methods. :param connection_id: Id for the connection :type connection_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.enable_methods.metadata['url'] path_format_arguments = { 'connectionId': self._serialize.url("connection_id", connection_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 [200]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response
def log_message_method( self, log_message, custom_headers=None, raw=False, **operation_config): """log a message to output. :param log_message: :type log_message: ~e2erestapi.models.LogMessage :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.log_message_method.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(log_message, 'LogMessage') # 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
def put_empty_root_list( self, bananas, custom_headers=None, raw=False, **operation_config): """Puts an empty list as the root element. :param bananas: :type bananas: list[~xmlservice.models.Banana] :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.put_empty_root_list.metadata['url'] # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/xml; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body serialization_ctxt = {'xml': {'name': 'bananas', 'itemsName': 'bananas', 'wrapped': True}} body_content = self._serialize.body(bananas, '[Banana]', serialization_ctxt=serialization_ctxt) # Construct and send request request = self._client.put(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [201]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response
def set_flags( self, flags, custom_headers=None, raw=False, **operation_config): """set flags for the objects in this server to use. :param flags: :type flags: object :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.set_flags.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(flags, 'object') # 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
def list_projects(self): """Lists the current projects within an organization""" url = '/_apis/projects' # First pass without X-VSS-ForceMsaPassThrough header response = self._list_projects_request(url) if response.status_code == 203: # If return with Non-Authoritative Information, force MSA pass through response = self._list_projects_request(url, msa=True) deserialized = None if response.status_code // 100 != 2: logging.error("GET %s", request.url) logging.error("response: %s", response.status_code) logging.error(response.text) raise HttpOperationError(self._deserialize, response) else: deserialized = self._deserialize('Projects', response) return deserialized
def regions(self): # Construct URL url = '/_apis/hostacquisition/regions' # Construct and send request request = self._client.get(url) response = self._client.send(request) # Handle Response deserialized = None if response.status_code not in [200]: print("GET", request.url, file=stderr) print("response:", response.status_code, file=stderr) print(response.text, file=stderr) raise HttpOperationError(self._deserialize, response) else: deserialized = self._deserialize('Regions', response) return deserialized
def receive_feedback_notification(self, custom_headers=None, raw=False, **operation_config): """Gets the feedback for cloud-to-device messages. See https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging for more information. This capability is only available in the standard tier IoT Hub. For more information, see [Choose the right IoT Hub tier](https://aka.ms/scaleyouriotsolution). :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.receive_feedback_notification.metadata["url"] # Construct parameters query_parameters = {} query_parameters["api-version"] = self._serialize.query( "self.api_version", self.api_version, "str" ) # Construct headers header_parameters = {} if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200, 204]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response
def put_empty_wrapped_lists( self, apple_barrel, custom_headers=None, raw=False, **operation_config): """Puts some empty wrapped lists. :param apple_barrel: :type apple_barrel: ~xmlservice.models.AppleBarrel :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.put_empty_wrapped_lists.metadata['url'] # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/xml; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(apple_barrel, 'AppleBarrel') # Construct and send request request = self._client.put(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [201]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response
def put_complex_type_ref_no_meta( self, model, custom_headers=None, raw=False, **operation_config): """Puts a complex type that has a ref to a complex type with no XML node. :param model: :type model: ~xmlservice.models.RootWithRefAndNoMeta :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.put_complex_type_ref_no_meta.metadata['url'] # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/xml; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(model, 'RootWithRefAndNoMeta') # Construct and send request request = self._client.put(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [201]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response
def network_reconnect(self, custom_headers=None, raw=False, **operation_config): """Reconnect the network after a simulated network disconnection. :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.network_reconnect.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.put(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
def get_token( self, username, password, custom_headers=None, raw=False, **operation_config): """ Gets new auth token """ # Construct URL url = self.get_token.metadata['url'] # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' #header_parameters['Content-Type'] = 'application/x-www-form-urlencoded' if custom_headers: header_parameters.update(custom_headers) # Construct body #body_content = self._serialize.body("grant_type=password&username="******"&password="******"grant_type=password&username="******"&password="******"\'') response = self._client.send(request, 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('TokenModel', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def send_command(self, cmd, custom_headers=None, raw=False, **operation_config): """send an arbitrary command. :param cmd: command string :type cmd: 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.send_command.metadata['url'] # Construct parameters query_parameters = {} query_parameters['cmd'] = self._serialize.query("cmd", cmd, 'str') # Construct headers header_parameters = {} if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.put(url, query_parameters, header_parameters) response = self._client.send(request, 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
def get_user_id(self, msa=False): """Get the user id""" header_parameters = {} if msa: header_parameters['X-VSS-ForceMsaPassThrough'] = 'true' header_parameters['Accept'] = 'application/json' request = self._client.get('/_apis/AzureTfs/UserContext') response = self._client.send(request, header_parameters) # Handle Response deserialized = None if response.status_code // 100 != 2: logging.error("GET %s", request.url) logging.error("response: %s", response.status_code) logging.error(response.text) raise HttpOperationError(self._deserialize, response) else: deserialized = self._deserialize('User', response) return deserialized
async def cleanup(self, *, custom_headers=None, raw=False, **operation_config): """verify that the clients have cleaned themselves up completely. :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.cleanup.metadata['url'] # Construct parameters query_parameters = {} # Construct headers header_parameters = {} if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.put(url, query_parameters, header_parameters) response = await self._client.async_send(request, 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
def create_organization(self, region_code, organization_name): """Create a new organization for user""" url = '/_apis/HostAcquisition/collections' #construct query parameters query_paramters = {} query_paramters['collectionName'] = organization_name query_paramters['preferredRegion'] = region_code query_paramters['api-version'] = '4.0-preview.1' #construct header parameters header_paramters = {} header_paramters['Accept'] = 'application/json' header_paramters['Content-Type'] = 'application/json' if self._user_mgr.is_msa_account(): header_paramters['X-VSS-ForceMsaPassThrough'] = 'true' #construct the payload payload = {} payload[ 'VisualStudio.Services.HostResolution.UseCodexDomainForHostCreation'] = 'true' request = self._create_organization_client.post(url=url, params=query_paramters, content=payload) response = self._create_organization_client.send( request, headers=header_paramters) # Handle Response deserialized = None if response.status_code // 100 != 2: logging.error("GET %s", request.url) logging.error("response: %s", response.status_code) logging.error(response.text) raise HttpOperationError(self._deserialize, response) else: deserialized = self._deserialize('NewOrganization', response) return deserialized
def get_headers( self, custom_headers=None, raw=False, **operation_config): """Get strongly-typed response headers. :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.get_headers.metadata['url'] # Construct parameters query_parameters = {} # Construct headers header_parameters = {} if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200]: raise HttpOperationError(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) client_raw_response.add_headers({ 'Custom-Header': 'str', }) return client_raw_response
def validate_organization_name(self, organization_name): """Validate an organization name by checking it does not already exist and that it fits name restrictions""" if organization_name is None: return models.ValidateAccountName( valid=False, message="The organization_name cannot be None") if re.search("[^0-9A-Za-z-]", organization_name): return models.ValidateAccountName( valid=False, message="""The name supplied contains forbidden characters. Only alphanumeric characters and dashes are allowed. Please try another organization name.""" ) #construct url url = '/_AzureSpsAccount/ValidateAccountName' #construct query parameters query_paramters = {} query_paramters['accountName'] = organization_name #construct header parameters header_paramters = {} header_paramters['Accept'] = 'application/json' request = self._client.get(url, params=query_paramters) response = self._client.send(request, headers=header_paramters) # Handle Response deserialized = None if response.status_code // 100 != 2: logging.error("GET %s", request.url) logging.error("response: %s", response.status_code) logging.error(response.text) raise HttpOperationError(self._deserialize, response) else: deserialized = self._deserialize('ValidateAccountName', response) return deserialized
def _is_project_created(self, project_id): """Helper function to see the status of a project""" url = '/' + self._organization_name + '/_apis/operations/' + project_id query_paramters = {} header_paramters = {} header_paramters['Accept'] = 'application/json' request = self._create_project_client.get(url, params=query_paramters) response = self._create_project_client.send(request, headers=header_paramters) # Handle Response deserialized = None if response.status_code // 100 != 2: logging.error("GET %s", request.url) logging.error("response: %s", response.status_code) logging.error(response.text) raise HttpOperationError(self._deserialize, response) else: deserialized = self._deserialize('ProjectPoll', 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_uploads(self, bucket_name, max_entries=None, custom_headers=None, raw=False, **operation_config): """Get a list of upload records from the server for a specific bucket. :param bucket_name: The name of the bucket to retrieve uploads for. :type bucket_name: str :param max_entries: The maximum number of entries to return; this is capped at 50, and 50 will be used if it's not specified. :type max_entries: 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: object or ClientRawResponse if raw=true :rtype: object or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_uploads.metadata['url'] path_format_arguments = { 'bucketName': self._serialize.url("bucket_name", bucket_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if max_entries is not None: query_parameters['maxEntries'] = self._serialize.query( "max_entries", max_entries, 'int') # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters, header_parameters) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200, 401, 404, 503]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize( '[AdiEmsWebApiV2DtoUploadUploadRecord]', response) if response.status_code == 401: deserialized = self._deserialize('AdiEmsWebApiModelError', response) if response.status_code == 404: deserialized = self._deserialize('AdiEmsWebApiModelError', response) if response.status_code == 503: deserialized = self._deserialize('AdiEmsWebApiModelError', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def get_upload_processing_status_multiple(self, bucket_name, ids, custom_headers=None, raw=False, **operation_config): """Gets the EMS processing status for a set of uploads. When using this route, make sure to use a bucket and upload IDs that match. Results for IDs that do not exist will still return valid results, but will indicate that the uploading processing is incomplete, which, while true, may be misleading. :param bucket_name: The name of the bucket to query for the specified uploads. :type bucket_name: str :param ids: The list of IDs of the upload for which to return status information. :type ids: 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: object or ClientRawResponse if raw=true :rtype: object or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.get_upload_processing_status_multiple.metadata['url'] path_format_arguments = { 'bucketName': self._serialize.url("bucket_name", bucket_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Accept'] = 'application/json' header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(ids, '[str]') # Construct and send request request = self._client.post(url, query_parameters, header_parameters, body_content) response = self._client.send(request, stream=False, **operation_config) if response.status_code not in [200, 400, 401, 404, 503]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize( '{AdiEmsWebApiV2DtoUploadUploadProcessingStatus}', response) if response.status_code == 400: deserialized = self._deserialize('AdiEmsWebApiModelError', response) if response.status_code == 401: deserialized = self._deserialize('AdiEmsWebApiModelError', response) if response.status_code == 404: deserialized = self._deserialize('AdiEmsWebApiModelError', response) if response.status_code == 503: deserialized = self._deserialize('AdiEmsWebApiModelError', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized