@@ -54,16 +54,16 @@ def get_backoff_time(self):
54
54
55
55
class BaseClient :
56
56
def __init__ (
57
- self ,
58
- token ,
59
- base_url ,
60
- user_agent = None ,
61
- page_size = None ,
62
- retry = True ,
63
- retry_rate_limit_interval = 1.0 ,
64
- retry_max = 5 ,
65
- retry_statuses = None ,
66
- ca_path = None ,
57
+ self ,
58
+ token ,
59
+ base_url ,
60
+ user_agent = None ,
61
+ page_size = None ,
62
+ retry = True ,
63
+ retry_rate_limit_interval = 1.0 ,
64
+ retry_max = 5 ,
65
+ retry_statuses = None ,
66
+ ca_path = None ,
67
67
):
68
68
self .base_url = base_url
69
69
self ._add_user_agent = user_agent
@@ -147,7 +147,7 @@ def load(self, target_type, target_id, target_parent_id=None):
147
147
return result
148
148
149
149
def _api_call (
150
- self , endpoint , model = None , method = None , data = None , filters = None
150
+ self , endpoint , model = None , method = None , data = None , filters = None
151
151
):
152
152
"""
153
153
Makes a call to the linode api. Data should only be given if the method is
@@ -201,7 +201,7 @@ def _api_call(
201
201
return j
202
202
203
203
def _get_objects (
204
- self , endpoint , cls , model = None , parent_id = None , filters = None
204
+ self , endpoint , cls , model = None , parent_id = None , filters = None
205
205
):
206
206
# handle non-default page sizes
207
207
call_endpoint = endpoint
@@ -268,11 +268,11 @@ def __setattr__(self, key, value):
268
268
269
269
# helper functions
270
270
def _get_and_filter (
271
- self ,
272
- obj_type ,
273
- * filters ,
274
- endpoint = None ,
275
- parent_id = None ,
271
+ self ,
272
+ obj_type ,
273
+ * filters ,
274
+ endpoint = None ,
275
+ parent_id = None ,
276
276
):
277
277
parsed_filters = None
278
278
if filters :
@@ -299,16 +299,16 @@ def _get_and_filter(
299
299
300
300
class LinodeClient (BaseClient ):
301
301
def __init__ (
302
- self ,
303
- token ,
304
- base_url = "https://api.linode.com/v4" ,
305
- user_agent = None ,
306
- page_size = None ,
307
- retry = True ,
308
- retry_rate_limit_interval = 1.0 ,
309
- retry_max = 5 ,
310
- retry_statuses = None ,
311
- ca_path = None ,
302
+ self ,
303
+ token ,
304
+ base_url = "https://api.linode.com/v4" ,
305
+ user_agent = None ,
306
+ page_size = None ,
307
+ retry = True ,
308
+ retry_rate_limit_interval = 1.0 ,
309
+ retry_max = 5 ,
310
+ retry_statuses = None ,
311
+ ca_path = None ,
312
312
):
313
313
"""
314
314
The main interface to the Linode API.
@@ -346,38 +346,6 @@ def __init__(
346
346
:param ca_path: The path to a CA file to use for API requests in this client.
347
347
:type ca_path: str
348
348
"""
349
- # retry_forcelist = [408, 429, 502]
350
- #
351
- # if retry_statuses is not None:
352
- # retry_forcelist.extend(retry_statuses)
353
- #
354
- # # Ensure the max retries value is valid
355
- # if not isinstance(retry_max, int):
356
- # raise ValueError("retry_max must be an int")
357
- #
358
- # self.retry = retry
359
- # self.retry_rate_limit_interval = float(retry_rate_limit_interval)
360
- # self.retry_max = retry_max
361
- # self.retry_statuses = retry_forcelist
362
- #
363
- # # Initialize the HTTP client session
364
- # self.session = requests.Session()
365
- #
366
- # self._retry_config = LinearRetry(
367
- # total=retry_max if retry else 0,
368
- # status_forcelist=self.retry_statuses,
369
- # respect_retry_after_header=True,
370
- # backoff_factor=self.retry_rate_limit_interval,
371
- # raise_on_status=False,
372
- # # By default, POST is not an allowed method.
373
- # # We should explicitly include it.
374
- # allowed_methods={"DELETE", "GET", "POST", "PUT"},
375
- # )
376
- # retry_adapter = HTTPAdapter(max_retries=self._retry_config)
377
- #
378
- # self.session.mount("http://", retry_adapter)
379
- # self.session.mount("https://", retry_adapter)
380
-
381
349
#: Access methods related to Linodes - see :any:`LinodeGroup` for
382
350
#: more information
383
351
self .linode = LinodeGroup (self )
@@ -466,11 +434,11 @@ def image_create(self, disk, label=None, description=None, tags=None):
466
434
)
467
435
468
436
def image_create_upload (
469
- self ,
470
- label : str ,
471
- region : str ,
472
- description : Optional [str ] = None ,
473
- tags : Optional [List [str ]] = None ,
437
+ self ,
438
+ label : str ,
439
+ region : str ,
440
+ description : Optional [str ] = None ,
441
+ tags : Optional [List [str ]] = None ,
474
442
) -> Tuple [Image , str ]:
475
443
"""
476
444
.. note:: This method is an alias to maintain backwards compatibility.
@@ -483,12 +451,12 @@ def image_create_upload(
483
451
)
484
452
485
453
def image_upload (
486
- self ,
487
- label : str ,
488
- region : str ,
489
- file : BinaryIO ,
490
- description : Optional [str ] = None ,
491
- tags : Optional [List [str ]] = None ,
454
+ self ,
455
+ label : str ,
456
+ region : str ,
457
+ file : BinaryIO ,
458
+ description : Optional [str ] = None ,
459
+ tags : Optional [List [str ]] = None ,
492
460
) -> Image :
493
461
"""
494
462
.. note:: This method is an alias to maintain backwards compatibility.
@@ -516,13 +484,13 @@ def domain_create(self, domain, master=True, **kwargs):
516
484
return self .domains .create (domain , master = master , ** kwargs )
517
485
518
486
def tag_create (
519
- self ,
520
- label ,
521
- instances = None ,
522
- domains = None ,
523
- nodebalancers = None ,
524
- volumes = None ,
525
- entities = [],
487
+ self ,
488
+ label ,
489
+ instances = None ,
490
+ domains = None ,
491
+ nodebalancers = None ,
492
+ volumes = None ,
493
+ entities = [],
526
494
):
527
495
"""
528
496
.. note:: This method is an alias to maintain backwards compatibility.
@@ -576,20 +544,19 @@ class MonitorClient(BaseClient):
576
544
"""
577
545
578
546
def __init__ (
579
- self ,
580
- token ,
581
- base_url = "https://monitor-api.linode.com/v2beta" ,
582
- user_agent = None ,
583
- page_size = None ,
584
- ca_path = None ,
585
- retry = True ,
586
- retry_rate_limit_interval = 1.0 ,
587
- retry_max = 5 ,
588
- retry_statuses = None ,
547
+ self ,
548
+ token ,
549
+ base_url = "https://monitor-api.linode.com/v2beta" ,
550
+ user_agent = None ,
551
+ page_size = None ,
552
+ ca_path = None ,
553
+ retry = True ,
554
+ retry_rate_limit_interval = 1.0 ,
555
+ retry_max = 5 ,
556
+ retry_statuses = None ,
589
557
):
590
- # define properties and modules
591
-
592
- # define a metric group and add access to it through MonitorClient
558
+ #: Access methods related to your monitor metrics - see :any:`MetricsGroup` for
559
+ #: more information
593
560
self .metrics = MetricsGroup (self )
594
561
595
562
super (MonitorClient , self ).__init__ (
@@ -601,5 +568,5 @@ def __init__(
601
568
retry_rate_limit_interval = retry_rate_limit_interval ,
602
569
retry_max = retry_max ,
603
570
retry_statuses = retry_statuses ,
604
- ca_path = ca_path
571
+ ca_path = ca_path ,
605
572
)
0 commit comments