Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/azure/mgmt/dynatrace/_dynatrace_observability_mgmt_client.py: 44%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

34 statements  

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 

9from copy import deepcopy 

10from typing import Any, TYPE_CHECKING 

11 

12from azure.core.rest import HttpRequest, HttpResponse 

13from azure.mgmt.core import ARMPipelineClient 

14 

15from . import models as _models 

16from ._configuration import DynatraceObservabilityMgmtClientConfiguration 

17from ._serialization import Deserializer, Serializer 

18from .operations import MonitorsOperations, Operations, SingleSignOnOperations, TagRulesOperations 

19 

20if TYPE_CHECKING: 

21 # pylint: disable=unused-import,ungrouped-imports 

22 from azure.core.credentials import TokenCredential 

23 

24 

25class DynatraceObservabilityMgmtClient: # pylint: disable=client-accepts-api-version-keyword 

26 """DynatraceObservabilityMgmtClient. 

27 

28 :ivar monitors: MonitorsOperations operations 

29 :vartype monitors: azure.mgmt.dynatrace.operations.MonitorsOperations 

30 :ivar operations: Operations operations 

31 :vartype operations: azure.mgmt.dynatrace.operations.Operations 

32 :ivar tag_rules: TagRulesOperations operations 

33 :vartype tag_rules: azure.mgmt.dynatrace.operations.TagRulesOperations 

34 :ivar single_sign_on: SingleSignOnOperations operations 

35 :vartype single_sign_on: azure.mgmt.dynatrace.operations.SingleSignOnOperations 

36 :param credential: Credential needed for the client to connect to Azure. Required. 

37 :type credential: ~azure.core.credentials.TokenCredential 

38 :param subscription_id: The ID of the target subscription. Required. 

39 :type subscription_id: str 

40 :param base_url: Service URL. Default value is "https://management.azure.com". 

41 :type base_url: str 

42 :keyword api_version: Api Version. Default value is "2023-04-27". Note that overriding this 

43 default value may result in unsupported behavior. 

44 :paramtype api_version: str 

45 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no 

46 Retry-After header is present. 

47 """ 

48 

49 def __init__( 

50 self, 

51 credential: "TokenCredential", 

52 subscription_id: str, 

53 base_url: str = "https://management.azure.com", 

54 **kwargs: Any 

55 ) -> None: 

56 self._config = DynatraceObservabilityMgmtClientConfiguration( 

57 credential=credential, subscription_id=subscription_id, **kwargs 

58 ) 

59 self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) 

60 

61 client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} 

62 self._serialize = Serializer(client_models) 

63 self._deserialize = Deserializer(client_models) 

64 self._serialize.client_side_validation = False 

65 self.monitors = MonitorsOperations(self._client, self._config, self._serialize, self._deserialize) 

66 self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) 

67 self.tag_rules = TagRulesOperations(self._client, self._config, self._serialize, self._deserialize) 

68 self.single_sign_on = SingleSignOnOperations(self._client, self._config, self._serialize, self._deserialize) 

69 

70 def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: 

71 """Runs the network request through the client's chained policies. 

72 

73 >>> from azure.core.rest import HttpRequest 

74 >>> request = HttpRequest("GET", "https://www.example.org/") 

75 <HttpRequest [GET], url: 'https://www.example.org/'> 

76 >>> response = client._send_request(request) 

77 <HttpResponse: 200 OK> 

78 

79 For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request 

80 

81 :param request: The network request you want to make. Required. 

82 :type request: ~azure.core.rest.HttpRequest 

83 :keyword bool stream: Whether the response payload will be streamed. Defaults to False. 

84 :return: The response of your network call. Does not do error handling on your response. 

85 :rtype: ~azure.core.rest.HttpResponse 

86 """ 

87 

88 request_copy = deepcopy(request) 

89 request_copy.url = self._client.format_url(request_copy.url) 

90 return self._client.send_request(request_copy, **kwargs) 

91 

92 def close(self) -> None: 

93 self._client.close() 

94 

95 def __enter__(self) -> "DynatraceObservabilityMgmtClient": 

96 self._client.__enter__() 

97 return self 

98 

99 def __exit__(self, *exc_details: Any) -> None: 

100 self._client.__exit__(*exc_details)