|
| 1 | +# coding=utf-8 |
| 2 | +# -------------------------------------------------------------------------- |
| 3 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 4 | +# Licensed under the MIT License. See License.txt in the project root for license information. |
| 5 | +# Code generated by Microsoft (R) AutoRest Code Generator. |
| 6 | +# Changes may cause incorrect behavior and will be lost if the code is regenerated. |
| 7 | +# -------------------------------------------------------------------------- |
| 8 | + |
| 9 | +from copy import deepcopy |
| 10 | +from typing import Any, TYPE_CHECKING |
| 11 | + |
| 12 | +from azure.core import PipelineClient |
| 13 | +from azure.core.rest import HttpRequest, HttpResponse |
| 14 | + |
| 15 | +from ._configuration import EasmClientConfiguration |
| 16 | +from ._serialization import Deserializer, Serializer |
| 17 | +from .operations import ( |
| 18 | + AssetsOperations, |
| 19 | + DiscoveryGroupsOperations, |
| 20 | + DiscoveryTemplatesOperations, |
| 21 | + ReportsOperations, |
| 22 | + SavedFiltersOperations, |
| 23 | + TasksOperations, |
| 24 | +) |
| 25 | + |
| 26 | +if TYPE_CHECKING: |
| 27 | + # pylint: disable=unused-import,ungrouped-imports |
| 28 | + from azure.core.credentials import TokenCredential |
| 29 | + |
| 30 | + |
| 31 | +class EasmClient: # pylint: disable=client-accepts-api-version-keyword |
| 32 | + """Defender EASM discovers and maps your digital attack surface to provide an "outside-in" |
| 33 | + perspective using probes to discover assets. The assets are provided with detailed metadata |
| 34 | + associated, including vulnerabilities, configurations and web components, allowing customers to |
| 35 | + view and prioritize external risk. The EASM REST API enables you to develop clients that |
| 36 | + integrate with your application. |
| 37 | +
|
| 38 | + :ivar assets: AssetsOperations operations |
| 39 | + :vartype assets: azure.defender.easm.operations.AssetsOperations |
| 40 | + :ivar discovery_groups: DiscoveryGroupsOperations operations |
| 41 | + :vartype discovery_groups: azure.defender.easm.operations.DiscoveryGroupsOperations |
| 42 | + :ivar discovery_templates: DiscoveryTemplatesOperations operations |
| 43 | + :vartype discovery_templates: azure.defender.easm.operations.DiscoveryTemplatesOperations |
| 44 | + :ivar reports: ReportsOperations operations |
| 45 | + :vartype reports: azure.defender.easm.operations.ReportsOperations |
| 46 | + :ivar saved_filters: SavedFiltersOperations operations |
| 47 | + :vartype saved_filters: azure.defender.easm.operations.SavedFiltersOperations |
| 48 | + :ivar tasks: TasksOperations operations |
| 49 | + :vartype tasks: azure.defender.easm.operations.TasksOperations |
| 50 | + :param endpoint: The endpoint hosting the requested resource. For example, |
| 51 | + {region}.easm.defender.microsoft.com. Required. |
| 52 | + :type endpoint: str |
| 53 | + :param resource_group_name: The name of the Resource Group. Required. |
| 54 | + :type resource_group_name: str |
| 55 | + :param subscription_id: The ID of the target subscription. Required. |
| 56 | + :type subscription_id: str |
| 57 | + :param workspace_name: The name of the Workspace. Required. |
| 58 | + :type workspace_name: str |
| 59 | + :param credential: Credential needed for the client to connect to Azure. Required. |
| 60 | + :type credential: ~azure.core.credentials.TokenCredential |
| 61 | + :keyword api_version: Api Version. Default value is "2022-11-01-preview". Note that overriding |
| 62 | + this default value may result in unsupported behavior. |
| 63 | + :paramtype api_version: str |
| 64 | + """ |
| 65 | + |
| 66 | + def __init__( |
| 67 | + self, |
| 68 | + endpoint: str, |
| 69 | + resource_group_name: str, |
| 70 | + subscription_id: str, |
| 71 | + workspace_name: str, |
| 72 | + credential: "TokenCredential", |
| 73 | + **kwargs: Any |
| 74 | + ) -> None: |
| 75 | + _endpoint = "https://{endpoint}" |
| 76 | + self._config = EasmClientConfiguration( |
| 77 | + endpoint=endpoint, |
| 78 | + resource_group_name=resource_group_name, |
| 79 | + subscription_id=subscription_id, |
| 80 | + workspace_name=workspace_name, |
| 81 | + credential=credential, |
| 82 | + **kwargs |
| 83 | + ) |
| 84 | + self._client = PipelineClient(base_url=_endpoint, config=self._config, **kwargs) |
| 85 | + |
| 86 | + self._serialize = Serializer() |
| 87 | + self._deserialize = Deserializer() |
| 88 | + self._serialize.client_side_validation = False |
| 89 | + self.assets = AssetsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 90 | + self.discovery_groups = DiscoveryGroupsOperations( |
| 91 | + self._client, self._config, self._serialize, self._deserialize |
| 92 | + ) |
| 93 | + self.discovery_templates = DiscoveryTemplatesOperations( |
| 94 | + self._client, self._config, self._serialize, self._deserialize |
| 95 | + ) |
| 96 | + self.reports = ReportsOperations(self._client, self._config, self._serialize, self._deserialize) |
| 97 | + self.saved_filters = SavedFiltersOperations(self._client, self._config, self._serialize, self._deserialize) |
| 98 | + self.tasks = TasksOperations(self._client, self._config, self._serialize, self._deserialize) |
| 99 | + |
| 100 | + def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: |
| 101 | + """Runs the network request through the client's chained policies. |
| 102 | +
|
| 103 | + >>> from azure.core.rest import HttpRequest |
| 104 | + >>> request = HttpRequest("GET", "https://www.example.org/") |
| 105 | + <HttpRequest [GET], url: 'https://www.example.org/'> |
| 106 | + >>> response = client.send_request(request) |
| 107 | + <HttpResponse: 200 OK> |
| 108 | +
|
| 109 | + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request |
| 110 | +
|
| 111 | + :param request: The network request you want to make. Required. |
| 112 | + :type request: ~azure.core.rest.HttpRequest |
| 113 | + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. |
| 114 | + :return: The response of your network call. Does not do error handling on your response. |
| 115 | + :rtype: ~azure.core.rest.HttpResponse |
| 116 | + """ |
| 117 | + |
| 118 | + request_copy = deepcopy(request) |
| 119 | + path_format_arguments = { |
| 120 | + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str"), |
| 121 | + } |
| 122 | + |
| 123 | + request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) |
| 124 | + return self._client.send_request(request_copy, **kwargs) |
| 125 | + |
| 126 | + def close(self) -> None: |
| 127 | + self._client.close() |
| 128 | + |
| 129 | + def __enter__(self) -> "EasmClient": |
| 130 | + self._client.__enter__() |
| 131 | + return self |
| 132 | + |
| 133 | + def __exit__(self, *exc_details) -> None: |
| 134 | + self._client.__exit__(*exc_details) |
0 commit comments