class AutoRestReportService(object): """Test Infrastructure for AutoRest :param config: Configuration for client. :type config: AutoRestReportServiceConfiguration """ def __init__(self, config): self._client = ServiceClient(None, config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer() self._deserialize = Deserializer(client_models) self.config = config def get_report( self, custom_headers={}, raw=False, **operation_config): """ Get test coverage report :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 = '/report' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('{int}', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class AutoRestReportServiceForAzure(object): """Test Infrastructure for AutoRest :param config: Configuration for client. :type config: AutoRestReportServiceForAzureConfiguration """ def __init__(self, config): self._client = ServiceClient(config.credentials, config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer() self._deserialize = Deserializer(client_models) self.config = config def get_report( self, custom_headers={}, raw=False, **operation_config): """ Get test coverage report :param dict custom_headers: headers that will be added to the request :param boolean raw: returns the direct response alongside the deserialized response :rtype: dict or msrest.pipeline.ClientRawResponse """ # Construct URL url = '/report/azure' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('{int}', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class LogicManagementClient(object): """REST API for Azure Logic Apps. :ivar config: Configuration for client. :vartype config: LogicManagementClientConfiguration :ivar workflows: Workflows operations :vartype workflows: .operations.WorkflowsOperations :ivar workflow_versions: WorkflowVersions operations :vartype workflow_versions: .operations.WorkflowVersionsOperations :ivar workflow_triggers: WorkflowTriggers operations :vartype workflow_triggers: .operations.WorkflowTriggersOperations :ivar workflow_trigger_histories: WorkflowTriggerHistories operations :vartype workflow_trigger_histories: .operations.WorkflowTriggerHistoriesOperations :ivar workflow_runs: WorkflowRuns operations :vartype workflow_runs: .operations.WorkflowRunsOperations :ivar workflow_run_actions: WorkflowRunActions operations :vartype workflow_run_actions: .operations.WorkflowRunActionsOperations :ivar integration_accounts: IntegrationAccounts operations :vartype integration_accounts: .operations.IntegrationAccountsOperations :ivar schemas: Schemas operations :vartype schemas: .operations.SchemasOperations :ivar maps: Maps operations :vartype maps: .operations.MapsOperations :ivar partners: Partners operations :vartype partners: .operations.PartnersOperations :ivar agreements: Agreements operations :vartype agreements: .operations.AgreementsOperations :ivar certificates: Certificates operations :vartype certificates: .operations.CertificatesOperations :ivar sessions: Sessions operations :vartype sessions: .operations.SessionsOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object<msrestazure.azure_active_directory>` :param subscription_id: The subscription id. :type subscription_id: str :param str base_url: Service URL """ def __init__( self, credentials, subscription_id, base_url=None): self.config = LogicManagementClientConfiguration(credentials, subscription_id, 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 = '2016-06-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.workflows = WorkflowsOperations( self._client, self.config, self._serialize, self._deserialize) self.workflow_versions = WorkflowVersionsOperations( self._client, self.config, self._serialize, self._deserialize) self.workflow_triggers = WorkflowTriggersOperations( self._client, self.config, self._serialize, self._deserialize) self.workflow_trigger_histories = WorkflowTriggerHistoriesOperations( self._client, self.config, self._serialize, self._deserialize) self.workflow_runs = WorkflowRunsOperations( self._client, self.config, self._serialize, self._deserialize) self.workflow_run_actions = WorkflowRunActionsOperations( self._client, self.config, self._serialize, self._deserialize) self.integration_accounts = IntegrationAccountsOperations( self._client, self.config, self._serialize, self._deserialize) self.schemas = SchemasOperations( self._client, self.config, self._serialize, self._deserialize) self.maps = MapsOperations( self._client, self.config, self._serialize, self._deserialize) self.partners = PartnersOperations( self._client, self.config, self._serialize, self._deserialize) self.agreements = AgreementsOperations( self._client, self.config, self._serialize, self._deserialize) self.certificates = CertificatesOperations( self._client, self.config, self._serialize, self._deserialize) self.sessions = SessionsOperations( self._client, self.config, self._serialize, self._deserialize) def list_operations( self, custom_headers=None, raw=False, **operation_config): """Lists all of the available Logic REST API operations. :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:`OperationPaged <azure.mgmt.logic.models.OperationPaged>` :raises: :class:`ErrorResponseException<azure.mgmt.logic.models.ErrorResponseException>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = '/providers/Microsoft.Logic/operations' # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorResponseException(self._deserialize, response) return response # Deserialize response deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized
class PredictionEndpoint(object): """PredictionEndpoint :ivar config: Configuration for client. :vartype config: PredictionEndpointConfiguration :param api_key: :type api_key: str :param str base_url: Service URL """ def __init__( self, api_key, base_url=None): self.config = PredictionEndpointConfiguration(api_key, 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.1' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) def predict_image_url( self, project_id, iteration_id=None, application=None, url=None, custom_headers=None, raw=False, **operation_config): """Predict an image url and saves the result. :param project_id: The project id :type project_id: str :param iteration_id: Optional. Specifies the id of a particular iteration to evaluate against. The default iteration for the project will be used when not specified :type iteration_id: str :param application: Optional. Specifies the name of application using the endpoint :type application: str :param url: :type url: 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: ImagePredictionResultModel or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.vision.customvision.prediction.models.ImagePredictionResultModel or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ image_url = models.ImageUrl(url=url) # Construct URL url = '/{projectId}/url' path_format_arguments = { 'projectId': self._serialize.url("project_id", project_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if iteration_id is not None: query_parameters['iterationId'] = self._serialize.query("iteration_id", iteration_id, 'str') if application is not None: query_parameters['application'] = self._serialize.query("application", application, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) header_parameters['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str') # Construct body body_content = self._serialize.body(image_url, 'ImageUrl') # 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('ImagePredictionResultModel', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def predict_image( self, project_id, image_data, iteration_id=None, application=None, custom_headers=None, raw=False, **operation_config): """Predict an image and saves the result. :param project_id: The project id :type project_id: str :param image_data: :type image_data: Generator :param iteration_id: Optional. Specifies the id of a particular iteration to evaluate against. The default iteration for the project will be used when not specified :type iteration_id: str :param application: Optional. Specifies the name of application using the endpoint :type application: 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: ImagePredictionResultModel or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.vision.customvision.prediction.models.ImagePredictionResultModel or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/{projectId}/image' path_format_arguments = { 'projectId': self._serialize.url("project_id", project_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if iteration_id is not None: query_parameters['iterationId'] = self._serialize.query("iteration_id", iteration_id, 'str') if application is not None: query_parameters['application'] = self._serialize.query("application", application, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'multipart/form-data' if custom_headers: header_parameters.update(custom_headers) header_parameters['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str') # Construct form data form_data_content = { 'imageData': image_data, } # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send_formdata( request, header_parameters, form_data_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('ImagePredictionResultModel', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def predict_image_url_with_no_store( self, project_id, iteration_id=None, application=None, url=None, custom_headers=None, raw=False, **operation_config): """Predict an image url without saving the result. :param project_id: The project id :type project_id: str :param iteration_id: Optional. Specifies the id of a particular iteration to evaluate against. The default iteration for the project will be used when not specified :type iteration_id: str :param application: Optional. Specifies the name of application using the endpoint :type application: str :param url: :type url: 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: ImagePredictionResultModel or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.vision.customvision.prediction.models.ImagePredictionResultModel or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ image_url = models.ImageUrl(url=url) # Construct URL url = '/{projectId}/url/nostore' path_format_arguments = { 'projectId': self._serialize.url("project_id", project_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if iteration_id is not None: query_parameters['iterationId'] = self._serialize.query("iteration_id", iteration_id, 'str') if application is not None: query_parameters['application'] = self._serialize.query("application", application, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) header_parameters['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str') # Construct body body_content = self._serialize.body(image_url, 'ImageUrl') # 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('ImagePredictionResultModel', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def predict_image_with_no_store( self, project_id, image_data, iteration_id=None, application=None, custom_headers=None, raw=False, **operation_config): """Predict an image without saving the result. :param project_id: The project id :type project_id: str :param image_data: :type image_data: Generator :param iteration_id: Optional. Specifies the id of a particular iteration to evaluate against. The default iteration for the project will be used when not specified :type iteration_id: str :param application: Optional. Specifies the name of application using the endpoint :type application: 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: ImagePredictionResultModel or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.vision.customvision.prediction.models.ImagePredictionResultModel or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/{projectId}/image/nostore' path_format_arguments = { 'projectId': self._serialize.url("project_id", project_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if iteration_id is not None: query_parameters['iterationId'] = self._serialize.query("iteration_id", iteration_id, 'str') if application is not None: query_parameters['application'] = self._serialize.query("application", application, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'multipart/form-data' if custom_headers: header_parameters.update(custom_headers) header_parameters['Prediction-Key'] = self._serialize.header("self.config.api_key", self.config.api_key, 'str') # Construct form data form_data_content = { 'imageData': image_data, } # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send_formdata( request, header_parameters, form_data_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('ImagePredictionResultModel', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class AutoRestReportServiceForAzure(object): """Test Infrastructure for AutoRest :ivar config: Configuration for client. :vartype config: AutoRestReportServiceForAzureConfiguration :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 = AutoRestReportServiceForAzureConfiguration(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 = '1.0.0' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) def get_report( self, custom_headers=None, raw=False, **operation_config): """Get test coverage report. :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: dict or :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :rtype: dict or :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` :raises: :class:`ErrorException<fixtures.acceptancetestsazurereport.models.ErrorException>` """ # Construct URL url = '/report/azure' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('{int}', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class AutoRestValidationTest(object): """Test Infrastructure for AutoRest. No server backend exists for these tests. :ivar config: Configuration for client. :vartype config: AutoRestValidationTestConfiguration :param subscription_id: Subscription ID. :type subscription_id: str :param str base_url: Service URL """ def __init__( self, subscription_id, base_url=None): self.config = AutoRestValidationTestConfiguration(subscription_id, base_url) self._client = ServiceClient(None, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self.api_version = '1.0.0' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) def validation_of_method_parameters( self, resource_group_name, id, custom_headers=None, raw=False, **operation_config): """Validates input parameters on the method. See swagger for details. :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. :type resource_group_name: str :param id: Required int multiple of 10 from 100 to 1000. :type id: int :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: :class:`Product <fixtures.acceptancetestsvalidation.models.Product>` or :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :rtype: :class:`Product <fixtures.acceptancetestsvalidation.models.Product>` or :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` :raises: :class:`ErrorException<fixtures.acceptancetestsvalidation.models.ErrorException>` """ # Construct URL url = '/fakepath/{subscriptionId}/{resourceGroupName}/{id}' path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=10, min_length=3, pattern=r'[a-zA-Z0-9]+'), 'id': self._serialize.url("id", id, 'int', maximum=1000, minimum=100, multiple=10) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['apiVersion'] = self._serialize.query("self.api_version", self.api_version, 'str', pattern=r'\d{2}-\d{2}-\d{4}') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def validation_of_body( self, resource_group_name, id, body=None, custom_headers=None, raw=False, **operation_config): """Validates body parameters on the method. See swagger for details. :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. :type resource_group_name: str :param id: Required int multiple of 10 from 100 to 1000. :type id: int :param body: :type body: :class:`Product <fixtures.acceptancetestsvalidation.models.Product>` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: :class:`Product <fixtures.acceptancetestsvalidation.models.Product>` or :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :rtype: :class:`Product <fixtures.acceptancetestsvalidation.models.Product>` or :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` :raises: :class:`ErrorException<fixtures.acceptancetestsvalidation.models.ErrorException>` """ # Construct URL url = '/fakepath/{subscriptionId}/{resourceGroupName}/{id}' path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=10, min_length=3, pattern=r'[a-zA-Z0-9]+'), 'id': self._serialize.url("id", id, 'int', maximum=1000, minimum=100, multiple=10) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['apiVersion'] = self._serialize.query("self.api_version", self.api_version, 'str', pattern=r'\d{2}-\d{2}-\d{4}') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body if body is not None: body_content = self._serialize.body(body, 'Product') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def 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>`. :return: None or :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :rtype: None or :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` :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 post_with_constant_in_body( self, body=None, custom_headers=None, raw=False, **operation_config): """ :param body: :type body: :class:`Product <fixtures.acceptancetestsvalidation.models.Product>` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: :class:`Product <fixtures.acceptancetestsvalidation.models.Product>` or :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :rtype: :class:`Product <fixtures.acceptancetestsvalidation.models.Product>` or :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` :raises: :class:`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 body if body is not None: body_content = self._serialize.body(body, 'Product') 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]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class PowerBIEmbeddedManagementClient(object): """Client to manage your Power BI Embedded workspace collections and retrieve workspaces. :ivar config: Configuration for client. :vartype config: PowerBIEmbeddedManagementClientConfiguration :ivar workspace_collections: WorkspaceCollections operations :vartype workspace_collections: .operations.WorkspaceCollectionsOperations :ivar workspaces: Workspaces operations :vartype workspaces: .operations.WorkspacesOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object<msrestazure.azure_active_directory>` :param subscription_id: Gets subscription credentials which uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str :param api_version: Client Api Version. :type api_version: str :param accept_language: Gets or sets the preferred language for the response. :type accept_language: str :param long_running_operation_retry_timeout: Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. :type long_running_operation_retry_timeout: int :param generate_client_request_id: When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. :type generate_client_request_id: bool :param str base_url: Service URL :param str filepath: Existing config """ def __init__( self, credentials, subscription_id, api_version='2016-01-29', accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): self.config = PowerBIEmbeddedManagementClientConfiguration(credentials, subscription_id, api_version, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.workspace_collections = WorkspaceCollectionsOperations( self._client, self.config, self._serialize, self._deserialize) self.workspaces = WorkspacesOperations( self._client, self.config, self._serialize, self._deserialize) def get_available_operations( self, custom_headers=None, raw=False, **operation_config): """Indicates which operations can be performed by the Power BI Resource Provider. :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:`OperationList <azure.mgmt.powerbiembedded.models.OperationList>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`ErrorException<azure.mgmt.powerbiembedded.models.ErrorException>` """ # Construct URL url = '/providers/Microsoft.PowerBI/operations' # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('OperationList', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
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 AzureReservationAPI(object): """This API describe Azure Reservation :ivar config: Configuration for client. :vartype config: AzureReservationAPIConfiguration :ivar reservation_order: ReservationOrder operations :vartype reservation_order: reservations.operations.ReservationOrderOperations :ivar reservation: Reservation operations :vartype reservation: reservations.operations.ReservationOperations :ivar operation: Operation operations :vartype operation: reservations.operations.OperationOperations :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 = AzureReservationAPIConfiguration(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 = '2017-11-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.reservation_order = ReservationOrderOperations( self._client, self.config, self._serialize, self._deserialize) self.reservation = ReservationOperations( self._client, self.config, self._serialize, self._deserialize) self.operation = OperationOperations( self._client, self.config, self._serialize, self._deserialize) def get_catalog( self, subscription_id, custom_headers=None, raw=False, **operation_config): """Get the regions and skus that are available for RI purchase for the specified Azure subscription. :param subscription_id: Id of the subscription :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 of :class:`Catalog <reservations.models.Catalog>` or :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :rtype: list of :class:`Catalog <reservations.models.Catalog>` or :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` :raises: :class:`ErrorException<reservations.models.ErrorException>` """ # Construct URL url = '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/catalogs' 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 = {} 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, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[Catalog]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def get_applied_reservation_list( self, subscription_id, custom_headers=None, raw=False, **operation_config): """Get list of applicable `Reservation`s. Get applicable `Reservation`s that are applied to this subscription. :param subscription_id: Id of the subscription :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: :class:`AppliedReservations <reservations.models.AppliedReservations>` or :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :rtype: :class:`AppliedReservations <reservations.models.AppliedReservations>` or :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` :raises: :class:`ErrorException<reservations.models.ErrorException>` """ # Construct URL url = '/subscriptions/{subscriptionId}/providers/Microsoft.Capacity/appliedReservations' 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 = {} 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, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('AppliedReservations', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
def search_extensions(search_query): """ Search extensions from marketplace """ from msrest.universal_http import ClientRequest from msrest.service_client import ServiceClient from msrest import Configuration from azext_devops.version import VERSION config = Configuration(base_url=None) config.add_user_agent('devOpsCli/{}'.format(VERSION)) client = ServiceClient(creds=None, config=config) request = ClientRequest(method='POST', url='https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery') search_request = { 'assetTypes': [ 'Microsoft.VisualStudio.Services.Icons.Default', 'Microsoft.VisualStudio.Services.Icons.Branding', 'Microsoft.VisualStudio.Services.Icons.Small' ], 'filters': [ { 'criteria': [ { 'filterType': 8, 'value': 'Microsoft.VisualStudio.Services' }, { 'filterType': 8, 'value': 'Microsoft.VisualStudio.Services.Integration' }, { 'filterType': 8, 'value': 'Microsoft.VisualStudio.Services.Cloud' }, { 'filterType': 8, 'value': 'Microsoft.TeamFoundation.Server' }, { 'filterType': 8, 'value': 'Microsoft.TeamFoundation.Server.Integration' }, { 'filterType': 8, 'value': 'Microsoft.VisualStudio.Services.Cloud.Integration' }, { 'filterType': 8, 'value': 'Microsoft.VisualStudio.Services.Resource.Cloud' }, { 'filterType': 10, 'value': search_query }, { 'filterType': 12, 'value': '37888' } ], 'direction': 2, 'pageSize': 50, 'pageNumber': 1, 'sortBy': 0, 'sortOrder': 0, 'pagingToken': None } ], 'flags': 870 } headers = {'Content-Type': 'application/json' + '; charset=utf-8', 'Accept': 'application/json' + ';api-version=' + '5.0-preview.1'} response = client.send(request=request, headers=headers, content=search_request) response_json = response.json() return response_json['results'][0]['extensions']
class AutoRestResourceFlatteningTestService(object): """Resource Flattening for AutoRest :param config: Configuration for client. :type config: AutoRestResourceFlatteningTestServiceConfiguration """ def __init__(self, config): self._client = ServiceClient(config.credentials, config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer() self._deserialize = Deserializer(client_models) self.config = config def put_array( self, resource_array=None, custom_headers={}, raw=False, **operation_config): """ Put External Resource as an Array :param resource_array: External Resource as an Array to put :type resource_array: list or None :param dict custom_headers: headers that will be added to the request :param boolean raw: returns the direct response alongside the deserialized response :rtype: None or msrest.pipeline.ClientRawResponse """ # Construct URL url = '/azure/resource-flatten/array' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body if resource_array is not None: body_content = self._serialize.body(resource_array, '[Resource]') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_array( self, custom_headers={}, raw=False, **operation_config): """ Get External Resource as an Array :param dict custom_headers: headers that will be added to the request :param boolean raw: returns the direct response alongside the deserialized response :rtype: list or msrest.pipeline.ClientRawResponse """ # Construct URL url = '/azure/resource-flatten/array' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[FlattenedProduct]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def put_dictionary( self, resource_dictionary=None, custom_headers={}, raw=False, **operation_config): """ Put External Resource as a Dictionary :param resource_dictionary: External Resource as a Dictionary to put :type resource_dictionary: dict or None :param dict custom_headers: headers that will be added to the request :param boolean raw: returns the direct response alongside the deserialized response :rtype: None or msrest.pipeline.ClientRawResponse """ # Construct URL url = '/azure/resource-flatten/dictionary' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body if resource_dictionary is not None: body_content = self._serialize.body(resource_dictionary, '{FlattenedProduct}') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_dictionary( self, custom_headers={}, raw=False, **operation_config): """ Get External Resource as a Dictionary :param dict custom_headers: headers that will be added to the request :param boolean raw: returns the direct response alongside the deserialized response :rtype: dict or msrest.pipeline.ClientRawResponse """ # Construct URL url = '/azure/resource-flatten/dictionary' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('{FlattenedProduct}', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def put_resource_collection( self, resource_complex_object=None, custom_headers={}, raw=False, **operation_config): """ Put External Resource as a ResourceCollection :param resource_complex_object: External Resource as a ResourceCollection to put :type resource_complex_object: ResourceCollection or None :param dict custom_headers: headers that will be added to the request :param boolean raw: returns the direct response alongside the deserialized response :rtype: None or msrest.pipeline.ClientRawResponse """ # Construct URL url = '/azure/resource-flatten/resourcecollection' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body if resource_complex_object is not None: body_content = self._serialize.body(resource_complex_object, 'ResourceCollection') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_resource_collection( self, custom_headers={}, raw=False, **operation_config): """ Get External Resource as a ResourceCollection :param dict custom_headers: headers that will be added to the request :param boolean raw: returns the direct response alongside the deserialized response :rtype: ResourceCollection or msrest.pipeline.ClientRawResponse """ # Construct URL url = '/azure/resource-flatten/resourcecollection' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('ResourceCollection', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class Client(object): """Client. :param str base_url: Service URL :param Authentication creds: Authenticated credentials. """ def __init__(self, base_url=None, creds=None): self.config = ClientConfiguration(base_url) self.config.credentials = creds self._client = ServiceClient(creds, config=self.config) _base_client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._base_deserialize = Deserializer(_base_client_models) self._base_serialize = Serializer(_base_client_models) self._all_host_types_locations = None self._locations = None self._suppress_fedauth_redirect = True self._force_msa_pass_through = True self.normalized_url = Client._normalize_url(base_url) def add_user_agent(self, user_agent): if user_agent is not None: self.config.add_user_agent(user_agent) def _send_request(self, request, headers=None, content=None, media_type=None, **operation_config): """Prepare and send request object according to configuration. :param ClientRequest request: The request object to be sent. :param dict headers: Any headers to add to the request. :param content: Any body data to add to the request. :param config: Any specific config overrides """ if (TRACE_ENV_VAR in os.environ and os.environ[TRACE_ENV_VAR] == 'true')\ or (TRACE_ENV_VAR_COMPAT in os.environ and os.environ[TRACE_ENV_VAR_COMPAT] == 'true'): print(request.method + ' ' + request.url) logger.debug('%s %s', request.method, request.url) if media_type is not None and media_type == 'application/json': logger.debug('Request content: %s', content) response = self._client.send(request=request, headers=headers, content=content, **operation_config) if ('Content-Type' in response.headers and response.headers['Content-Type'].startswith('application/json')): logger.debug('Response content: %s', response.content) if response.status_code < 200 or response.status_code >= 300: self._handle_error(request, response) return response def _send(self, http_method, location_id, version, route_values=None, query_parameters=None, content=None, media_type='application/json', accept_media_type='application/json', additional_headers=None): request = self._create_request_message(http_method=http_method, location_id=location_id, route_values=route_values, query_parameters=query_parameters) negotiated_version = self._negotiate_request_version( self._get_resource_location(location_id), version) if version != negotiated_version: logger.info("Negotiated api version from '%s' down to '%s'. This means the client is newer than the server.", version, negotiated_version) else: logger.debug("Api version '%s'", negotiated_version) # Construct headers headers = {'Content-Type': media_type + '; charset=utf-8', 'Accept': accept_media_type + ';api-version=' + negotiated_version} if additional_headers is not None: for key in additional_headers: headers[key] = str(additional_headers[key]) if self.config.additional_headers is not None: for key in self.config.additional_headers: headers[key] = self.config.additional_headers[key] if self._suppress_fedauth_redirect: headers['X-TFS-FedAuthRedirect'] = 'Suppress' if self._force_msa_pass_through: headers['X-VSS-ForceMsaPassThrough'] = 'true' if Client._session_header_key in Client._session_data and Client._session_header_key not in headers: headers[Client._session_header_key] = Client._session_data[Client._session_header_key] response = self._send_request(request=request, headers=headers, content=content, media_type=media_type) if Client._session_header_key in response.headers: Client._session_data[Client._session_header_key] = response.headers[Client._session_header_key] return response def _unwrap_collection(self, response): if response.headers.get("transfer-encoding") == 'chunked': wrapper = self._base_deserialize.deserialize_data(response.json(), 'VssJsonCollectionWrapper') else: wrapper = self._base_deserialize('VssJsonCollectionWrapper', response) collection = wrapper.value return collection def _create_request_message(self, http_method, location_id, route_values=None, query_parameters=None): location = self._get_resource_location(location_id) if location is None: raise ValueError('API resource location ' + location_id + ' is not registered on ' + self.config.base_url + '.') if route_values is None: route_values = {} route_values['area'] = location.area route_values['resource'] = location.resource_name url = self._transform_route_template(location.route_template, route_values) logger.debug('Route template: %s', location.route_template) request = ClientRequest(method=http_method, url=self._client.format_url(url)) if query_parameters: request.format_parameters(query_parameters) return request @staticmethod def _transform_route_template(route_template, route_values): new_template = '' route_template = route_template.replace('{*', '{') for path_segment in route_template.split('/'): if (len(path_segment) <= 2 or not path_segment[0] == '{' or not path_segment[len(path_segment) - 1] == '}'): new_template = new_template + '/' + path_segment elif path_segment[1:len(path_segment) - 1] in route_values: new_template = new_template + '/' + route_values[path_segment[1:len(path_segment) - 1]] return new_template def _get_resource_location(self, location_id): if self.config.base_url not in Client._locations_cache: Client._locations_cache[self.config.base_url] = self._get_resource_locations(all_host_types=False) for location in Client._locations_cache[self.config.base_url]: if location.id == location_id: return location def _get_resource_locations(self, all_host_types): # Check local client's cached Options first if all_host_types: if self._all_host_types_locations is not None: return self._all_host_types_locations elif self._locations is not None: return self._locations # Next check for options cached on disk if not all_host_types and OPTIONS_FILE_CACHE[self.normalized_url]: try: logger.debug('File cache hit for options on: %s', self.normalized_url) self._locations = self._base_deserialize.deserialize_data(OPTIONS_FILE_CACHE[self.normalized_url], '[ApiResourceLocation]') return self._locations except DeserializationError as ex: logger.debug(ex, exc_info=True) else: logger.debug('File cache miss for options on: %s', self.normalized_url) # Last resort, make the call to the server options_uri = self._combine_url(self.config.base_url, '_apis') request = ClientRequest(method='OPTIONS', url=self._client.format_url(options_uri)) if all_host_types: query_parameters = {'allHostTypes': True} request.format_parameters(query_parameters) headers = {'Accept': 'application/json'} if self._suppress_fedauth_redirect: headers['X-TFS-FedAuthRedirect'] = 'Suppress' if self._force_msa_pass_through: headers['X-VSS-ForceMsaPassThrough'] = 'true' response = self._send_request(request, headers=headers) wrapper = self._base_deserialize('VssJsonCollectionWrapper', response) if wrapper is None: raise AzureDevOpsClientRequestError("Failed to retrieve resource locations from: {}".format(options_uri)) collection = wrapper.value returned_locations = self._base_deserialize('[ApiResourceLocation]', collection) if all_host_types: self._all_host_types_locations = returned_locations else: self._locations = returned_locations try: OPTIONS_FILE_CACHE[self.normalized_url] = wrapper.value except SerializationError as ex: logger.debug(ex, exc_info=True) return returned_locations @staticmethod def _negotiate_request_version(location, version): if location is None or version is None: return version pattern = r'(\d+(\.\d)?)(-preview(.(\d+))?)?' match = re.match(pattern, version) requested_api_version = match.group(1) if requested_api_version is not None: requested_api_version = float(requested_api_version) if location.min_version > requested_api_version: # Client is older than the server. The server no longer supports this # resource (deprecated). return elif location.max_version < requested_api_version: # Client is newer than the server. Negotiate down to the latest version # on the server negotiated_version = str(location.max_version) if float(location.released_version) < location.max_version: negotiated_version += '-preview' return negotiated_version else: # We can send at the requested api version. Make sure the resource version # is not bigger than what the server supports negotiated_version = match.group(1) is_preview = match.group(3) is not None if is_preview: negotiated_version += '-preview' if match.group(5) is not None: if location.resource_version < int(match.group(5)): negotiated_version += '.' + str(location.resource_version) else: negotiated_version += '.' + match.group(5) return negotiated_version @staticmethod def _combine_url(part1, part2): return part1.rstrip('/') + '/' + part2.strip('/') def _handle_error(self, request, response): content_type = response.headers.get('Content-Type') error_message = '' if content_type is None or content_type.find('text/plain') < 0: try: wrapped_exception = self._base_deserialize('WrappedException', response) if wrapped_exception is not None and wrapped_exception.message is not None: raise AzureDevOpsServiceError(wrapped_exception) else: # System exceptions from controllers are not returning wrapped exceptions. # Following code is to handle this unusual exception json case. # TODO: dig into this. collection_wrapper = self._base_deserialize('VssJsonCollectionWrapper', response) if collection_wrapper is not None and collection_wrapper.value is not None: wrapped_exception = self._base_deserialize('ImproperException', collection_wrapper.value) if wrapped_exception is not None and wrapped_exception.message is not None: raise AzureDevOpsClientRequestError(wrapped_exception.message) # if we get here we still have not raised an exception, try to deserialize as a System Exception system_exception = self._base_deserialize('SystemException', response) if system_exception is not None and system_exception.message is not None: raise AzureDevOpsClientRequestError(system_exception.message) except DeserializationError: pass elif response.content is not None: error_message = response.content.decode("utf-8") + ' ' if response.status_code == 401: full_message_format = '{error_message}The requested resource requires user authentication: {url}' raise AzureDevOpsAuthenticationError(full_message_format.format(error_message=error_message, url=request.url)) else: full_message_format = '{error_message}Operation returned a {status_code} status code.' raise AzureDevOpsClientRequestError(full_message_format.format(error_message=error_message, status_code=response.status_code)) @staticmethod def _normalize_url(url): return url.rstrip('/').lower() _locations_cache = {} _session_header_key = 'X-TFS-Session' _session_data = {_session_header_key: str(uuid.uuid4())}
class UserManager(object): """ Get details about a user Attributes: See BaseManager """ def __init__(self, base_url='https://peprodscussu2.portalext.visualstudio.com', creds=None): """Inits UserManager as to be able to send the right requests""" self._config = Configuration(base_url=base_url) self._client = ServiceClient(creds, self._config) #create the deserializer for the models client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._deserialize = Deserializer(client_models) # create cache for two user type self._cache_aad_user = None self._cache_msa_user = None def is_msa_account(self): user_id_aad = self.get_user(msa=False).id user_id_msa = self.get_user(msa=True).id return user_id_aad != user_id_msa def get_user(self, msa=False): # Try to get from cache if msa is True and self._cache_msa_user is not None: return self._cache_msa_user if msa is False and self._cache_aad_user is not None: return self._cache_aad_user header_parameters = {} header_parameters['X-VSS-ForceMsaPassThrough'] = 'true' if msa else 'false' 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) # Write to cache if msa is True and self._cache_msa_user is None: self._cache_msa_user = deserialized if msa is False and self._cache_aad_user is None: self._cache_aad_user = deserialized return deserialized @property def aad_id(self): return self.get_user(msa=False).id @property def msa_id(self): return self.get_user(msa=True).id def close_connection(self): self._client.close()
class AutoRestReportService(object): """Test Infrastructure for AutoRest :ivar config: Configuration for client. :vartype config: AutoRestReportServiceConfiguration :param str base_url: Service URL :param str filepath: Existing config """ def __init__(self, base_url=None, filepath=None): self.config = AutoRestReportServiceConfiguration(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 get_report(self, custom_headers=None, raw=False, **operation_config): """Get test coverage report. :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:`ErrorException<Fixtures.AcceptanceTestsReport.models.ErrorException>` """ # Construct URL url = '/report' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('{int}', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class AutoRestReportServiceForAzure(object): """Test Infrastructure for AutoRest :ivar config: Configuration for client. :vartype config: AutoRestReportServiceForAzureConfiguration :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object<msrestazure.azure_active_directory>` :param accept_language: Gets or sets the preferred language for the response. :type accept_language: str :param long_running_operation_retry_timeout: Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. :type long_running_operation_retry_timeout: int :param generate_client_request_id: When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. :type generate_client_request_id: bool :param str base_url: Service URL :param str filepath: Existing config """ def __init__(self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): self.config = AutoRestReportServiceForAzureConfiguration( credentials, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) self._client = ServiceClient(self.config.credentials, self.config) client_models = { k: v for k, v in models.__dict__.items() if isinstance(v, type) } self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) def get_report(self, custom_headers=None, raw=False, **operation_config): """Get test coverage report. :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:`ErrorException<fixtures.acceptancetestsazurereport.models.ErrorException>` """ # Construct URL url = '/report/azure' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header( "self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('{int}', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class AutoRestResourceFlatteningTestService(object): """Resource Flattening for AutoRest :ivar config: Configuration for client. :vartype config: AutoRestResourceFlatteningTestServiceConfiguration :param str base_url: Service URL """ def __init__(self, base_url=None): self.config = AutoRestResourceFlatteningTestServiceConfiguration( base_url) self._client = ServiceClient(None, self.config) client_models = { k: v for k, v in models.__dict__.items() if isinstance(v, type) } self.api_version = '1.0.0' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) def put_array(self, resource_array=None, custom_headers=None, raw=False, **operation_config): """Put External Resource as an Array. :param resource_array: External Resource as an Array to put :type resource_array: list of :class:`Resource <fixtures.acceptancetestsmodelflattening.models.Resource>` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: None :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`ErrorException<fixtures.acceptancetestsmodelflattening.models.ErrorException>` """ # Construct URL url = '/model-flatten/array' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body if resource_array is not None: body_content = self._serialize.body(resource_array, '[Resource]') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send(request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_array(self, custom_headers=None, raw=False, **operation_config): """Get External Resource as an Array. :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: list of :class:`FlattenedProduct <fixtures.acceptancetestsmodelflattening.models.FlattenedProduct>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`ErrorException<fixtures.acceptancetestsmodelflattening.models.ErrorException>` """ # Construct URL url = '/model-flatten/array' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[FlattenedProduct]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def put_dictionary(self, resource_dictionary=None, custom_headers=None, raw=False, **operation_config): """Put External Resource as a Dictionary. :param resource_dictionary: External Resource as a Dictionary to put :type resource_dictionary: dict :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: None :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`ErrorException<fixtures.acceptancetestsmodelflattening.models.ErrorException>` """ # Construct URL url = '/model-flatten/dictionary' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body if resource_dictionary is not None: body_content = self._serialize.body(resource_dictionary, '{FlattenedProduct}') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send(request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_dictionary(self, custom_headers=None, raw=False, **operation_config): """Get External Resource as a Dictionary. :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:`ErrorException<fixtures.acceptancetestsmodelflattening.models.ErrorException>` """ # Construct URL url = '/model-flatten/dictionary' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('{FlattenedProduct}', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def put_resource_collection(self, resource_complex_object=None, custom_headers=None, raw=False, **operation_config): """Put External Resource as a ResourceCollection. :param resource_complex_object: External Resource as a ResourceCollection to put :type resource_complex_object: :class:`ResourceCollection <fixtures.acceptancetestsmodelflattening.models.ResourceCollection>` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: None :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`ErrorException<fixtures.acceptancetestsmodelflattening.models.ErrorException>` """ # Construct URL url = '/model-flatten/resourcecollection' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body if resource_complex_object is not None: body_content = self._serialize.body(resource_complex_object, 'ResourceCollection') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send(request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_resource_collection(self, custom_headers=None, raw=False, **operation_config): """Get External Resource as a ResourceCollection. :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:`ResourceCollection <fixtures.acceptancetestsmodelflattening.models.ResourceCollection>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`ErrorException<fixtures.acceptancetestsmodelflattening.models.ErrorException>` """ # Construct URL url = '/model-flatten/resourcecollection' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('ResourceCollection', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def put_simple_product(self, simple_body_product=None, custom_headers=None, raw=False, **operation_config): """Put Simple Product with client flattening true on the model. :param simple_body_product: Simple body product to put :type simple_body_product: :class:`SimpleProduct <fixtures.acceptancetestsmodelflattening.models.SimpleProduct>` :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:`SimpleProduct <fixtures.acceptancetestsmodelflattening.models.SimpleProduct>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`ErrorException<fixtures.acceptancetestsmodelflattening.models.ErrorException>` """ # Construct URL url = '/model-flatten/customFlattening' # 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 simple_body_product is not None: body_content = self._serialize.body(simple_body_product, 'SimpleProduct') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send(request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('SimpleProduct', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def post_flattened_simple_product(self, product_id, max_product_display_name, description=None, generic_value=None, odatavalue=None, custom_headers=None, raw=False, **operation_config): """Put Flattened Simple Product with client flattening true on the parameter. :param product_id: Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles. :type product_id: str :param max_product_display_name: Display name of product. :type max_product_display_name: str :param description: Description of product. :type description: str :param generic_value: Generic URL value. :type generic_value: str :param odatavalue: URL value. :type odatavalue: 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:`SimpleProduct <fixtures.acceptancetestsmodelflattening.models.SimpleProduct>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`ErrorException<fixtures.acceptancetestsmodelflattening.models.ErrorException>` """ simple_body_product = None if product_id is not None or description is not None or max_product_display_name is not None or generic_value is not None or odatavalue is not None: simple_body_product = models.SimpleProduct( product_id=product_id, description=description, max_product_display_name=max_product_display_name, generic_value=generic_value, odatavalue=odatavalue) # Construct URL url = '/model-flatten/customFlattening' # 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 simple_body_product is not None: body_content = self._serialize.body(simple_body_product, 'SimpleProduct') 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]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('SimpleProduct', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def put_simple_product_with_grouping(self, flatten_parameter_group, custom_headers=None, raw=False, **operation_config): """Put Simple Product with client flattening true on the model. :param flatten_parameter_group: Additional parameters for the operation :type flatten_parameter_group: :class:`FlattenParameterGroup <fixtures.acceptancetestsmodelflattening.models.FlattenParameterGroup>` :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:`SimpleProduct <fixtures.acceptancetestsmodelflattening.models.SimpleProduct>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`ErrorException<fixtures.acceptancetestsmodelflattening.models.ErrorException>` """ name = None if flatten_parameter_group is not None: name = flatten_parameter_group.name product_id = None if flatten_parameter_group is not None: product_id = flatten_parameter_group.product_id description = None if flatten_parameter_group is not None: description = flatten_parameter_group.description max_product_display_name = None if flatten_parameter_group is not None: max_product_display_name = flatten_parameter_group.max_product_display_name generic_value = None if flatten_parameter_group is not None: generic_value = flatten_parameter_group.generic_value odatavalue = None if flatten_parameter_group is not None: odatavalue = flatten_parameter_group.odatavalue simple_body_product = None if product_id is not None or description is not None or max_product_display_name is not None or generic_value is not None or odatavalue is not None: simple_body_product = models.SimpleProduct( product_id=product_id, description=description, max_product_display_name=max_product_display_name, generic_value=generic_value, odatavalue=odatavalue) # Construct URL url = '/model-flatten/customFlattening/parametergrouping/{name}/' path_format_arguments = { 'name': self._serialize.url("name", name, '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 simple_body_product is not None: body_content = self._serialize.body(simple_body_product, 'SimpleProduct') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send(request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('SimpleProduct', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class NetworkManagementClient(object): """Composite Swagger for Network Client :ivar config: Configuration for client. :vartype config: NetworkManagementClientConfiguration :ivar application_gateways: ApplicationGateways operations :vartype application_gateways: .operations.ApplicationGatewaysOperations :ivar route_tables: RouteTables operations :vartype route_tables: .operations.RouteTablesOperations :ivar routes: Routes operations :vartype routes: .operations.RoutesOperations :ivar public_ip_addresses: PublicIPAddresses operations :vartype public_ip_addresses: .operations.PublicIPAddressesOperations :ivar network_security_groups: NetworkSecurityGroups operations :vartype network_security_groups: .operations.NetworkSecurityGroupsOperations :ivar security_rules: SecurityRules operations :vartype security_rules: .operations.SecurityRulesOperations :ivar load_balancers: LoadBalancers operations :vartype load_balancers: .operations.LoadBalancersOperations :ivar virtual_networks: VirtualNetworks operations :vartype virtual_networks: .operations.VirtualNetworksOperations :ivar subnets: Subnets operations :vartype subnets: .operations.SubnetsOperations :ivar virtual_network_peerings: VirtualNetworkPeerings operations :vartype virtual_network_peerings: .operations.VirtualNetworkPeeringsOperations :ivar network_interfaces: NetworkInterfaces operations :vartype network_interfaces: .operations.NetworkInterfacesOperations :ivar usages: Usages operations :vartype usages: .operations.UsagesOperations :ivar virtual_network_gateways: VirtualNetworkGateways operations :vartype virtual_network_gateways: .operations.VirtualNetworkGatewaysOperations :ivar virtual_network_gateway_connections: VirtualNetworkGatewayConnections operations :vartype virtual_network_gateway_connections: .operations.VirtualNetworkGatewayConnectionsOperations :ivar local_network_gateways: LocalNetworkGateways operations :vartype local_network_gateways: .operations.LocalNetworkGatewaysOperations :ivar express_route_circuit_authorizations: ExpressRouteCircuitAuthorizations operations :vartype express_route_circuit_authorizations: .operations.ExpressRouteCircuitAuthorizationsOperations :ivar express_route_circuit_peerings: ExpressRouteCircuitPeerings operations :vartype express_route_circuit_peerings: .operations.ExpressRouteCircuitPeeringsOperations :ivar express_route_circuits: ExpressRouteCircuits operations :vartype express_route_circuits: .operations.ExpressRouteCircuitsOperations :ivar express_route_service_providers: ExpressRouteServiceProviders operations :vartype express_route_service_providers: .operations.ExpressRouteServiceProvidersOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object<msrestazure.azure_active_directory>` :param subscription_id: The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str :param accept_language: Gets or sets the preferred language for the response. :type accept_language: str :param long_running_operation_retry_timeout: Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. :type long_running_operation_retry_timeout: int :param generate_client_request_id: When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. :type generate_client_request_id: bool :param str base_url: Service URL :param str filepath: Existing config """ def __init__( self, credentials, subscription_id, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): self.config = NetworkManagementClientConfiguration(credentials, subscription_id, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.application_gateways = ApplicationGatewaysOperations( self._client, self.config, self._serialize, self._deserialize) self.route_tables = RouteTablesOperations( self._client, self.config, self._serialize, self._deserialize) self.routes = RoutesOperations( self._client, self.config, self._serialize, self._deserialize) self.public_ip_addresses = PublicIPAddressesOperations( self._client, self.config, self._serialize, self._deserialize) self.network_security_groups = NetworkSecurityGroupsOperations( self._client, self.config, self._serialize, self._deserialize) self.security_rules = SecurityRulesOperations( self._client, self.config, self._serialize, self._deserialize) self.load_balancers = LoadBalancersOperations( self._client, self.config, self._serialize, self._deserialize) self.virtual_networks = VirtualNetworksOperations( self._client, self.config, self._serialize, self._deserialize) self.subnets = SubnetsOperations( self._client, self.config, self._serialize, self._deserialize) self.virtual_network_peerings = VirtualNetworkPeeringsOperations( self._client, self.config, self._serialize, self._deserialize) self.network_interfaces = NetworkInterfacesOperations( self._client, self.config, self._serialize, self._deserialize) self.usages = UsagesOperations( self._client, self.config, self._serialize, self._deserialize) self.virtual_network_gateways = VirtualNetworkGatewaysOperations( self._client, self.config, self._serialize, self._deserialize) self.virtual_network_gateway_connections = VirtualNetworkGatewayConnectionsOperations( self._client, self.config, self._serialize, self._deserialize) self.local_network_gateways = LocalNetworkGatewaysOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_circuit_authorizations = ExpressRouteCircuitAuthorizationsOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_circuit_peerings = ExpressRouteCircuitPeeringsOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_circuits = ExpressRouteCircuitsOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_service_providers = ExpressRouteServiceProvidersOperations( self._client, self.config, self._serialize, self._deserialize) def check_dns_name_availability( self, location, domain_name_label=None, custom_headers=None, raw=False, **operation_config): """Checks whether a domain name in the cloudapp.net zone is available for use. :param location: The location of the domain name. :type location: str :param domain_name_label: The domain name to be verified. It must conform to the following regular expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$. :type domain_name_label: 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:`DnsNameAvailabilityResult <azure.mgmt.network.models.DnsNameAvailabilityResult>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ api_version = "2016-09-01" # Construct URL url = '/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability' path_format_arguments = { 'location': self._serialize.url("location", location, 'str'), 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if domain_name_label is not None: query_parameters['domainNameLabel'] = self._serialize.query("domain_name_label", domain_name_label, 'str') query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct 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]: 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('DnsNameAvailabilityResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class IntuneResourceManagementClient(object): """Microsoft.Intune Resource provider Api features in the swagger-2.0 specification :ivar config: Configuration for client. :vartype config: IntuneResourceManagementClientConfiguration :ivar ios: Ios operations :vartype ios: .operations.IosOperations :ivar android: Android operations :vartype android: .operations.AndroidOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object<msrestazure.azure_active_directory>` :param api_version: Service Api Version. :type api_version: str :param accept_language: Gets or sets the preferred language for the response. :type accept_language: str :param long_running_operation_retry_timeout: Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. :type long_running_operation_retry_timeout: int :param generate_client_request_id: When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. :type generate_client_request_id: bool :param str base_url: Service URL :param str filepath: Existing config """ def __init__( self, credentials, api_version='2015-01-14-preview', accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): self.config = IntuneResourceManagementClientConfiguration(credentials, api_version, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.ios = IosOperations( self._client, self.config, self._serialize, self._deserialize) self.android = AndroidOperations( self._client, self.config, self._serialize, self._deserialize) def get_locations( self, custom_headers=None, raw=False, **operation_config): """Returns location for user tenant. :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:`LocationPaged <azure.mgmt.intune.models.LocationPaged>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = '/providers/Microsoft.Intune/locations' # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) return response # Deserialize response deserialized = models.LocationPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.LocationPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized def get_location_by_host_name( self, custom_headers=None, raw=False, **operation_config): """Returns location for given tenant. :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:`Location <azure.mgmt.intune.models.Location>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/providers/Microsoft.Intune/locations/hostName' # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Location', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def get_apps( self, host_name, filter=None, top=None, select=None, custom_headers=None, raw=False, **operation_config): """Returns Intune Manageable apps. :param host_name: Location hostName for the tenant :type host_name: str :param filter: The filter to apply on the operation. :type filter: str :param top: :type top: int :param select: select specific fields in entity. :type select: 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:`ApplicationPaged <azure.mgmt.intune.models.ApplicationPaged>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = '/providers/Microsoft.Intune/locations/{hostName}/apps' path_format_arguments = { 'hostName': self._serialize.url("host_name", host_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int') if select is not None: query_parameters['$select'] = self._serialize.query("select", select, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) return response # Deserialize response deserialized = models.ApplicationPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.ApplicationPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized def get_mam_user_devices( self, host_name, user_name, filter=None, top=None, select=None, custom_headers=None, raw=False, **operation_config): """Get devices for a user. :param host_name: Location hostName for the tenant :type host_name: str :param user_name: user unique Name :type user_name: str :param filter: The filter to apply on the operation. :type filter: str :param top: :type top: int :param select: select specific fields in entity. :type select: 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:`DevicePaged <azure.mgmt.intune.models.DevicePaged>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = '/providers/Microsoft.Intune/locations/{hostName}/users/{userName}/devices' path_format_arguments = { 'hostName': self._serialize.url("host_name", host_name, 'str'), 'userName': self._serialize.url("user_name", user_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int') if select is not None: query_parameters['$select'] = self._serialize.query("select", select, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) return response # Deserialize response deserialized = models.DevicePaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.DevicePaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized def get_mam_user_device_by_device_name( self, host_name, user_name, device_name, select=None, custom_headers=None, raw=False, **operation_config): """Get a unique device for a user. :param host_name: Location hostName for the tenant :type host_name: str :param user_name: unique user name :type user_name: str :param device_name: device name :type device_name: str :param select: select specific fields in entity. :type select: 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:`Device <azure.mgmt.intune.models.Device>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/providers/Microsoft.Intune/locations/{hostName}/users/{userName}/devices/{deviceName}' path_format_arguments = { 'hostName': self._serialize.url("host_name", host_name, 'str'), 'userName': self._serialize.url("user_name", user_name, 'str'), 'deviceName': self._serialize.url("device_name", device_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') if select is not None: query_parameters['$select'] = self._serialize.query("select", select, '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, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Device', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def wipe_mam_user_device( self, host_name, user_name, device_name, custom_headers=None, raw=False, **operation_config): """Wipe a device for a user. :param host_name: Location hostName for the tenant :type host_name: str :param user_name: unique user name :type user_name: str :param device_name: device name :type device_name: 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:`WipeDeviceOperationResult <azure.mgmt.intune.models.WipeDeviceOperationResult>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/providers/Microsoft.Intune/locations/{hostName}/users/{userName}/devices/{deviceName}/wipe' path_format_arguments = { 'hostName': self._serialize.url("host_name", host_name, 'str'), 'userName': self._serialize.url("user_name", user_name, 'str'), 'deviceName': self._serialize.url("device_name", device_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if 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, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('WipeDeviceOperationResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def get_operation_results( self, host_name, filter=None, top=None, select=None, custom_headers=None, raw=False, **operation_config): """Returns operationResults. :param host_name: Location hostName for the tenant :type host_name: str :param filter: The filter to apply on the operation. :type filter: str :param top: :type top: int :param select: select specific fields in entity. :type select: 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:`OperationResultPaged <azure.mgmt.intune.models.OperationResultPaged>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = '/providers/Microsoft.Intune/locations/{hostName}/operationResults' path_format_arguments = { 'hostName': self._serialize.url("host_name", host_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int') if select is not None: query_parameters['$select'] = self._serialize.query("select", select, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) return response # Deserialize response deserialized = models.OperationResultPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.OperationResultPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized def get_mam_statuses( self, host_name, custom_headers=None, raw=False, **operation_config): """Returns Intune Tenant level statuses. :param host_name: Location hostName for the tenant :type host_name: 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:`StatusesDefault <azure.mgmt.intune.models.StatusesDefault>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = '/providers/Microsoft.Intune/locations/{hostName}/statuses/default' path_format_arguments = { 'hostName': self._serialize.url("host_name", host_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) return response # Deserialize response deserialized = models.(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized def get_mam_flagged_users( self, host_name, filter=None, top=None, select=None, custom_headers=None, raw=False, **operation_config): """Returns Intune flagged user collection. :param host_name: Location hostName for the tenant :type host_name: str :param filter: The filter to apply on the operation. :type filter: str :param top: :type top: int :param select: select specific fields in entity. :type select: 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:`FlaggedUserPaged <azure.mgmt.intune.models.FlaggedUserPaged>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = '/providers/Microsoft.Intune/locations/{hostName}/flaggedUsers' path_format_arguments = { 'hostName': self._serialize.url("host_name", host_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int') if select is not None: query_parameters['$select'] = self._serialize.query("select", select, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) return response # Deserialize response deserialized = models.FlaggedUserPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.FlaggedUserPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized def get_mam_flagged_user_by_name( self, host_name, user_name, select=None, custom_headers=None, raw=False, **operation_config): """Returns Intune flagged user details. :param host_name: Location hostName for the tenant :type host_name: str :param user_name: Flagged userName :type user_name: str :param select: select specific fields in entity. :type select: 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:`FlaggedUser <azure.mgmt.intune.models.FlaggedUser>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/providers/Microsoft.Intune/locations/{hostName}/flaggedUsers/{userName}' path_format_arguments = { 'hostName': self._serialize.url("host_name", host_name, 'str'), 'userName': self._serialize.url("user_name", user_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') if select is not None: query_parameters['$select'] = self._serialize.query("select", select, '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, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('FlaggedUser', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def get_mam_user_flagged_enrolled_apps( self, host_name, user_name, filter=None, top=None, select=None, custom_headers=None, raw=False, **operation_config): """Returns Intune flagged enrolled app collection for the User. :param host_name: Location hostName for the tenant :type host_name: str :param user_name: User name for the tenant :type user_name: str :param filter: The filter to apply on the operation. :type filter: str :param top: :type top: int :param select: select specific fields in entity. :type select: 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:`FlaggedEnrolledAppPaged <azure.mgmt.intune.models.FlaggedEnrolledAppPaged>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = '/providers/Microsoft.Intune/locations/{hostName}/flaggedUsers/{userName}/flaggedEnrolledApps' path_format_arguments = { 'hostName': self._serialize.url("host_name", host_name, 'str'), 'userName': self._serialize.url("user_name", user_name, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') if filter is not None: query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') if top is not None: query_parameters['$top'] = self._serialize.query("top", top, 'int') if select is not None: query_parameters['$select'] = self._serialize.query("select", select, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) return response # Deserialize response deserialized = models.FlaggedEnrolledAppPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.FlaggedEnrolledAppPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized
class AutoRestReportServiceForAzure(object): """Test Infrastructure for AutoRest :ivar config: Configuration for client. :vartype config: AutoRestReportServiceForAzureConfiguration :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 = AutoRestReportServiceForAzureConfiguration( 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 = '1.0.0' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) def get_report(self, custom_headers=None, raw=False, **operation_config): """Get test coverage report. :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: dict or ClientRawResponse if raw=true :rtype: dict[str, int] or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorException<fixtures.acceptancetestsazurereport.models.ErrorException>` """ # Construct URL url = '/report/azure' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header( "self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('{int}', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class VstsInfoProvider(object): """VstsInfoProvider :ivar config: Configuration for client. :vartype config: AzureTfsConfiguration :param api_version: Version of the API to use. This should be set to '3.2-preview' to use this version of the api. :type api_version: str :param str vsts_git_url: vsts git URL :param Credentials creds: credentials for vsts """ def __init__(self, api_version, vsts_git_url, creds=None): self.config = VstsInfoProviderConfiguration(api_version, vsts_git_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 = '3.2' if not api_version else api_version self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) def get_vsts_info(self, custom_headers=None, raw=False, **operation_config): """GetContinuousDeploymentOperation. :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:`ContinuousDeploymentOperation <vsts_info_provider.models.ContinuousDeploymentOperation>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = '/vsts/info' # 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]: print("response:", response.status_code, file=stderr) print(response.text, file=stderr) raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('VstsInfo', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class PowerBIEmbeddedManagementClient(object): """Client to manage your Power BI Embedded workspace collections and retrieve workspaces. :ivar config: Configuration for client. :vartype config: PowerBIEmbeddedManagementClientConfiguration :ivar workspace_collections: WorkspaceCollections operations :vartype workspace_collections: azure.mgmt.powerbiembedded.operations.WorkspaceCollectionsOperations :ivar workspaces: Workspaces operations :vartype workspaces: azure.mgmt.powerbiembedded.operations.WorkspacesOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object<msrestazure.azure_active_directory>` :param subscription_id: Gets subscription credentials which uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str :param str base_url: Service URL """ def __init__(self, credentials, subscription_id, base_url=None): self.config = PowerBIEmbeddedManagementClientConfiguration( credentials, subscription_id, 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 = '2016-01-29' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.workspace_collections = WorkspaceCollectionsOperations( self._client, self.config, self._serialize, self._deserialize) self.workspaces = WorkspacesOperations(self._client, self.config, self._serialize, self._deserialize) def get_available_operations(self, custom_headers=None, raw=False, **operation_config): """Indicates which operations can be performed by the Power BI Resource Provider. :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:`OperationList <azure.mgmt.powerbiembedded.models.OperationList>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`ErrorException<azure.mgmt.powerbiembedded.models.ErrorException>` """ # Construct URL url = '/providers/Microsoft.PowerBI/operations' # 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, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('OperationList', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class NetworkManagementClient(object): """Composite Swagger for Network Client :ivar config: Configuration for client. :vartype config: NetworkManagementClientConfiguration :ivar application_gateways: ApplicationGateways operations :vartype application_gateways: azure.mgmt.network.v2017_06_01.operations.ApplicationGatewaysOperations :ivar express_route_circuit_authorizations: ExpressRouteCircuitAuthorizations operations :vartype express_route_circuit_authorizations: azure.mgmt.network.v2017_06_01.operations.ExpressRouteCircuitAuthorizationsOperations :ivar express_route_circuit_peerings: ExpressRouteCircuitPeerings operations :vartype express_route_circuit_peerings: azure.mgmt.network.v2017_06_01.operations.ExpressRouteCircuitPeeringsOperations :ivar express_route_circuits: ExpressRouteCircuits operations :vartype express_route_circuits: azure.mgmt.network.v2017_06_01.operations.ExpressRouteCircuitsOperations :ivar express_route_service_providers: ExpressRouteServiceProviders operations :vartype express_route_service_providers: azure.mgmt.network.v2017_06_01.operations.ExpressRouteServiceProvidersOperations :ivar load_balancers: LoadBalancers operations :vartype load_balancers: azure.mgmt.network.v2017_06_01.operations.LoadBalancersOperations :ivar network_interfaces: NetworkInterfaces operations :vartype network_interfaces: azure.mgmt.network.v2017_06_01.operations.NetworkInterfacesOperations :ivar network_security_groups: NetworkSecurityGroups operations :vartype network_security_groups: azure.mgmt.network.v2017_06_01.operations.NetworkSecurityGroupsOperations :ivar security_rules: SecurityRules operations :vartype security_rules: azure.mgmt.network.v2017_06_01.operations.SecurityRulesOperations :ivar network_watchers: NetworkWatchers operations :vartype network_watchers: azure.mgmt.network.v2017_06_01.operations.NetworkWatchersOperations :ivar packet_captures: PacketCaptures operations :vartype packet_captures: azure.mgmt.network.v2017_06_01.operations.PacketCapturesOperations :ivar public_ip_addresses: PublicIPAddresses operations :vartype public_ip_addresses: azure.mgmt.network.v2017_06_01.operations.PublicIPAddressesOperations :ivar route_filters: RouteFilters operations :vartype route_filters: azure.mgmt.network.v2017_06_01.operations.RouteFiltersOperations :ivar route_filter_rules: RouteFilterRules operations :vartype route_filter_rules: azure.mgmt.network.v2017_06_01.operations.RouteFilterRulesOperations :ivar route_tables: RouteTables operations :vartype route_tables: azure.mgmt.network.v2017_06_01.operations.RouteTablesOperations :ivar routes: Routes operations :vartype routes: azure.mgmt.network.v2017_06_01.operations.RoutesOperations :ivar bgp_service_communities: BgpServiceCommunities operations :vartype bgp_service_communities: azure.mgmt.network.v2017_06_01.operations.BgpServiceCommunitiesOperations :ivar usages: Usages operations :vartype usages: azure.mgmt.network.v2017_06_01.operations.UsagesOperations :ivar virtual_networks: VirtualNetworks operations :vartype virtual_networks: azure.mgmt.network.v2017_06_01.operations.VirtualNetworksOperations :ivar subnets: Subnets operations :vartype subnets: azure.mgmt.network.v2017_06_01.operations.SubnetsOperations :ivar virtual_network_peerings: VirtualNetworkPeerings operations :vartype virtual_network_peerings: azure.mgmt.network.v2017_06_01.operations.VirtualNetworkPeeringsOperations :ivar virtual_network_gateways: VirtualNetworkGateways operations :vartype virtual_network_gateways: azure.mgmt.network.v2017_06_01.operations.VirtualNetworkGatewaysOperations :ivar virtual_network_gateway_connections: VirtualNetworkGatewayConnections operations :vartype virtual_network_gateway_connections: azure.mgmt.network.v2017_06_01.operations.VirtualNetworkGatewayConnectionsOperations :ivar local_network_gateways: LocalNetworkGateways operations :vartype local_network_gateways: azure.mgmt.network.v2017_06_01.operations.LocalNetworkGatewaysOperations :ivar available_private_access_services: AvailablePrivateAccessServices operations :vartype available_private_access_services: azure.mgmt.network.v2017_06_01.operations.AvailablePrivateAccessServicesOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object<msrestazure.azure_active_directory>` :param subscription_id: The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str :param str base_url: Service URL """ def __init__(self, credentials, subscription_id, base_url=None): self.config = NetworkManagementClientConfiguration( credentials, subscription_id, 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._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.application_gateways = ApplicationGatewaysOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_circuit_authorizations = ExpressRouteCircuitAuthorizationsOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_circuit_peerings = ExpressRouteCircuitPeeringsOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_circuits = ExpressRouteCircuitsOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_service_providers = ExpressRouteServiceProvidersOperations( self._client, self.config, self._serialize, self._deserialize) self.load_balancers = LoadBalancersOperations(self._client, self.config, self._serialize, self._deserialize) self.network_interfaces = NetworkInterfacesOperations( self._client, self.config, self._serialize, self._deserialize) self.network_security_groups = NetworkSecurityGroupsOperations( self._client, self.config, self._serialize, self._deserialize) self.security_rules = SecurityRulesOperations(self._client, self.config, self._serialize, self._deserialize) self.network_watchers = NetworkWatchersOperations( self._client, self.config, self._serialize, self._deserialize) self.packet_captures = PacketCapturesOperations( self._client, self.config, self._serialize, self._deserialize) self.public_ip_addresses = PublicIPAddressesOperations( self._client, self.config, self._serialize, self._deserialize) self.route_filters = RouteFiltersOperations(self._client, self.config, self._serialize, self._deserialize) self.route_filter_rules = RouteFilterRulesOperations( self._client, self.config, self._serialize, self._deserialize) self.route_tables = RouteTablesOperations(self._client, self.config, self._serialize, self._deserialize) self.routes = RoutesOperations(self._client, self.config, self._serialize, self._deserialize) self.bgp_service_communities = BgpServiceCommunitiesOperations( self._client, self.config, self._serialize, self._deserialize) self.usages = UsagesOperations(self._client, self.config, self._serialize, self._deserialize) self.virtual_networks = VirtualNetworksOperations( self._client, self.config, self._serialize, self._deserialize) self.subnets = SubnetsOperations(self._client, self.config, self._serialize, self._deserialize) self.virtual_network_peerings = VirtualNetworkPeeringsOperations( self._client, self.config, self._serialize, self._deserialize) self.virtual_network_gateways = VirtualNetworkGatewaysOperations( self._client, self.config, self._serialize, self._deserialize) self.virtual_network_gateway_connections = VirtualNetworkGatewayConnectionsOperations( self._client, self.config, self._serialize, self._deserialize) self.local_network_gateways = LocalNetworkGatewaysOperations( self._client, self.config, self._serialize, self._deserialize) self.available_private_access_services = AvailablePrivateAccessServicesOperations( self._client, self.config, self._serialize, self._deserialize) def check_dns_name_availability(self, location, domain_name_label=None, custom_headers=None, raw=False, **operation_config): """Checks whether a domain name in the cloudapp.net zone is available for use. :param location: The location of the domain name. :type location: str :param domain_name_label: The domain name to be verified. It must conform to the following regular expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$. :type domain_name_label: 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:`DnsNameAvailabilityResult <azure.mgmt.network.v2017_06_01.models.DnsNameAvailabilityResult>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ api_version = "2017-06-01" # Construct URL url = '/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability' path_format_arguments = { 'location': self._serialize.url("location", location, 'str'), 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if domain_name_label is not None: query_parameters['domainNameLabel'] = self._serialize.query( "domain_name_label", domain_name_label, 'str') query_parameters['api-version'] = self._serialize.query( "api_version", api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header( "self.config.accept_language", self.config.accept_language, 'str') # Construct 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]: 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('DnsNameAvailabilityResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class SqlManagementClient(object): """The Azure SQL Database management API provides a RESTful set of web services that interact with Azure SQL Database services to manage your databases. The API enables you to create, retrieve, update, and delete databases. :ivar config: Configuration for client. :vartype config: SqlManagementClientConfiguration :ivar servers: Servers operations :vartype servers: .operations.ServersOperations :ivar databases: Databases operations :vartype databases: .operations.DatabasesOperations :ivar import_export_operations: ImportExportOperations operations :vartype import_export_operations: .operations.ImportExportOperations :ivar elastic_pools: ElasticPools operations :vartype elastic_pools: .operations.ElasticPoolsOperations :ivar recommended_elastic_pools: RecommendedElasticPools operations :vartype recommended_elastic_pools: .operations.RecommendedElasticPoolsOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object<msrestazure.azure_active_directory>` :param subscription_id: The subscription ID that identifies an Azure subscription. :type subscription_id: str :param str base_url: Service URL """ def __init__( self, credentials, subscription_id, base_url=None): self.config = SqlManagementClientConfiguration(credentials, subscription_id, 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._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.servers = ServersOperations( self._client, self.config, self._serialize, self._deserialize) self.databases = DatabasesOperations( self._client, self.config, self._serialize, self._deserialize) self.import_export_operations = ImportExportOperations( self._client, self.config, self._serialize, self._deserialize) self.elastic_pools = ElasticPoolsOperations( self._client, self.config, self._serialize, self._deserialize) self.recommended_elastic_pools = RecommendedElasticPoolsOperations( self._client, self.config, self._serialize, self._deserialize) def list_operations( self, custom_headers=None, raw=False, **operation_config): """Lists all of the available SQL Rest API operations. :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:`OperationListResult <azure.mgmt.sql.models.OperationListResult>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ api_version = "2014-04-01" # Construct URL url = '/providers/Microsoft.Sql/operations' # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct 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]: 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('OperationListResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class CdnManagementClient(object): """Use these APIs to manage Azure CDN resources through the Azure Resource Manager. You must make sure that requests made to these resources are secure. :ivar config: Configuration for client. :vartype config: CdnManagementClientConfiguration :ivar profiles: Profiles operations :vartype profiles: azure.mgmt.cdn.operations.ProfilesOperations :ivar endpoints: Endpoints operations :vartype endpoints: azure.mgmt.cdn.operations.EndpointsOperations :ivar origins: Origins operations :vartype origins: azure.mgmt.cdn.operations.OriginsOperations :ivar custom_domains: CustomDomains operations :vartype custom_domains: azure.mgmt.cdn.operations.CustomDomainsOperations :ivar resource_usage: ResourceUsage operations :vartype resource_usage: azure.mgmt.cdn.operations.ResourceUsageOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.cdn.operations.Operations :ivar edge_nodes: EdgeNodes operations :vartype edge_nodes: azure.mgmt.cdn.operations.EdgeNodesOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object<msrestazure.azure_active_directory>` :param subscription_id: Azure Subscription ID. :type subscription_id: str :param str base_url: Service URL """ def __init__(self, credentials, subscription_id, base_url=None): self.config = CdnManagementClientConfiguration(credentials, subscription_id, 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 = '2017-04-02' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.profiles = ProfilesOperations(self._client, self.config, self._serialize, self._deserialize) self.endpoints = EndpointsOperations(self._client, self.config, self._serialize, self._deserialize) self.origins = OriginsOperations(self._client, self.config, self._serialize, self._deserialize) self.custom_domains = CustomDomainsOperations(self._client, self.config, self._serialize, self._deserialize) self.resource_usage = ResourceUsageOperations(self._client, self.config, self._serialize, self._deserialize) self.operations = Operations(self._client, self.config, self._serialize, self._deserialize) self.edge_nodes = EdgeNodesOperations(self._client, self.config, self._serialize, self._deserialize) def check_name_availability(self, name, custom_headers=None, raw=False, **operation_config): """Check the availability of a resource name. This is needed for resources where name is globally unique, such as a CDN endpoint. :param name: The resource name to validate. :type name: 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: CheckNameAvailabilityOutput or ClientRawResponse if raw=true :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.mgmt.cdn.models.ErrorResponseException>` """ check_name_availability_input = models.CheckNameAvailabilityInput( name=name) # Construct URL url = '/providers/Microsoft.Cdn/checkNameAvailability' # 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(check_name_availability_input, 'CheckNameAvailabilityInput') # 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]: raise models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('CheckNameAvailabilityOutput', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def validate_probe(self, probe_url, custom_headers=None, raw=False, **operation_config): """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to a file hosted on the origin server to help accelerate the delivery of dynamic content via the CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. :param probe_url: The probe URL to validate. :type probe_url: 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: ValidateProbeOutput or ClientRawResponse if raw=true :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.mgmt.cdn.models.ErrorResponseException>` """ validate_probe_input = models.ValidateProbeInput(probe_url=probe_url) # Construct URL url = '/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/validateProbe' path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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(validate_probe_input, 'ValidateProbeInput') # 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]: raise models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('ValidateProbeOutput', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class CdnManagementClient(object): """Use these APIs to manage Azure CDN resources through the Azure Resource Manager. You must make sure that requests made to these resources are secure. :ivar config: Configuration for client. :vartype config: CdnManagementClientConfiguration :ivar profiles: Profiles operations :vartype profiles: .operations.ProfilesOperations :ivar endpoints: Endpoints operations :vartype endpoints: .operations.EndpointsOperations :ivar origins: Origins operations :vartype origins: .operations.OriginsOperations :ivar custom_domains: CustomDomains operations :vartype custom_domains: .operations.CustomDomainsOperations :ivar edge_nodes: EdgeNodes operations :vartype edge_nodes: .operations.EdgeNodesOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object<msrestazure.azure_active_directory>` :param subscription_id: Azure Subscription ID. :type subscription_id: str :param api_version: Version of the API to be used with the client request. Current version is 2016-10-02. :type api_version: str :param accept_language: Gets or sets the preferred language for the response. :type accept_language: str :param long_running_operation_retry_timeout: Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. :type long_running_operation_retry_timeout: int :param generate_client_request_id: When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. :type generate_client_request_id: bool :param str base_url: Service URL :param str filepath: Existing config """ def __init__( self, credentials, subscription_id, api_version="2016-10-02", accept_language="en-US", long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None, ): self.config = CdnManagementClientConfiguration( credentials, subscription_id, api_version, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath, ) self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.profiles = ProfilesOperations(self._client, self.config, self._serialize, self._deserialize) self.endpoints = EndpointsOperations(self._client, self.config, self._serialize, self._deserialize) self.origins = OriginsOperations(self._client, self.config, self._serialize, self._deserialize) self.custom_domains = CustomDomainsOperations(self._client, self.config, self._serialize, self._deserialize) self.edge_nodes = EdgeNodesOperations(self._client, self.config, self._serialize, self._deserialize) def check_name_availability(self, name, custom_headers=None, raw=False, **operation_config): """Check the availability of a resource name. This is needed for resources where name is globally unique, such as a CDN endpoint. :param name: The resource name to validate. :type name: 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:`CheckNameAvailabilityOutput <azure.mgmt.cdn.models.CheckNameAvailabilityOutput>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`ErrorResponseException<azure.mgmt.cdn.models.ErrorResponseException>` """ check_name_availability_input = models.CheckNameAvailabilityInput(name=name) # Construct URL url = "/providers/Microsoft.Cdn/checkNameAvailability" # Construct parameters query_parameters = {} query_parameters["api-version"] = self._serialize.query( "self.config.api_version", self.config.api_version, "str" ) # Construct headers header_parameters = {} header_parameters["Content-Type"] = "application/json; charset=utf-8" if 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(check_name_availability_input, "CheckNameAvailabilityInput") # 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]: raise models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize("CheckNameAvailabilityOutput", response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def check_resource_usage(self, custom_headers=None, raw=False, **operation_config): """Check the quota and actual usage of the CDN profiles under the given subscription. :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:`ResourceUsagePaged <azure.mgmt.cdn.models.ResourceUsagePaged>` :raises: :class:`ErrorResponseException<azure.mgmt.cdn.models.ErrorResponseException>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/checkResourceUsage" path_format_arguments = { "subscriptionId": self._serialize.url( "self.config.subscription_id", self.config.subscription_id, "str" ) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters["api-version"] = self._serialize.query( "self.config.api_version", self.config.api_version, "str" ) else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters["Content-Type"] = "application/json; charset=utf-8" if self.config.generate_client_request_id: header_parameters["x-ms-client-request-id"] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters["accept-language"] = self._serialize.header( "self.config.accept_language", self.config.accept_language, "str" ) # Construct and send request request = self._client.post(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorResponseException(self._deserialize, response) return response # Deserialize response deserialized = models.ResourceUsagePaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.ResourceUsagePaged( internal_paging, self._deserialize.dependencies, header_dict ) return client_raw_response return deserialized def list_operations(self, custom_headers=None, raw=False, **operation_config): """Lists all of the available CDN REST API operations. :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:`OperationPaged <azure.mgmt.cdn.models.OperationPaged>` :raises: :class:`ErrorResponseException<azure.mgmt.cdn.models.ErrorResponseException>` """ def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = "/providers/Microsoft.Cdn/operations" # Construct parameters query_parameters = {} query_parameters["api-version"] = self._serialize.query( "self.config.api_version", self.config.api_version, "str" ) else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters["Content-Type"] = "application/json; charset=utf-8" if self.config.generate_client_request_id: header_parameters["x-ms-client-request-id"] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters["accept-language"] = self._serialize.header( "self.config.accept_language", self.config.accept_language, "str" ) # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorResponseException(self._deserialize, response) return response # Deserialize response deserialized = models.OperationPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.OperationPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized
class AutoRestResourceFlatteningTestService(object): """Resource Flattening for AutoRest :ivar config: Configuration for client. :vartype config: AutoRestResourceFlatteningTestServiceConfiguration :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object<msrestazure.azure_active_directory>` :param accept_language: Gets or sets the preferred language for the response. :type accept_language: str :param long_running_operation_retry_timeout: Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. :type long_running_operation_retry_timeout: int :param generate_client_request_id: When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. :type generate_client_request_id: bool :param str base_url: Service URL :param str filepath: Existing config """ def __init__(self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): self.config = AutoRestResourceFlatteningTestServiceConfiguration( credentials, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) self._client = ServiceClient(self.config.credentials, self.config) client_models = { k: v for k, v in models.__dict__.items() if isinstance(v, type) } self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) def put_array(self, resource_array=None, custom_headers=None, raw=False, **operation_config): """Put External Resource as an Array. :param resource_array: External Resource as an Array to put :type resource_array: list of :class:`Resource <Fixtures.AcceptanceTestsAzureResource.models.Resource>` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: None :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/azure/resource-flatten/array' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header( "self.config.accept_language", self.config.accept_language, 'str') # Construct body if resource_array is not None: body_content = self._serialize.body(resource_array, '[Resource]') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send(request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_array(self, custom_headers=None, raw=False, **operation_config): """Get External Resource as an Array. :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: list of :class:`FlattenedProduct <Fixtures.AcceptanceTestsAzureResource.models.FlattenedProduct>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/azure/resource-flatten/array' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header( "self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[FlattenedProduct]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def put_dictionary(self, resource_dictionary=None, custom_headers=None, raw=False, **operation_config): """Put External Resource as a Dictionary. :param resource_dictionary: External Resource as a Dictionary to put :type resource_dictionary: dict :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 = '/azure/resource-flatten/dictionary' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header( "self.config.accept_language", self.config.accept_language, 'str') # Construct body if resource_dictionary is not None: body_content = self._serialize.body(resource_dictionary, '{FlattenedProduct}') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send(request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_dictionary(self, custom_headers=None, raw=False, **operation_config): """Get External Resource as a Dictionary. :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 = '/azure/resource-flatten/dictionary' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header( "self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('{FlattenedProduct}', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def put_resource_collection(self, resource_complex_object=None, custom_headers=None, raw=False, **operation_config): """Put External Resource as a ResourceCollection. :param resource_complex_object: External Resource as a ResourceCollection to put :type resource_complex_object: :class:`ResourceCollection <Fixtures.AcceptanceTestsAzureResource.models.ResourceCollection>` :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 = '/azure/resource-flatten/resourcecollection' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header( "self.config.accept_language", self.config.accept_language, 'str') # Construct body if resource_complex_object is not None: body_content = self._serialize.body(resource_complex_object, 'ResourceCollection') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send(request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_resource_collection(self, custom_headers=None, raw=False, **operation_config): """Get External Resource as a ResourceCollection. :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:`ResourceCollection <Fixtures.AcceptanceTestsAzureResource.models.ResourceCollection>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/azure/resource-flatten/resourcecollection' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header( "self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('ResourceCollection', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class EventGridClient(object): """EventGrid Client :ivar config: Configuration for client. :vartype config: EventGridClientConfiguration :param credentials: Subscription credentials which uniquely identify client subscription. :type credentials: None """ def __init__( self, credentials): self.config = EventGridClientConfiguration(credentials) 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 = '2018-01-01' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) def publish_events( self, topic_hostname, events, custom_headers=None, raw=False, **operation_config): """Publishes a batch of events to an Azure Event Grid topic. :param topic_hostname: The host name of the topic, e.g. topic1.westus2-1.eventgrid.azure.net :type topic_hostname: str :param events: An array of events to be published to Event Grid. :type events: list[~azure.eventgrid.models.EventGridEvent] :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 = '/api/events' path_format_arguments = { 'topicHostname': self._serialize.url("topic_hostname", topic_hostname, 'str', skip_quote=True) } 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 custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(events, '[EventGridEvent]') # 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) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response
class AutoRestValidationTest(object): """Test Infrastructure for AutoRest. No server backend exists for these tests. :ivar config: Configuration for client. :vartype config: AutoRestValidationTestConfiguration :param subscription_id: Subscription ID. :type subscription_id: str :param api_version: Required string following pattern \\d{2}-\\d{2}-\\d{4} :type api_version: str :param str base_url: Service URL :param str filepath: Existing config """ def __init__(self, subscription_id, api_version, base_url=None, filepath=None): self.config = AutoRestValidationTestConfiguration( subscription_id, api_version, 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 validation_of_method_parameters(self, resource_group_name, id, custom_headers=None, raw=False, **operation_config): """Validates input parameters on the method. See swagger for details. :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. :type resource_group_name: str :param id: Required int multiple of 10 from 100 to 1000. :type id: int :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: :class:`Product <fixtures.acceptancetestsvalidation.models.Product>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`ErrorException<fixtures.acceptancetestsvalidation.models.ErrorException>` """ # Construct URL url = '/fakepath/{subscriptionId}/{resourceGroupName}/{id}' path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=10, min_length=3, pattern='[a-zA-Z0-9]+'), 'id': self._serialize.url("id", id, 'int', maximum=1000, minimum=100, multiple=10) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['apiVersion'] = self._serialize.query( "self.config.api_version", self.config.api_version, 'str', pattern='\d{2}-\d{2}-\d{4}') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def validation_of_body(self, resource_group_name, id, body=None, custom_headers=None, raw=False, **operation_config): """Validates body parameters on the method. See swagger for details. :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. :type resource_group_name: str :param id: Required int multiple of 10 from 100 to 1000. :type id: int :param body: :type body: :class:`Product <fixtures.acceptancetestsvalidation.models.Product>` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: :class:`Product <fixtures.acceptancetestsvalidation.models.Product>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`ErrorException<fixtures.acceptancetestsvalidation.models.ErrorException>` """ # Construct URL url = '/fakepath/{subscriptionId}/{resourceGroupName}/{id}' path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=10, min_length=3, pattern='[a-zA-Z0-9]+'), 'id': self._serialize.url("id", id, 'int', maximum=1000, minimum=100, multiple=10) } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['apiVersion'] = self._serialize.query( "self.config.api_version", self.config.api_version, 'str', pattern='\d{2}-\d{2}-\d{4}') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body if body is not None: body_content = self._serialize.body(body, 'Product') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send(request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def 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 post_with_constant_in_body(self, body=None, custom_headers=None, raw=False, **operation_config): """ :param body: :type body: :class:`Product <fixtures.acceptancetestsvalidation.models.Product>` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: :class:`Product <fixtures.acceptancetestsvalidation.models.Product>` :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 body if body is not None: body_content = self._serialize.body(body, 'Product') 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]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class NetworkManagementClient(object): """The Microsoft Azure Network management API provides a RESTful set of web services that interact with Microsoft Azure Networks service to manage your network resources. The API has entities that capture the relationship between an end user and the Microsoft Azure Networks service. :ivar config: Configuration for client. :vartype config: NetworkManagementClientConfiguration :ivar application_gateways: ApplicationGateways operations :vartype application_gateways: .operations.ApplicationGatewaysOperations :ivar express_route_circuit_authorizations: ExpressRouteCircuitAuthorizations operations :vartype express_route_circuit_authorizations: .operations.ExpressRouteCircuitAuthorizationsOperations :ivar express_route_circuit_peerings: ExpressRouteCircuitPeerings operations :vartype express_route_circuit_peerings: .operations.ExpressRouteCircuitPeeringsOperations :ivar express_route_circuits: ExpressRouteCircuits operations :vartype express_route_circuits: .operations.ExpressRouteCircuitsOperations :ivar express_route_service_providers: ExpressRouteServiceProviders operations :vartype express_route_service_providers: .operations.ExpressRouteServiceProvidersOperations :ivar load_balancers: LoadBalancers operations :vartype load_balancers: .operations.LoadBalancersOperations :ivar local_network_gateways: LocalNetworkGateways operations :vartype local_network_gateways: .operations.LocalNetworkGatewaysOperations :ivar network_interfaces: NetworkInterfaces operations :vartype network_interfaces: .operations.NetworkInterfacesOperations :ivar network_security_groups: NetworkSecurityGroups operations :vartype network_security_groups: .operations.NetworkSecurityGroupsOperations :ivar public_ip_addresses: PublicIPAddresses operations :vartype public_ip_addresses: .operations.PublicIPAddressesOperations :ivar route_tables: RouteTables operations :vartype route_tables: .operations.RouteTablesOperations :ivar routes: Routes operations :vartype routes: .operations.RoutesOperations :ivar security_rules: SecurityRules operations :vartype security_rules: .operations.SecurityRulesOperations :ivar subnets: Subnets operations :vartype subnets: .operations.SubnetsOperations :ivar virtual_network_peerings: VirtualNetworkPeerings operations :vartype virtual_network_peerings: .operations.VirtualNetworkPeeringsOperations :ivar usages: Usages operations :vartype usages: .operations.UsagesOperations :ivar virtual_network_gateway_connections: VirtualNetworkGatewayConnections operations :vartype virtual_network_gateway_connections: .operations.VirtualNetworkGatewayConnectionsOperations :ivar virtual_network_gateways: VirtualNetworkGateways operations :vartype virtual_network_gateways: .operations.VirtualNetworkGatewaysOperations :ivar virtual_networks: VirtualNetworks operations :vartype virtual_networks: .operations.VirtualNetworksOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object<msrestazure.azure_active_directory>` :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str :param api_version: Client Api Version. :type api_version: str :param accept_language: Gets or sets the preferred language for the response. :type accept_language: str :param long_running_operation_retry_timeout: Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. :type long_running_operation_retry_timeout: int :param generate_client_request_id: When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. :type generate_client_request_id: bool :param str base_url: Service URL :param str filepath: Existing config """ def __init__( self, credentials, subscription_id, api_version='2016-09-01', accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): self.config = NetworkManagementClientConfiguration(credentials, subscription_id, api_version, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.application_gateways = ApplicationGatewaysOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_circuit_authorizations = ExpressRouteCircuitAuthorizationsOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_circuit_peerings = ExpressRouteCircuitPeeringsOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_circuits = ExpressRouteCircuitsOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_service_providers = ExpressRouteServiceProvidersOperations( self._client, self.config, self._serialize, self._deserialize) self.load_balancers = LoadBalancersOperations( self._client, self.config, self._serialize, self._deserialize) self.local_network_gateways = LocalNetworkGatewaysOperations( self._client, self.config, self._serialize, self._deserialize) self.network_interfaces = NetworkInterfacesOperations( self._client, self.config, self._serialize, self._deserialize) self.network_security_groups = NetworkSecurityGroupsOperations( self._client, self.config, self._serialize, self._deserialize) self.public_ip_addresses = PublicIPAddressesOperations( self._client, self.config, self._serialize, self._deserialize) self.route_tables = RouteTablesOperations( self._client, self.config, self._serialize, self._deserialize) self.routes = RoutesOperations( self._client, self.config, self._serialize, self._deserialize) self.security_rules = SecurityRulesOperations( self._client, self.config, self._serialize, self._deserialize) self.subnets = SubnetsOperations( self._client, self.config, self._serialize, self._deserialize) self.virtual_network_peerings = VirtualNetworkPeeringsOperations( self._client, self.config, self._serialize, self._deserialize) self.usages = UsagesOperations( self._client, self.config, self._serialize, self._deserialize) self.virtual_network_gateway_connections = VirtualNetworkGatewayConnectionsOperations( self._client, self.config, self._serialize, self._deserialize) self.virtual_network_gateways = VirtualNetworkGatewaysOperations( self._client, self.config, self._serialize, self._deserialize) self.virtual_networks = VirtualNetworksOperations( self._client, self.config, self._serialize, self._deserialize) def check_dns_name_availability( self, location, domain_name_label=None, custom_headers=None, raw=False, **operation_config): """Checks whether a domain name in the cloudapp.net zone is available for use. :param location: The location of the domain name :type location: str :param domain_name_label: The domain name to be verified. It must conform to the following regular expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$. :type domain_name_label: 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:`DnsNameAvailabilityResult <azure.mgmt.network.models.DnsNameAvailabilityResult>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ # Construct URL url = '/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability' path_format_arguments = { 'location': self._serialize.url("location", location, 'str'), 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if domain_name_label is not None: query_parameters['domainNameLabel'] = self._serialize.query("domain_name_label", domain_name_label, 'str') query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: 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('DnsNameAvailabilityResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class AutoRestReportServiceForAzure(object): """Test Infrastructure for AutoRest :ivar config: Configuration for client. :vartype config: AutoRestReportServiceForAzureConfiguration :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object<msrestazure.azure_active_directory>` :param accept_language: Gets or sets the preferred language for the response. :type accept_language: str :param long_running_operation_retry_timeout: Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. :type long_running_operation_retry_timeout: int :param generate_client_request_id: When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. :type generate_client_request_id: bool :param str base_url: Service URL :param str filepath: Existing config """ def __init__( self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): self.config = AutoRestReportServiceForAzureConfiguration(credentials, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) def get_report( self, custom_headers=None, raw=False, **operation_config): """Get test coverage report. :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 = '/report/azure' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('{int}', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class AutoRestResourceFlatteningTestService(object): """Resource Flattening for AutoRest :param config: Configuration for client. :type config: AutoRestResourceFlatteningTestServiceConfiguration """ def __init__(self, config): self._client = ServiceClient(None, config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer() self._deserialize = Deserializer(client_models) self.config = config def put_array( self, resource_array=None, custom_headers={}, raw=False, **operation_config): """ Put External Resource as an Array :param resource_array: External Resource as an Array to put :type resource_array: list of :class:`Resource <fixtures.acceptancetestsmodelflattening.models.Resource>` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: None :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/model-flatten/array' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body if resource_array is not None: body_content = self._serialize.body(resource_array, '[Resource]') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_array( self, custom_headers={}, raw=False, **operation_config): """ Get External Resource as an Array :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: list of :class:`FlattenedProduct <fixtures.acceptancetestsmodelflattening.models.FlattenedProduct>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/model-flatten/array' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[FlattenedProduct]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def put_dictionary( self, resource_dictionary=None, custom_headers={}, raw=False, **operation_config): """ Put External Resource as a Dictionary :param resource_dictionary: External Resource as a Dictionary to put :type resource_dictionary: dict :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: None :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/model-flatten/dictionary' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body if resource_dictionary is not None: body_content = self._serialize.body(resource_dictionary, '{FlattenedProduct}') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_dictionary( self, custom_headers={}, raw=False, **operation_config): """ Get External Resource as a Dictionary :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 = '/model-flatten/dictionary' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('{FlattenedProduct}', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def put_resource_collection( self, resource_complex_object=None, custom_headers={}, raw=False, **operation_config): """ Put External Resource as a ResourceCollection :param resource_complex_object: External Resource as a ResourceCollection to put :type resource_complex_object: :class:`ResourceCollection <fixtures.acceptancetestsmodelflattening.models.ResourceCollection>` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: None :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/model-flatten/resourcecollection' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct body if resource_complex_object is not None: body_content = self._serialize.body(resource_complex_object, 'ResourceCollection') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_resource_collection( self, custom_headers={}, raw=False, **operation_config): """ Get External Resource as a ResourceCollection :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:`ResourceCollection <fixtures.acceptancetestsmodelflattening.models.ResourceCollection>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/model-flatten/resourcecollection' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('ResourceCollection', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def put_simple_product( self, simple_body_product=None, custom_headers={}, raw=False, **operation_config): """ Put Simple Product with client flattening true on the model :param simple_body_product: Simple body product to put :type simple_body_product: :class:`SimpleProduct <fixtures.acceptancetestsmodelflattening.models.SimpleProduct>` :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:`SimpleProduct <fixtures.acceptancetestsmodelflattening.models.SimpleProduct>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ # Construct URL url = '/model-flatten/customFlattening' # 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 simple_body_product is not None: body_content = self._serialize.body(simple_body_product, 'SimpleProduct') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('SimpleProduct', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def post_flattened_simple_product( self, product_id, max_product_display_name, description=None, odatavalue=None, custom_headers={}, raw=False, **operation_config): """ Put Flattened Simple Product with client flattening true on the parameter :param product_id: Unique identifier representing a specific product for a given latitude & longitude. For example, uberX in San Francisco will have a different product_id than uberX in Los Angeles. :type product_id: str :param max_product_display_name: Display name of product. :type max_product_display_name: str :param description: Description of product. :type description: str :param odatavalue: URL value. :type odatavalue: 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:`SimpleProduct <fixtures.acceptancetestsmodelflattening.models.SimpleProduct>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ simple_body_product = models.SimpleProduct(product_id=product_id, description=description, max_product_display_name=max_product_display_name, odatavalue=odatavalue) # Construct URL url = '/model-flatten/customFlattening' # 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 simple_body_product is not None: body_content = self._serialize.body(simple_body_product, 'SimpleProduct') 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]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('SimpleProduct', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def put_simple_product_with_grouping( self, flatten_parameter_group, custom_headers={}, raw=False, **operation_config): """ Put Simple Product with client flattening true on the model :param flatten_parameter_group: Additional parameters for the operation :type flatten_parameter_group: :class:`FlattenParameterGroup <fixtures.acceptancetestsmodelflattening.models.FlattenParameterGroup>` :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:`SimpleProduct <fixtures.acceptancetestsmodelflattening.models.SimpleProduct>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true """ name = None if flatten_parameter_group is not None: name = flatten_parameter_group.name product_id = None if flatten_parameter_group is not None: product_id = flatten_parameter_group.product_id description = None if flatten_parameter_group is not None: description = flatten_parameter_group.description max_product_display_name = None if flatten_parameter_group is not None: max_product_display_name = flatten_parameter_group.max_product_display_name odatavalue = None if flatten_parameter_group is not None: odatavalue = flatten_parameter_group.odatavalue simple_body_product = models.SimpleProduct(product_id=product_id, description=description, max_product_display_name=max_product_display_name, odatavalue=odatavalue) # Construct URL url = '/model-flatten/customFlattening/parametergrouping/{name}/' path_format_arguments = { 'name': self._serialize.url("name", name, '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 simple_body_product is not None: body_content = self._serialize.body(simple_body_product, 'SimpleProduct') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('SimpleProduct', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class AutoRestValidationTest(object): """Test Infrastructure for AutoRest. No server backend exists for these tests. :param config: Configuration for client. :type config: AutoRestValidationTestConfiguration """ def __init__(self, config): self._client = ServiceClient(None, config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer() self._deserialize = Deserializer(client_models) self.config = config def validation_of_method_parameters( self, resource_group_name, id, custom_headers={}, raw=False, **operation_config): """ Validates input parameters on the method. See swagger for details. :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. :type resource_group_name: str :param id: Required int multiple of 10 from 100 to 1000. :type id: int :param dict custom_headers: headers that will be added to the request :param boolean raw: returns the direct response alongside the deserialized response :rtype: Product or msrest.pipeline.ClientRawResponse """ # Construct URL url = '/fakepath/{subscriptionId}/{resourceGroupName}/{id}' path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'id': self._serialize.url("id", id, 'int') } url = url.format(**path_format_arguments) # Construct parameters query_parameters = {} query_parameters['apiVersion'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def validation_of_body( self, resource_group_name, id, body=None, custom_headers={}, raw=False, **operation_config): """ Validates body parameters on the method. See swagger for details. :param resource_group_name: Required string between 3 and 10 chars with pattern [a-zA-Z0-9]+. :type resource_group_name: str :param id: Required int multiple of 10 from 100 to 1000. :type id: int :param body: :type body: Product or None :param dict custom_headers: headers that will be added to the request :param boolean raw: returns the direct response alongside the deserialized response :rtype: Product or msrest.pipeline.ClientRawResponse """ # Construct URL url = '/fakepath/{subscriptionId}/{resourceGroupName}/{id}' path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), 'id': self._serialize.url("id", id, 'int') } url = url.format(**path_format_arguments) # Construct parameters query_parameters = {} query_parameters['apiVersion'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') # Construct headers 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, 'Product') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def get_with_constant_in_path( self, constant_param, custom_headers={}, raw=False, **operation_config): """ :param constant_param: :type constant_param: str :param dict custom_headers: headers that will be added to the request :param boolean raw: returns the direct response alongside the deserialized response :rtype: None or msrest.pipeline.ClientRawResponse """ # Construct URL url = '/validation/constantsInPath/{constantParam}/value' path_format_arguments = { 'constantParam': self._serialize.url("constant_param", constant_param, 'str') } url = url.format(**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 post_with_constant_in_body( self, constant_param, body=None, custom_headers={}, raw=False, **operation_config): """ :param constant_param: :type constant_param: str :param body: :type body: Product or None :param dict custom_headers: headers that will be added to the request :param boolean raw: returns the direct response alongside the deserialized response :rtype: Product or msrest.pipeline.ClientRawResponse """ # Construct URL url = '/validation/constantsInPath/{constantParam}/value' path_format_arguments = { 'constantParam': self._serialize.url("constant_param", constant_param, 'str') } url = url.format(**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, 'Product') 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]: raise HttpOperationError(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class NetworkManagementClient(object): """Network Client :ivar config: Configuration for client. :vartype config: NetworkManagementClientConfiguration :ivar application_gateways: ApplicationGateways operations :vartype application_gateways: azure.mgmt.network.v2017_09_01.operations.ApplicationGatewaysOperations :ivar application_security_groups: ApplicationSecurityGroups operations :vartype application_security_groups: azure.mgmt.network.v2017_09_01.operations.ApplicationSecurityGroupsOperations :ivar available_endpoint_services: AvailableEndpointServices operations :vartype available_endpoint_services: azure.mgmt.network.v2017_09_01.operations.AvailableEndpointServicesOperations :ivar express_route_circuit_authorizations: ExpressRouteCircuitAuthorizations operations :vartype express_route_circuit_authorizations: azure.mgmt.network.v2017_09_01.operations.ExpressRouteCircuitAuthorizationsOperations :ivar express_route_circuit_peerings: ExpressRouteCircuitPeerings operations :vartype express_route_circuit_peerings: azure.mgmt.network.v2017_09_01.operations.ExpressRouteCircuitPeeringsOperations :ivar express_route_circuits: ExpressRouteCircuits operations :vartype express_route_circuits: azure.mgmt.network.v2017_09_01.operations.ExpressRouteCircuitsOperations :ivar express_route_service_providers: ExpressRouteServiceProviders operations :vartype express_route_service_providers: azure.mgmt.network.v2017_09_01.operations.ExpressRouteServiceProvidersOperations :ivar load_balancers: LoadBalancers operations :vartype load_balancers: azure.mgmt.network.v2017_09_01.operations.LoadBalancersOperations :ivar load_balancer_backend_address_pools: LoadBalancerBackendAddressPools operations :vartype load_balancer_backend_address_pools: azure.mgmt.network.v2017_09_01.operations.LoadBalancerBackendAddressPoolsOperations :ivar load_balancer_frontend_ip_configurations: LoadBalancerFrontendIPConfigurations operations :vartype load_balancer_frontend_ip_configurations: azure.mgmt.network.v2017_09_01.operations.LoadBalancerFrontendIPConfigurationsOperations :ivar inbound_nat_rules: InboundNatRules operations :vartype inbound_nat_rules: azure.mgmt.network.v2017_09_01.operations.InboundNatRulesOperations :ivar load_balancer_load_balancing_rules: LoadBalancerLoadBalancingRules operations :vartype load_balancer_load_balancing_rules: azure.mgmt.network.v2017_09_01.operations.LoadBalancerLoadBalancingRulesOperations :ivar load_balancer_network_interfaces: LoadBalancerNetworkInterfaces operations :vartype load_balancer_network_interfaces: azure.mgmt.network.v2017_09_01.operations.LoadBalancerNetworkInterfacesOperations :ivar load_balancer_probes: LoadBalancerProbes operations :vartype load_balancer_probes: azure.mgmt.network.v2017_09_01.operations.LoadBalancerProbesOperations :ivar network_interfaces: NetworkInterfaces operations :vartype network_interfaces: azure.mgmt.network.v2017_09_01.operations.NetworkInterfacesOperations :ivar network_interface_ip_configurations: NetworkInterfaceIPConfigurations operations :vartype network_interface_ip_configurations: azure.mgmt.network.v2017_09_01.operations.NetworkInterfaceIPConfigurationsOperations :ivar network_interface_load_balancers: NetworkInterfaceLoadBalancers operations :vartype network_interface_load_balancers: azure.mgmt.network.v2017_09_01.operations.NetworkInterfaceLoadBalancersOperations :ivar network_security_groups: NetworkSecurityGroups operations :vartype network_security_groups: azure.mgmt.network.v2017_09_01.operations.NetworkSecurityGroupsOperations :ivar security_rules: SecurityRules operations :vartype security_rules: azure.mgmt.network.v2017_09_01.operations.SecurityRulesOperations :ivar default_security_rules: DefaultSecurityRules operations :vartype default_security_rules: azure.mgmt.network.v2017_09_01.operations.DefaultSecurityRulesOperations :ivar network_watchers: NetworkWatchers operations :vartype network_watchers: azure.mgmt.network.v2017_09_01.operations.NetworkWatchersOperations :ivar packet_captures: PacketCaptures operations :vartype packet_captures: azure.mgmt.network.v2017_09_01.operations.PacketCapturesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.network.v2017_09_01.operations.Operations :ivar public_ip_addresses: PublicIPAddresses operations :vartype public_ip_addresses: azure.mgmt.network.v2017_09_01.operations.PublicIPAddressesOperations :ivar route_filters: RouteFilters operations :vartype route_filters: azure.mgmt.network.v2017_09_01.operations.RouteFiltersOperations :ivar route_filter_rules: RouteFilterRules operations :vartype route_filter_rules: azure.mgmt.network.v2017_09_01.operations.RouteFilterRulesOperations :ivar route_tables: RouteTables operations :vartype route_tables: azure.mgmt.network.v2017_09_01.operations.RouteTablesOperations :ivar routes: Routes operations :vartype routes: azure.mgmt.network.v2017_09_01.operations.RoutesOperations :ivar bgp_service_communities: BgpServiceCommunities operations :vartype bgp_service_communities: azure.mgmt.network.v2017_09_01.operations.BgpServiceCommunitiesOperations :ivar usages: Usages operations :vartype usages: azure.mgmt.network.v2017_09_01.operations.UsagesOperations :ivar virtual_networks: VirtualNetworks operations :vartype virtual_networks: azure.mgmt.network.v2017_09_01.operations.VirtualNetworksOperations :ivar subnets: Subnets operations :vartype subnets: azure.mgmt.network.v2017_09_01.operations.SubnetsOperations :ivar virtual_network_peerings: VirtualNetworkPeerings operations :vartype virtual_network_peerings: azure.mgmt.network.v2017_09_01.operations.VirtualNetworkPeeringsOperations :ivar virtual_network_gateways: VirtualNetworkGateways operations :vartype virtual_network_gateways: azure.mgmt.network.v2017_09_01.operations.VirtualNetworkGatewaysOperations :ivar virtual_network_gateway_connections: VirtualNetworkGatewayConnections operations :vartype virtual_network_gateway_connections: azure.mgmt.network.v2017_09_01.operations.VirtualNetworkGatewayConnectionsOperations :ivar local_network_gateways: LocalNetworkGateways operations :vartype local_network_gateways: azure.mgmt.network.v2017_09_01.operations.LocalNetworkGatewaysOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object<msrestazure.azure_active_directory>` :param subscription_id: The subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str :param str base_url: Service URL """ def __init__( self, credentials, subscription_id, base_url=None): self.config = NetworkManagementClientConfiguration(credentials, subscription_id, 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._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.application_gateways = ApplicationGatewaysOperations( self._client, self.config, self._serialize, self._deserialize) self.application_security_groups = ApplicationSecurityGroupsOperations( self._client, self.config, self._serialize, self._deserialize) self.available_endpoint_services = AvailableEndpointServicesOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_circuit_authorizations = ExpressRouteCircuitAuthorizationsOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_circuit_peerings = ExpressRouteCircuitPeeringsOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_circuits = ExpressRouteCircuitsOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_service_providers = ExpressRouteServiceProvidersOperations( self._client, self.config, self._serialize, self._deserialize) self.load_balancers = LoadBalancersOperations( self._client, self.config, self._serialize, self._deserialize) self.load_balancer_backend_address_pools = LoadBalancerBackendAddressPoolsOperations( self._client, self.config, self._serialize, self._deserialize) self.load_balancer_frontend_ip_configurations = LoadBalancerFrontendIPConfigurationsOperations( self._client, self.config, self._serialize, self._deserialize) self.inbound_nat_rules = InboundNatRulesOperations( self._client, self.config, self._serialize, self._deserialize) self.load_balancer_load_balancing_rules = LoadBalancerLoadBalancingRulesOperations( self._client, self.config, self._serialize, self._deserialize) self.load_balancer_network_interfaces = LoadBalancerNetworkInterfacesOperations( self._client, self.config, self._serialize, self._deserialize) self.load_balancer_probes = LoadBalancerProbesOperations( self._client, self.config, self._serialize, self._deserialize) self.network_interfaces = NetworkInterfacesOperations( self._client, self.config, self._serialize, self._deserialize) self.network_interface_ip_configurations = NetworkInterfaceIPConfigurationsOperations( self._client, self.config, self._serialize, self._deserialize) self.network_interface_load_balancers = NetworkInterfaceLoadBalancersOperations( self._client, self.config, self._serialize, self._deserialize) self.network_security_groups = NetworkSecurityGroupsOperations( self._client, self.config, self._serialize, self._deserialize) self.security_rules = SecurityRulesOperations( self._client, self.config, self._serialize, self._deserialize) self.default_security_rules = DefaultSecurityRulesOperations( self._client, self.config, self._serialize, self._deserialize) self.network_watchers = NetworkWatchersOperations( self._client, self.config, self._serialize, self._deserialize) self.packet_captures = PacketCapturesOperations( self._client, self.config, self._serialize, self._deserialize) self.operations = Operations( self._client, self.config, self._serialize, self._deserialize) self.public_ip_addresses = PublicIPAddressesOperations( self._client, self.config, self._serialize, self._deserialize) self.route_filters = RouteFiltersOperations( self._client, self.config, self._serialize, self._deserialize) self.route_filter_rules = RouteFilterRulesOperations( self._client, self.config, self._serialize, self._deserialize) self.route_tables = RouteTablesOperations( self._client, self.config, self._serialize, self._deserialize) self.routes = RoutesOperations( self._client, self.config, self._serialize, self._deserialize) self.bgp_service_communities = BgpServiceCommunitiesOperations( self._client, self.config, self._serialize, self._deserialize) self.usages = UsagesOperations( self._client, self.config, self._serialize, self._deserialize) self.virtual_networks = VirtualNetworksOperations( self._client, self.config, self._serialize, self._deserialize) self.subnets = SubnetsOperations( self._client, self.config, self._serialize, self._deserialize) self.virtual_network_peerings = VirtualNetworkPeeringsOperations( self._client, self.config, self._serialize, self._deserialize) self.virtual_network_gateways = VirtualNetworkGatewaysOperations( self._client, self.config, self._serialize, self._deserialize) self.virtual_network_gateway_connections = VirtualNetworkGatewayConnectionsOperations( self._client, self.config, self._serialize, self._deserialize) self.local_network_gateways = LocalNetworkGatewaysOperations( self._client, self.config, self._serialize, self._deserialize) def check_dns_name_availability( self, location, domain_name_label, custom_headers=None, raw=False, **operation_config): """Checks whether a domain name in the cloudapp.azure.com zone is available for use. :param location: The location of the domain name. :type location: str :param domain_name_label: The domain name to be verified. It must conform to the following regular expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$. :type domain_name_label: 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: DnsNameAvailabilityResult or ClientRawResponse if raw=true :rtype: ~azure.mgmt.network.v2017_09_01.models.DnsNameAvailabilityResult or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ api_version = "2017-09-01" # Construct URL url = '/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability' path_format_arguments = { 'location': self._serialize.url("location", location, 'str'), 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} query_parameters['domainNameLabel'] = self._serialize.query("domain_name_label", domain_name_label, 'str') query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct 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]: 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('DnsNameAvailabilityResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class CdnManagementClient(object): """Use these APIs to manage Azure CDN resources through the Azure Resource Manager. You must make sure that requests made to these resources are secure. :ivar config: Configuration for client. :vartype config: CdnManagementClientConfiguration :ivar profiles: Profiles operations :vartype profiles: azure.mgmt.cdn.operations.ProfilesOperations :ivar endpoints: Endpoints operations :vartype endpoints: azure.mgmt.cdn.operations.EndpointsOperations :ivar origins: Origins operations :vartype origins: azure.mgmt.cdn.operations.OriginsOperations :ivar custom_domains: CustomDomains operations :vartype custom_domains: azure.mgmt.cdn.operations.CustomDomainsOperations :ivar resource_usage: ResourceUsage operations :vartype resource_usage: azure.mgmt.cdn.operations.ResourceUsageOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.cdn.operations.Operations :ivar edge_nodes: EdgeNodes operations :vartype edge_nodes: azure.mgmt.cdn.operations.EdgeNodesOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object<msrestazure.azure_active_directory>` :param subscription_id: Azure Subscription ID. :type subscription_id: str :param str base_url: Service URL """ def __init__( self, credentials, subscription_id, base_url=None): self.config = CdnManagementClientConfiguration(credentials, subscription_id, 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 = '2017-04-02' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.profiles = ProfilesOperations( self._client, self.config, self._serialize, self._deserialize) self.endpoints = EndpointsOperations( self._client, self.config, self._serialize, self._deserialize) self.origins = OriginsOperations( self._client, self.config, self._serialize, self._deserialize) self.custom_domains = CustomDomainsOperations( self._client, self.config, self._serialize, self._deserialize) self.resource_usage = ResourceUsageOperations( self._client, self.config, self._serialize, self._deserialize) self.operations = Operations( self._client, self.config, self._serialize, self._deserialize) self.edge_nodes = EdgeNodesOperations( self._client, self.config, self._serialize, self._deserialize) def check_name_availability( self, name, custom_headers=None, raw=False, **operation_config): """Check the availability of a resource name. This is needed for resources where name is globally unique, such as a CDN endpoint. :param name: The resource name to validate. :type name: 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: CheckNameAvailabilityOutput or ClientRawResponse if raw=true :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.mgmt.cdn.models.ErrorResponseException>` """ check_name_availability_input = models.CheckNameAvailabilityInput(name=name) # Construct URL url = self.check_name_availability.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 body body_content = self._serialize.body(check_name_availability_input, 'CheckNameAvailabilityInput') # 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 models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('CheckNameAvailabilityOutput', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized check_name_availability.metadata = {'url': '/providers/Microsoft.Cdn/checkNameAvailability'} def validate_probe( self, probe_url, custom_headers=None, raw=False, **operation_config): """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to a file hosted on the origin server to help accelerate the delivery of dynamic content via the CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. :param probe_url: The probe URL to validate. :type probe_url: 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: ValidateProbeOutput or ClientRawResponse if raw=true :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.mgmt.cdn.models.ErrorResponseException>` """ validate_probe_input = models.ValidateProbeInput(probe_url=probe_url) # Construct URL url = self.validate_probe.metadata['url'] path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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(validate_probe_input, 'ValidateProbeInput') # 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 models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('ValidateProbeOutput', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized validate_probe.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/validateProbe'}
class OrganizationManager(): """ Manage DevOps organizations Create or list existing organizations Attributes: config: url configuration client: authentication client dserialize: deserializer to process http responses into python classes """ def __init__(self, base_url='https://app.vssps.visualstudio.com', creds=None, create_organization_url='https://app.vsaex.visualstudio.com'): """Inits OrganizationManager""" self._creds = creds self._config = Configuration(base_url=base_url) self._client = ServiceClient(creds, self._config) #need to make a secondary client for the creating organization as it uses a different base url self._create_organization_config = Configuration( base_url=create_organization_url) self._create_organization_client = ServiceClient( creds, self._create_organization_config) self._list_region_config = Configuration( base_url='https://aex.dev.azure.com') self._list_region_client = ServiceClient( creds, self._create_organization_config) client_models = { k: v for k, v in models.__dict__.items() if isinstance(v, type) } self._deserialize = Deserializer(client_models) self._user_mgr = UserManager(creds=self._creds) 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 list_organizations(self): """List what organizations this user is part of""" if not self._user_mgr.is_msa_account(): # Only need to do the one request as ids are the same organizations = self._list_organizations_request( self._user_mgr.aad_id) else: # Need to do a request for each of the ids and then combine them (disabled) #organizations_aad = self._list_organizations_request(self._user_mgr.aad_id, msa=False) #organizations_msa = self._list_organizations_request(self._user_mgr.msa_id, msa=True) #organizations = organizations_msa # Overwrite merge aad organizations with msa organizations #duplicated_aad_orgs = [] #for msa_org in organizations_msa.value: # duplicated_aad_orgs.extend([ # o for o in organizations_aad.value if o.accountName == msa_org.accountName # ]) #filtered_organizations_aad = [o for o in organizations_aad.value if (o not in duplicated_aad_orgs)] #organizations.value += list(filtered_organizations_aad) #organizations.count = len(organizations.value) organizations = self._list_organizations_request( self._user_mgr.msa_id, msa=True) return organizations def _list_organizations_request(self, member_id, msa=False): url = '/_apis/Commerce/Subscription' query_paramters = {} query_paramters['memberId'] = member_id query_paramters['includeMSAAccounts'] = True query_paramters['queryOnlyOwnerAccounts'] = True query_paramters['inlcudeDisabledAccounts'] = False query_paramters['providerNamespaceId'] = 'VisualStudioOnline' #construct header parameters header_parameters = {} header_parameters[ 'X-VSS-ForceMsaPassThrough'] = 'true' if msa else 'false' header_parameters['Accept'] = 'application/json' request = self._client.get(url, params=query_paramters) response = self._client.send(request, headers=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('Organizations', response) return deserialized 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 list_regions(self): """List what regions organizations can exist in""" # Construct URL url = '/_apis/hostacquisition/regions' #construct header parameters header_paramters = {} header_paramters['Accept'] = 'application/json' # Construct and send request request = self._list_region_client.get(url, headers=header_paramters) response = self._list_region_client.send(request) # 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('Regions', response) return deserialized def close_connection(self): """Close the sessions""" self._client.close() self._create_organization_client.close()
class NetworkManagementClient(object): """The Microsoft Azure Network management API provides a RESTful set of web services that interact with Microsoft Azure Networks service to manage your network resrources. The API has entities that capture the relationship between an end user and the Microsoft Azure Networks service. :param config: Configuration for client. :type config: NetworkManagementClientConfiguration :ivar application_gateways: ApplicationGateways operations :vartype application_gateways: .operations.ApplicationGatewaysOperations :ivar express_route_circuit_authorizations: ExpressRouteCircuitAuthorizations operations :vartype express_route_circuit_authorizations: .operations.ExpressRouteCircuitAuthorizationsOperations :ivar express_route_circuit_peerings: ExpressRouteCircuitPeerings operations :vartype express_route_circuit_peerings: .operations.ExpressRouteCircuitPeeringsOperations :ivar express_route_circuits: ExpressRouteCircuits operations :vartype express_route_circuits: .operations.ExpressRouteCircuitsOperations :ivar express_route_service_providers: ExpressRouteServiceProviders operations :vartype express_route_service_providers: .operations.ExpressRouteServiceProvidersOperations :ivar load_balancers: LoadBalancers operations :vartype load_balancers: .operations.LoadBalancersOperations :ivar local_network_gateways: LocalNetworkGateways operations :vartype local_network_gateways: .operations.LocalNetworkGatewaysOperations :ivar network_interfaces: NetworkInterfaces operations :vartype network_interfaces: .operations.NetworkInterfacesOperations :ivar network_security_groups: NetworkSecurityGroups operations :vartype network_security_groups: .operations.NetworkSecurityGroupsOperations :ivar public_ip_addresses: PublicIPAddresses operations :vartype public_ip_addresses: .operations.PublicIPAddressesOperations :ivar route_tables: RouteTables operations :vartype route_tables: .operations.RouteTablesOperations :ivar routes: Routes operations :vartype routes: .operations.RoutesOperations :ivar security_rules: SecurityRules operations :vartype security_rules: .operations.SecurityRulesOperations :ivar subnets: Subnets operations :vartype subnets: .operations.SubnetsOperations :ivar usages: Usages operations :vartype usages: .operations.UsagesOperations :ivar virtual_network_gateway_connections: VirtualNetworkGatewayConnections operations :vartype virtual_network_gateway_connections: .operations.VirtualNetworkGatewayConnectionsOperations :ivar virtual_network_gateways: VirtualNetworkGateways operations :vartype virtual_network_gateways: .operations.VirtualNetworkGatewaysOperations :ivar virtual_networks: VirtualNetworks operations :vartype virtual_networks: .operations.VirtualNetworksOperations """ def __init__(self, config): self._client = ServiceClient(config.credentials, config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer() self._deserialize = Deserializer(client_models) self.config = config self.application_gateways = ApplicationGatewaysOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_circuit_authorizations = ExpressRouteCircuitAuthorizationsOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_circuit_peerings = ExpressRouteCircuitPeeringsOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_circuits = ExpressRouteCircuitsOperations( self._client, self.config, self._serialize, self._deserialize) self.express_route_service_providers = ExpressRouteServiceProvidersOperations( self._client, self.config, self._serialize, self._deserialize) self.load_balancers = LoadBalancersOperations( self._client, self.config, self._serialize, self._deserialize) self.local_network_gateways = LocalNetworkGatewaysOperations( self._client, self.config, self._serialize, self._deserialize) self.network_interfaces = NetworkInterfacesOperations( self._client, self.config, self._serialize, self._deserialize) self.network_security_groups = NetworkSecurityGroupsOperations( self._client, self.config, self._serialize, self._deserialize) self.public_ip_addresses = PublicIPAddressesOperations( self._client, self.config, self._serialize, self._deserialize) self.route_tables = RouteTablesOperations( self._client, self.config, self._serialize, self._deserialize) self.routes = RoutesOperations( self._client, self.config, self._serialize, self._deserialize) self.security_rules = SecurityRulesOperations( self._client, self.config, self._serialize, self._deserialize) self.subnets = SubnetsOperations( self._client, self.config, self._serialize, self._deserialize) self.usages = UsagesOperations( self._client, self.config, self._serialize, self._deserialize) self.virtual_network_gateway_connections = VirtualNetworkGatewayConnectionsOperations( self._client, self.config, self._serialize, self._deserialize) self.virtual_network_gateways = VirtualNetworkGatewaysOperations( self._client, self.config, self._serialize, self._deserialize) self.virtual_networks = VirtualNetworksOperations( self._client, self.config, self._serialize, self._deserialize) def check_dns_name_availability( self, location, domain_name_label=None, custom_headers={}, raw=False, **operation_config): """ Checks whether a domain name in the cloudapp.net zone is available for use. :param location: The location of the domain name :type location: str :param domain_name_label: The domain name to be verified. It must conform to the following regular expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$. :type domain_name_label: str :param dict custom_headers: headers that will be added to the request :param boolean raw: returns the direct response alongside the deserialized response :rtype: DnsNameAvailabilityResult :rtype: msrest.pipeline.ClientRawResponse if raw=True """ # Construct URL url = '/subscriptions/{subscriptionId}/providers/Microsoft.Network/locations/{location}/CheckDnsNameAvailability' path_format_arguments = { 'location': self._serialize.url("location", location, 'str'), 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if domain_name_label is not None: query_parameters['domainNameLabel'] = self._serialize.query("domain_name_label", domain_name_label, 'str') query_parameters['api-version'] = self._serialize.query("self.config.api_version", self.config.api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: 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('DnsNameAvailabilityResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class TextAnalyticsAPI(object): """The Text Analytics API is a suite of text analytics web services built with best-in-class Microsoft machine learning algorithms. The API can be used to analyze unstructured text for tasks such as sentiment analysis, key phrase extraction and language detection. No training data is needed to use this API; just bring your text data. This API uses advanced natural language processing techniques to deliver best in class predictions. Further documentation can be found in https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview :ivar config: Configuration for client. :vartype config: TextAnalyticsAPIConfiguration :param azure_region: Supported Azure regions for Cognitive Services endpoints. Possible values include: 'westus', 'westeurope', 'southeastasia', 'eastus2', 'westcentralus', 'westus2', 'eastus', 'southcentralus', 'northeurope', 'eastasia', 'australiaeast', 'brazilsouth' :type azure_region: str or ~azure.cognitiveservices.language.textanalytics.models.AzureRegions :param credentials: Subscription credentials which uniquely identify client subscription. :type credentials: None """ def __init__( self, azure_region, credentials): self.config = TextAnalyticsAPIConfiguration(azure_region, credentials) 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.0' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) def key_phrases( self, documents=None, custom_headers=None, raw=False, **operation_config): """The API returns a list of strings denoting the key talking points in the input text. We employ techniques from Microsoft Office's sophisticated Natural Language Processing toolkit. See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text Analytics Documentation</a> for details about the languages that are supported by key phrase extraction. :param documents: :type documents: list[~azure.cognitiveservices.language.textanalytics.models.MultiLanguageInput] :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: KeyPhraseBatchResult or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.language.textanalytics.models.KeyPhraseBatchResult or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.cognitiveservices.language.textanalytics.models.ErrorResponseException>` """ input = models.MultiLanguageBatchInput(documents=documents) # Construct URL url = '/v2.0/keyPhrases' path_format_arguments = { 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) } 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(input, 'MultiLanguageBatchInput') # 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 models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('KeyPhraseBatchResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def detect_language( self, documents=None, custom_headers=None, raw=False, **operation_config): """The API returns the detected language and a numeric score between 0 and 1. Scores close to 1 indicate 100% certainty that the identified language is true. A total of 120 languages are supported. :param documents: :type documents: list[~azure.cognitiveservices.language.textanalytics.models.Input] :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: LanguageBatchResult or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.language.textanalytics.models.LanguageBatchResult or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.cognitiveservices.language.textanalytics.models.ErrorResponseException>` """ input = models.BatchInput(documents=documents) # Construct URL url = '/v2.0/languages' path_format_arguments = { 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) } 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(input, 'BatchInput') # 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 models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('LanguageBatchResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def sentiment( self, documents=None, custom_headers=None, raw=False, **operation_config): """The API returns a numeric score between 0 and 1. Scores close to 1 indicate positive sentiment, while scores close to 0 indicate negative sentiment. Sentiment score is generated using classification techniques. The input features to the classifier include n-grams, features generated from part-of-speech tags, and word embeddings. See the <a href="https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/overview#supported-languages">Text Analytics Documentation</a> for details about the languages that are supported by sentiment analysis. :param documents: :type documents: list[~azure.cognitiveservices.language.textanalytics.models.MultiLanguageInput] :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: SentimentBatchResult or ClientRawResponse if raw=true :rtype: ~azure.cognitiveservices.language.textanalytics.models.SentimentBatchResult or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<azure.cognitiveservices.language.textanalytics.models.ErrorResponseException>` """ input = models.MultiLanguageBatchInput(documents=documents) # Construct URL url = '/v2.0/sentiment' path_format_arguments = { 'AzureRegion': self._serialize.url("self.config.azure_region", self.config.azure_region, 'AzureRegions', skip_quote=True) } 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(input, 'MultiLanguageBatchInput') # 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 models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('SentimentBatchResult', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class AutoRestReportService(object): """Test Infrastructure for AutoRest :ivar config: Configuration for client. :vartype config: AutoRestReportServiceConfiguration :param str base_url: Service URL :param str filepath: Existing config """ def __init__(self, base_url=None, filepath=None): self.config = AutoRestReportServiceConfiguration(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 get_report(self, custom_headers=None, raw=False, **operation_config): """Get test coverage report. :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:`ErrorException<Fixtures.AcceptanceTestsReport.models.ErrorException>` """ # Construct URL url = "/report" # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters["Content-Type"] = "application/json; charset=utf-8" if custom_headers: header_parameters.update(custom_headers) # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize("{int}", response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class WebSiteManagementClient(object): """WebSite Management Client :ivar config: Configuration for client. :vartype config: WebSiteManagementClientConfiguration :ivar app_service_certificate_orders: AppServiceCertificateOrders operations :vartype app_service_certificate_orders: azure.mgmt.web.operations.AppServiceCertificateOrdersOperations :ivar domains: Domains operations :vartype domains: azure.mgmt.web.operations.DomainsOperations :ivar top_level_domains: TopLevelDomains operations :vartype top_level_domains: azure.mgmt.web.operations.TopLevelDomainsOperations :ivar certificates: Certificates operations :vartype certificates: azure.mgmt.web.operations.CertificatesOperations :ivar deleted_web_apps: DeletedWebApps operations :vartype deleted_web_apps: azure.mgmt.web.operations.DeletedWebAppsOperations :ivar provider: Provider operations :vartype provider: azure.mgmt.web.operations.ProviderOperations :ivar recommendations: Recommendations operations :vartype recommendations: azure.mgmt.web.operations.RecommendationsOperations :ivar web_apps: WebApps operations :vartype web_apps: azure.mgmt.web.operations.WebAppsOperations :ivar app_service_environments: AppServiceEnvironments operations :vartype app_service_environments: azure.mgmt.web.operations.AppServiceEnvironmentsOperations :ivar app_service_plans: AppServicePlans operations :vartype app_service_plans: azure.mgmt.web.operations.AppServicePlansOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object<msrestazure.azure_active_directory>` :param subscription_id: Your Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). :type subscription_id: str :param str base_url: Service URL """ def __init__( self, credentials, subscription_id, base_url=None): self.config = WebSiteManagementClientConfiguration(credentials, subscription_id, 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._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self.app_service_certificate_orders = AppServiceCertificateOrdersOperations( self._client, self.config, self._serialize, self._deserialize) self.domains = DomainsOperations( self._client, self.config, self._serialize, self._deserialize) self.top_level_domains = TopLevelDomainsOperations( self._client, self.config, self._serialize, self._deserialize) self.certificates = CertificatesOperations( self._client, self.config, self._serialize, self._deserialize) self.deleted_web_apps = DeletedWebAppsOperations( self._client, self.config, self._serialize, self._deserialize) self.provider = ProviderOperations( self._client, self.config, self._serialize, self._deserialize) self.recommendations = RecommendationsOperations( self._client, self.config, self._serialize, self._deserialize) self.web_apps = WebAppsOperations( self._client, self.config, self._serialize, self._deserialize) self.app_service_environments = AppServiceEnvironmentsOperations( self._client, self.config, self._serialize, self._deserialize) self.app_service_plans = AppServicePlansOperations( self._client, self.config, self._serialize, self._deserialize) def get_publishing_user( self, custom_headers=None, raw=False, **operation_config): """Gets publishing user. Gets publishing 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>`. :return: User or ClientRawResponse if raw=true :rtype: ~azure.mgmt.web.models.User or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ api_version = "2016-03-01" # Construct URL url = '/providers/Microsoft.Web/publishingUsers/web' # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct 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]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp deserialized = None if response.status_code == 200: deserialized = self._deserialize('User', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def update_publishing_user( self, user_details, custom_headers=None, raw=False, **operation_config): """Updates publishing user. Updates publishing user. :param user_details: Details of publishing user :type user_details: ~azure.mgmt.web.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>`. :return: User or ClientRawResponse if raw=true :rtype: ~azure.mgmt.web.models.User or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ api_version = "2016-03-01" # Construct URL url = '/providers/Microsoft.Web/publishingUsers/web' # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body body_content = self._serialize.body(user_details, 'User') # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp deserialized = None if response.status_code == 200: deserialized = self._deserialize('User', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def list_source_controls( self, custom_headers=None, raw=False, **operation_config): """Gets the source controls available for Azure websites. Gets the source controls available for Azure websites. :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: An iterator like instance of SourceControl :rtype: ~azure.mgmt.web.models.SourceControlPaged[~azure.mgmt.web.models.SourceControl] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ api_version = "2016-03-01" def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = '/providers/Microsoft.Web/sourcecontrols' # Construct parameters query_parameters = {} query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( request, header_parameters, **operation_config) if response.status_code not in [200]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp return response # Deserialize response deserialized = models.SourceControlPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.SourceControlPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized def get_source_control( self, source_control_type, custom_headers=None, raw=False, **operation_config): """Gets source control token. Gets source control token. :param source_control_type: Type of source control :type source_control_type: 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: SourceControl or ClientRawResponse if raw=true :rtype: ~azure.mgmt.web.models.SourceControl or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ api_version = "2016-03-01" # Construct URL url = '/providers/Microsoft.Web/sourcecontrols/{sourceControlType}' path_format_arguments = { 'sourceControlType': self._serialize.url("source_control_type", source_control_type, '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 self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: 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('SourceControl', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def update_source_control( self, source_control_type, request_message, custom_headers=None, raw=False, **operation_config): """Updates source control token. Updates source control token. :param source_control_type: Type of source control :type source_control_type: str :param request_message: Source control token information :type request_message: ~azure.mgmt.web.models.SourceControl :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: SourceControl or ClientRawResponse if raw=true :rtype: ~azure.mgmt.web.models.SourceControl or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ api_version = "2016-03-01" # Construct URL url = '/providers/Microsoft.Web/sourcecontrols/{sourceControlType}' path_format_arguments = { 'sourceControlType': self._serialize.url("source_control_type", source_control_type, '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 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(request_message, 'SourceControl') # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp deserialized = None if response.status_code == 200: deserialized = self._deserialize('SourceControl', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def check_name_availability( self, name, type, is_fqdn=None, custom_headers=None, raw=False, **operation_config): """Check if a resource name is available. Check if a resource name is available. :param name: Resource name to verify. :type name: str :param type: Resource type used for verification. Possible values include: 'Site', 'Slot', 'HostingEnvironment' :type type: str or ~azure.mgmt.web.models.CheckNameResourceTypes :param is_fqdn: Is fully qualified domain name. :type is_fqdn: bool :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: ResourceNameAvailability or ClientRawResponse if raw=true :rtype: ~azure.mgmt.web.models.ResourceNameAvailability or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ request = models.ResourceNameAvailabilityRequest(name=name, type=type, is_fqdn=is_fqdn) api_version = "2016-03-01" # Construct URL url = '/subscriptions/{subscriptionId}/providers/Microsoft.Web/checknameavailability' path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 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(request, 'ResourceNameAvailabilityRequest') # 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]: 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('ResourceNameAvailability', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def get_subscription_deployment_locations( self, custom_headers=None, raw=False, **operation_config): """Gets list of available geo regions plus ministamps. Gets list of available geo regions plus ministamps. :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: DeploymentLocations or ClientRawResponse if raw=true :rtype: ~azure.mgmt.web.models.DeploymentLocations or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ api_version = "2016-03-01" # Construct URL url = '/subscriptions/{subscriptionId}/providers/Microsoft.Web/deploymentLocations' path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: 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('DeploymentLocations', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def list_geo_regions( self, sku=None, linux_workers_enabled=None, custom_headers=None, raw=False, **operation_config): """Get a list of available geographical regions. Get a list of available geographical regions. :param sku: Name of SKU used to filter the regions. Possible values include: 'Free', 'Shared', 'Basic', 'Standard', 'Premium', 'PremiumV2', 'Dynamic', 'Isolated' :type sku: str or ~azure.mgmt.web.models.SkuName :param linux_workers_enabled: Specify <code>true</code> if you want to filter to only regions that support Linux workers. :type linux_workers_enabled: bool :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: An iterator like instance of GeoRegion :rtype: ~azure.mgmt.web.models.GeoRegionPaged[~azure.mgmt.web.models.GeoRegion] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ api_version = "2016-03-01" def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = '/subscriptions/{subscriptionId}/providers/Microsoft.Web/geoRegions' path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') } url = self._client.format_url(url, **path_format_arguments) # Construct parameters query_parameters = {} if sku is not None: query_parameters['sku'] = self._serialize.query("sku", sku, 'str') if linux_workers_enabled is not None: query_parameters['linuxWorkersEnabled'] = self._serialize.query("linux_workers_enabled", linux_workers_enabled, 'bool') query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( request, header_parameters, **operation_config) if response.status_code not in [200]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp return response # Deserialize response deserialized = models.GeoRegionPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.GeoRegionPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized def list_premier_add_on_offers( self, custom_headers=None, raw=False, **operation_config): """List all premier add-on offers. List all premier add-on offers. :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: An iterator like instance of PremierAddOnOffer :rtype: ~azure.mgmt.web.models.PremierAddOnOfferPaged[~azure.mgmt.web.models.PremierAddOnOffer] :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ api_version = "2016-03-01" def internal_paging(next_link=None, raw=False): if not next_link: # Construct URL url = '/subscriptions/{subscriptionId}/providers/Microsoft.Web/premieraddonoffers' path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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') else: url = next_link query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send( request, header_parameters, **operation_config) if response.status_code not in [200]: exp = CloudError(response) exp.request_id = response.headers.get('x-ms-request-id') raise exp return response # Deserialize response deserialized = models.PremierAddOnOfferPaged(internal_paging, self._deserialize.dependencies) if raw: header_dict = {} client_raw_response = models.PremierAddOnOfferPaged(internal_paging, self._deserialize.dependencies, header_dict) return client_raw_response return deserialized def list_skus( self, custom_headers=None, raw=False, **operation_config): """List all SKUs. List all SKUs. :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: SkuInfos or ClientRawResponse if raw=true :rtype: ~azure.mgmt.web.models.SkuInfos or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ api_version = "2016-03-01" # Construct URL url = '/subscriptions/{subscriptionId}/providers/Microsoft.Web/skus' path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: 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('SkuInfos', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def verify_hosting_environment_vnet( self, parameters, custom_headers=None, raw=False, **operation_config): """Verifies if this VNET is compatible with an App Service Environment by analyzing the Network Security Group rules. Verifies if this VNET is compatible with an App Service Environment by analyzing the Network Security Group rules. :param parameters: VNET information :type parameters: ~azure.mgmt.web.models.VnetParameters :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: VnetValidationFailureDetails or ClientRawResponse if raw=true :rtype: ~azure.mgmt.web.models.VnetValidationFailureDetails or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ api_version = "2016-03-01" # Construct URL url = '/subscriptions/{subscriptionId}/providers/Microsoft.Web/verifyHostingEnvironmentVnet' path_format_arguments = { 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 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(parameters, 'VnetParameters') # 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]: 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('VnetValidationFailureDetails', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def move( self, resource_group_name, target_resource_group=None, resources=None, custom_headers=None, raw=False, **operation_config): """Move resources between resource groups. Move resources between resource groups. :param resource_group_name: Name of the resource group to which the resource belongs. :type resource_group_name: str :param target_resource_group: :type target_resource_group: str :param resources: :type resources: 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: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ move_resource_envelope = models.CsmMoveResourceEnvelope(target_resource_group=target_resource_group, resources=resources) api_version = "2016-03-01" # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/moveResources' path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'), 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 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(move_resource_envelope, 'CsmMoveResourceEnvelope') # 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 [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 def validate( self, resource_group_name, validate_request, custom_headers=None, raw=False, **operation_config): """Validate if a resource can be created. Validate if a resource can be created. :param resource_group_name: Name of the resource group to which the resource belongs. :type resource_group_name: str :param validate_request: Request with the resources to validate. :type validate_request: ~azure.mgmt.web.models.ValidateRequest :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: ValidateResponse or ClientRawResponse if raw=true :rtype: ~azure.mgmt.web.models.ValidateResponse or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ api_version = "2016-03-01" # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/validate' path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'), 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 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(validate_request, 'ValidateRequest') # 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]: 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('ValidateResponse', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def validate_move( self, resource_group_name, target_resource_group=None, resources=None, custom_headers=None, raw=False, **operation_config): """Validate whether a resource can be moved. Validate whether a resource can be moved. :param resource_group_name: Name of the resource group to which the resource belongs. :type resource_group_name: str :param target_resource_group: :type target_resource_group: str :param resources: :type resources: 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: None or ClientRawResponse if raw=true :rtype: None or ~msrest.pipeline.ClientRawResponse :raises: :class:`CloudError<msrestazure.azure_exceptions.CloudError>` """ move_resource_envelope = models.CsmMoveResourceEnvelope(target_resource_group=target_resource_group, resources=resources) api_version = "2016-03-01" # Construct URL url = '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/validateMoveResources' path_format_arguments = { 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+[^\.]$'), 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_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 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(move_resource_envelope, 'CsmMoveResourceEnvelope') # 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 [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
class AutoRestResourceFlatteningTestService(object): """Resource Flattening for AutoRest :ivar config: Configuration for client. :vartype config: AutoRestResourceFlatteningTestServiceConfiguration :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials object<msrestazure.azure_active_directory>` :param accept_language: Gets or sets the preferred language for the response. :type accept_language: str :param long_running_operation_retry_timeout: Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. :type long_running_operation_retry_timeout: int :param generate_client_request_id: When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. :type generate_client_request_id: bool :param str base_url: Service URL :param str filepath: Existing config """ def __init__( self, credentials, accept_language='en-US', long_running_operation_retry_timeout=30, generate_client_request_id=True, base_url=None, filepath=None): self.config = AutoRestResourceFlatteningTestServiceConfiguration(credentials, accept_language, long_running_operation_retry_timeout, generate_client_request_id, base_url, filepath) self._client = ServiceClient(self.config.credentials, self.config) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) def put_array( self, resource_array=None, custom_headers=None, raw=False, **operation_config): """Put External Resource as an Array. :param resource_array: External Resource as an Array to put :type resource_array: list of :class:`Resource <fixtures.acceptancetestsazureresource.models.Resource>` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: None :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`ErrorException<fixtures.acceptancetestsazureresource.models.ErrorException>` """ # Construct URL url = '/azure/resource-flatten/array' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body if resource_array is not None: body_content = self._serialize.body(resource_array, '[Resource]') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_array( self, custom_headers=None, raw=False, **operation_config): """Get External Resource as an Array. :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: list of :class:`FlattenedProduct <fixtures.acceptancetestsazureresource.models.FlattenedProduct>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`ErrorException<fixtures.acceptancetestsazureresource.models.ErrorException>` """ # Construct URL url = '/azure/resource-flatten/array' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('[FlattenedProduct]', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def put_dictionary( self, resource_dictionary=None, custom_headers=None, raw=False, **operation_config): """Put External Resource as a Dictionary. :param resource_dictionary: External Resource as a Dictionary to put :type resource_dictionary: dict :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: None :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`ErrorException<fixtures.acceptancetestsazureresource.models.ErrorException>` """ # Construct URL url = '/azure/resource-flatten/dictionary' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body if resource_dictionary is not None: body_content = self._serialize.body(resource_dictionary, '{FlattenedProduct}') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_dictionary( self, custom_headers=None, raw=False, **operation_config): """Get External Resource as a Dictionary. :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:`ErrorException<fixtures.acceptancetestsazureresource.models.ErrorException>` """ # Construct URL url = '/azure/resource-flatten/dictionary' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('{FlattenedProduct}', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized def put_resource_collection( self, resource_complex_object=None, custom_headers=None, raw=False, **operation_config): """Put External Resource as a ResourceCollection. :param resource_complex_object: External Resource as a ResourceCollection to put :type resource_complex_object: :class:`ResourceCollection <fixtures.acceptancetestsazureresource.models.ResourceCollection>` :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :rtype: None :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`ErrorException<fixtures.acceptancetestsazureresource.models.ErrorException>` """ # Construct URL url = '/azure/resource-flatten/resourcecollection' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body if resource_complex_object is not None: body_content = self._serialize.body(resource_complex_object, 'ResourceCollection') else: body_content = None # Construct and send request request = self._client.put(url, query_parameters) response = self._client.send( request, header_parameters, body_content, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) if raw: client_raw_response = ClientRawResponse(None, response) return client_raw_response def get_resource_collection( self, custom_headers=None, raw=False, **operation_config): """Get External Resource as a ResourceCollection. :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:`ResourceCollection <fixtures.acceptancetestsazureresource.models.ResourceCollection>` :rtype: :class:`ClientRawResponse<msrest.pipeline.ClientRawResponse>` if raw=true :raises: :class:`ErrorException<fixtures.acceptancetestsazureresource.models.ErrorException>` """ # Construct URL url = '/azure/resource-flatten/resourcecollection' # Construct parameters query_parameters = {} # Construct headers header_parameters = {} header_parameters['Content-Type'] = 'application/json; charset=utf-8' if self.config.generate_client_request_id: header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) if custom_headers: header_parameters.update(custom_headers) if self.config.accept_language is not None: header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct and send request request = self._client.get(url, query_parameters) response = self._client.send(request, header_parameters, **operation_config) if response.status_code not in [200]: raise models.ErrorException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize('ResourceCollection', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
class RestClient(object): """This is the Open API specification of the Burdock execution service. :ivar config: Configuration for client. :vartype config: RestClientConfiguration :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 = RestClientConfiguration(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 = '0.0.1' self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) def executerun(self, details, custom_headers=None, raw=False, **operation_config): """Execute a differentially private module. Create a run of the specified module and return the results. :param details: Configuration for the module run. :type details: ~restclient.models.ProjectRunDetails :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: ExecuterunOKResponse or ClientRawResponse if raw=true :rtype: ~restclient.models.ExecuterunOKResponse or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.executerun.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(details, 'ProjectRunDetails') # 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('ExecuterunOKResponse', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized executerun.metadata = {'url': '/execute'} def datasetread(self, info, custom_headers=None, raw=False, **operation_config): """Read the details for reading the dataset. Return the details of the requested dataset. :param info: Get the dataset read info :type info: ~restclient.models.DatasetReadRequest :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: DatasetDocument or ClientRawResponse if raw=true :rtype: ~restclient.models.DatasetDocument or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.datasetread.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(info, 'DatasetReadRequest') # 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('DatasetDocument', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized datasetread.metadata = {'url': '/dataset'} def secretsput(self, secret, custom_headers=None, raw=False, **operation_config): """Add a secret to the secret store. Add the secret to the secret store. :param secret: Add a secret :type secret: ~restclient.models.Secret :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: SecretPutSuccess or ClientRawResponse if raw=true :rtype: ~restclient.models.SecretPutSuccess or ~msrest.pipeline.ClientRawResponse :raises: :class:`HttpOperationError<msrest.exceptions.HttpOperationError>` """ # Construct URL url = self.secretsput.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(secret, 'Secret') # 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('SecretPutSuccess', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized secretsput.metadata = {'url': '/secrets'}