Skip to content

Commit e8d46b8

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Regenerate client from commit 39e9110 of spec repo (#152)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent 01f2873 commit e8d46b8

File tree

7 files changed

+122
-114
lines changed

7 files changed

+122
-114
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.3.0",
7-
"regenerated": "2020-11-16 10:16:59.959518",
8-
"spec_repo_commit": "81a95d1"
7+
"regenerated": "2020-11-16 16:32:33.369096",
8+
"spec_repo_commit": "39e9110"
99
},
1010
"v2": {
1111
"apigentools_version": "1.3.0",
12-
"regenerated": "2020-11-16 10:17:11.730032",
13-
"spec_repo_commit": "81a95d1"
12+
"regenerated": "2020-11-16 16:32:43.927281",
13+
"spec_repo_commit": "39e9110"
1414
}
1515
}
1616
}

src/datadog_api_client/v1/configuration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ def __init__(self, host=None,
203203
# Enable client side validation
204204
self.client_side_validation = True
205205

206+
# Options to pass down to the underlying urllib3 socket
207+
self.socket_options = None
208+
206209
# Keep track of unstable operations
207210
self.unstable_operations = {
208211
"get_logs_index": False,

src/datadog_api_client/v1/model_utils.py

Lines changed: 53 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,6 @@ def set_attribute(self, name, value):
151151
)
152152
self.__dict__['_data_store'][name] = value
153153

154-
def __setitem__(self, name, value):
155-
"""this allows us to set values with instance[field_name] = val"""
156-
self.__setattr__(name, value)
157-
158-
def __getitem__(self, name):
159-
"""this allows us to get a value with val = instance[field_name]"""
160-
return self.__getattr__(name)
161-
162154
def __repr__(self):
163155
"""For `print` and `pprint`"""
164156
return self.to_str()
@@ -167,6 +159,14 @@ def __ne__(self, other):
167159
"""Returns true if both objects are not equal"""
168160
return not self == other
169161

162+
def __setattr__(self, attr, value):
163+
"""set the value of an attribute using dot notation: `instance.attr = val`"""
164+
self[attr] = value
165+
166+
def __getattr__(self, attr):
167+
"""get the value of an attribute using dot notation: `instance.attr`"""
168+
return self.__getitem__(attr)
169+
170170
def __new__(cls, *args, **kwargs):
171171
# this function uses the discriminator to
172172
# pick a new schema/class to instantiate because a discriminator
@@ -285,40 +285,39 @@ class ModelSimple(OpenApiModel):
285285
"""the parent class of models whose type != object in their
286286
swagger/openapi"""
287287

288-
def __setattr__(self, name, value):
289-
"""this allows us to set a value with instance.field_name = val"""
288+
def __setitem__(self, name, value):
289+
"""set the value of an attribute using square-bracket notation: `instance[attr] = val`"""
290290
if name in self.required_properties:
291291
self.__dict__[name] = value
292292
return
293293

294294
self.set_attribute(name, value)
295295

296-
def __getattr__(self, name):
297-
"""this allows us to get a value with val = instance.field_name"""
296+
def get(self, name, default=None):
297+
"""returns the value of an attribute or some default value if the attribute was not set"""
298298
if name in self.required_properties:
299299
return self.__dict__[name]
300300

301-
if name in self.__dict__['_data_store']:
302-
return self.__dict__['_data_store'][name]
301+
return self.__dict__['_data_store'].get(name, default)
302+
303+
def __getitem__(self, name):
304+
"""get the value of an attribute using square-bracket notation: `instance[attr]`"""
305+
if name in self:
306+
return self.get(name)
303307

304-
path_to_item = []
305-
if self._path_to_item:
306-
path_to_item.extend(self._path_to_item)
307-
path_to_item.append(name)
308308
raise ApiAttributeError(
309309
"{0} has no attribute '{1}'".format(
310310
type(self).__name__, name),
311-
[name]
311+
[e for e in [self._path_to_item, name] if e]
312312
)
313313

314314
def __contains__(self, name):
315-
"""this allows us to use `in` operator: `'attr' in instance`"""
315+
"""used by `in` operator to check if an attrbute value was set in an instance: `'attr' in instance`"""
316316
if name in self.required_properties:
317317
return name in self.__dict__
318318

319319
return name in self.__dict__['_data_store']
320320

321-
322321
def to_str(self):
323322
"""Returns the string representation of the model"""
324323
return str(self.value)
@@ -341,40 +340,39 @@ class ModelNormal(OpenApiModel):
341340
"""the parent class of models whose type == object in their
342341
swagger/openapi"""
343342

344-
def __setattr__(self, name, value):
345-
"""this allows us to set a value with instance.field_name = val"""
343+
def __setitem__(self, name, value):
344+
"""set the value of an attribute using square-bracket notation: `instance[attr] = val`"""
346345
if name in self.required_properties:
347346
self.__dict__[name] = value
348347
return
349348

350349
self.set_attribute(name, value)
351350

352-
def __getattr__(self, name):
353-
"""this allows us to get a value with val = instance.field_name"""
351+
def get(self, name, default=None):
352+
"""returns the value of an attribute or some default value if the attribute was not set"""
354353
if name in self.required_properties:
355354
return self.__dict__[name]
356355

357-
if name in self.__dict__['_data_store']:
358-
return self.__dict__['_data_store'][name]
356+
return self.__dict__['_data_store'].get(name, default)
357+
358+
def __getitem__(self, name):
359+
"""get the value of an attribute using square-bracket notation: `instance[attr]`"""
360+
if name in self:
361+
return self.get(name)
359362

360-
path_to_item = []
361-
if self._path_to_item:
362-
path_to_item.extend(self._path_to_item)
363-
path_to_item.append(name)
364363
raise ApiAttributeError(
365364
"{0} has no attribute '{1}'".format(
366365
type(self).__name__, name),
367-
[name]
366+
[e for e in [self._path_to_item, name] if e]
368367
)
369368

370369
def __contains__(self, name):
371-
"""this allows us to use `in` operator: `'attr' in instance`"""
370+
"""used by `in` operator to check if an attrbute value was set in an instance: `'attr' in instance`"""
372371
if name in self.required_properties:
373372
return name in self.__dict__
374373

375374
return name in self.__dict__['_data_store']
376375

377-
378376
def to_dict(self):
379377
"""Returns the model properties as a dict"""
380378
return model_to_dict(self, serialize=False)
@@ -427,8 +425,8 @@ class ModelComposed(OpenApiModel):
427425
which contain the value that the key is referring to.
428426
"""
429427

430-
def __setattr__(self, name, value):
431-
"""this allows us to set a value with instance.field_name = val"""
428+
def __setitem__(self, name, value):
429+
"""set the value of an attribute using square-bracket notation: `instance[attr] = val`"""
432430
if name in self.required_properties:
433431
self.__dict__[name] = value
434432
return
@@ -449,28 +447,22 @@ def __setattr__(self, name, value):
449447
)
450448
return None
451449

452-
path_to_item = []
453-
if self._path_to_item:
454-
path_to_item.extend(self._path_to_item)
455-
path_to_item.append(name)
456450
raise ApiAttributeError(
457451
"{0} has no attribute '{1}'".format(
458452
type(self).__name__, name),
459-
path_to_item
453+
[e for e in [self._path_to_item, name] if e]
460454
)
461455

462-
def __getattr__(self, name):
463-
"""this allows us to get a value with val = instance.field_name"""
456+
__unset_attribute_value__ = object()
457+
458+
def get(self, name, default=None):
459+
"""returns the value of an attribute or some default value if the attribute was not set"""
464460
if name in self.required_properties:
465461
return self.__dict__[name]
466462

467463
# get the attribute from the correct instance
468464
model_instances = self._var_name_to_model_instances.get(
469465
name, self._additional_properties_model_instances)
470-
path_to_item = []
471-
if self._path_to_item:
472-
path_to_item.extend(self._path_to_item)
473-
path_to_item.append(name)
474466
values = []
475467
# A composed model stores child (oneof/anyOf/allOf) models under
476468
# self._var_name_to_model_instances. A named property can exist in
@@ -484,23 +476,30 @@ def __getattr__(self, name):
484476
values.append(v)
485477
len_values = len(values)
486478
if len_values == 0:
487-
raise ApiAttributeError(
488-
"{0} has no attribute '{1}'".format(
489-
type(self).__name__, name),
490-
path_to_item
491-
)
479+
return default
492480
elif len_values == 1:
493481
return values[0]
494482
elif len_values > 1:
495483
raise ApiValueError(
496484
"Values stored for property {0} in {1} differ when looking "
497485
"at self and self's composed instances. All values must be "
498486
"the same".format(name, type(self).__name__),
499-
path_to_item
487+
[e for e in [self._path_to_item, name] if e]
500488
)
501489

490+
def __getitem__(self, name):
491+
"""get the value of an attribute using square-bracket notation: `instance[attr]`"""
492+
value = self.get(name, self.__unset_attribute_value__)
493+
if value is self.__unset_attribute_value__:
494+
raise ApiAttributeError(
495+
"{0} has no attribute '{1}'".format(
496+
type(self).__name__, name),
497+
[e for e in [self._path_to_item, name] if e]
498+
)
499+
return value
500+
502501
def __contains__(self, name):
503-
"""this allows us to use `in` operator: `'attr' in instance`"""
502+
"""used by `in` operator to check if an attrbute value was set in an instance: `'attr' in instance`"""
504503

505504
if name in self.required_properties:
506505
return name in self.__dict__
@@ -515,7 +514,6 @@ def __contains__(self, name):
515514

516515
return False
517516

518-
519517
def to_dict(self):
520518
"""Returns the model properties as a dict"""
521519
return model_to_dict(self, serialize=False)

src/datadog_api_client/v1/rest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ def __init__(self, configuration, pools_size=4, maxsize=None):
6767
if configuration.retries is not None:
6868
addition_pool_args['retries'] = configuration.retries
6969

70+
if configuration.socket_options is not None:
71+
addition_pool_args['socket_options'] = configuration.socket_options
72+
7073
if maxsize is None:
7174
if configuration.connection_pool_maxsize is not None:
7275
maxsize = configuration.connection_pool_maxsize

src/datadog_api_client/v2/configuration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ def __init__(self, host=None,
203203
# Enable client side validation
204204
self.client_side_validation = True
205205

206+
# Options to pass down to the underlying urllib3 socket
207+
self.socket_options = None
208+
206209
# Keep track of unstable operations
207210
self.unstable_operations = {
208211
"create_incident_service": False,

0 commit comments

Comments
 (0)