Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/azure/mgmt/core/_pipeline_client.py: 28%

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

18 statements  

1# -------------------------------------------------------------------------- 

2# 

3# Copyright (c) Microsoft Corporation. All rights reserved. 

4# 

5# The MIT License (MIT) 

6# 

7# Permission is hereby granted, free of charge, to any person obtaining a copy 

8# of this software and associated documentation files (the ""Software""), to 

9# deal in the Software without restriction, including without limitation the 

10# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 

11# sell copies of the Software, and to permit persons to whom the Software is 

12# furnished to do so, subject to the following conditions: 

13# 

14# The above copyright notice and this permission notice shall be included in 

15# all copies or substantial portions of the Software. 

16# 

17# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 

18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 

19# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 

20# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 

21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 

22# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 

23# IN THE SOFTWARE. 

24# 

25# -------------------------------------------------------------------------- 

26from collections.abc import Iterable 

27from azure.core import PipelineClient 

28from .policies import ARMAutoResourceProviderRegistrationPolicy, ARMHttpLoggingPolicy 

29 

30 

31class ARMPipelineClient(PipelineClient): 

32 """A pipeline client designed for ARM explicitly. 

33 

34 :param str base_url: URL for the request. 

35 :keyword Pipeline pipeline: If omitted, a Pipeline object is created and returned. 

36 :keyword list[HTTPPolicy] policies: If omitted, the standard policies of the configuration object is used. 

37 :keyword per_call_policies: If specified, the policies will be added into the policy list before RetryPolicy 

38 :paramtype per_call_policies: Union[HTTPPolicy, SansIOHTTPPolicy, list[HTTPPolicy], list[SansIOHTTPPolicy]] 

39 :keyword per_retry_policies: If specified, the policies will be added into the policy list after RetryPolicy 

40 :paramtype per_retry_policies: Union[HTTPPolicy, SansIOHTTPPolicy, list[HTTPPolicy], list[SansIOHTTPPolicy]] 

41 :keyword HttpTransport transport: If omitted, RequestsTransport is used for synchronous transport. 

42 """ 

43 

44 def __init__(self, base_url, **kwargs): 

45 if "policies" not in kwargs: 

46 if "config" not in kwargs: 

47 raise ValueError("Current implementation requires to pass 'config' if you don't pass 'policies'") 

48 per_call_policies = kwargs.get("per_call_policies", []) 

49 if isinstance(per_call_policies, Iterable): 

50 per_call_policies.append(ARMAutoResourceProviderRegistrationPolicy()) 

51 else: 

52 per_call_policies = [ 

53 per_call_policies, 

54 ARMAutoResourceProviderRegistrationPolicy(), 

55 ] 

56 kwargs["per_call_policies"] = per_call_policies 

57 config = kwargs.get("config") 

58 if not config.http_logging_policy: 

59 config.http_logging_policy = kwargs.get("http_logging_policy", ARMHttpLoggingPolicy(**kwargs)) 

60 kwargs["config"] = config 

61 super(ARMPipelineClient, self).__init__(base_url, **kwargs)