MCPcopy Create free account
hub / github.com/adobe/Marinus / UltraDNSHelper

Class UltraDNSHelper

python3_cron_scripts/libs3/UltraDNSHelper.py:29–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27
28
29class UltraDNSHelper(object):
30 refresh_token = None
31 access_token = None
32 zone_queried = None
33 previous_zones = None
34 jobs_manager = None
35 offset = 0
36 source = "UltraDNS"
37 # This is as required by the UltraDNS documentation.
38 access_token_expiration_error = "invalid_grant:Token not found, expired or invalid."
39
40 MC = MongoConnector.MongoConnector()
41 APIH = APIHelper.APIHelper()
42
43 # Get the UltraDNS connection data
44 ULTRACONNECT = UltraDNSConnector.UltraDNSConnector()
45
46 zones_collection = MC.get_zone_connection()
47
48 _logger = None
49
50 def _log(self):
51 """
52 Get the log
53 """
54 return logging.getLogger(__name__)
55
56 @backoff.on_exception(
57 backoff.expo,
58 requests.exceptions.ConnectionError,
59 max_tries=4,
60 factor=10,
61 on_backoff=APIH.connection_error_retry,
62 )
63 def backoff_api_retry(self, url, params, headers):
64 """
65 Makes API calls with exponential retry capabilities using 'backoff'. The API is
66 retried 3 times in case of ConnectionError exception before the script exists.
67 """
68 return requests.get(url, params, headers=headers, timeout=120)
69
70 @backoff.on_exception(
71 backoff.expo,
72 requests.exceptions.ConnectionError,
73 max_tries=4,
74 factor=10,
75 on_backoff=APIH.connection_error_retry,
76 )
77 def login(self, grant_type):
78 """
79 Retrieves the access and refresh token to login into UltraDNS.
80 The first call is made with grant_type=password. Any subsequent request
81 to fetch the accessToken is made with grant_type=refresh_token.
82 :param grant_type: String specifying the grant_type
83 """
84 login_url = self.ULTRACONNECT.LOGIN
85 data = dict()
86 data["grant_type"] = grant_type

Callers

nothing calls this directly

Calls 1

get_zone_connectionMethod · 0.45

Tested by

no test coverage detected