Skip to content

Commit 73a9dc9

Browse files
bretambroseBret Ambrose
and
Bret Ambrose
authored
New constructors (#81)
* New class constructors * Update samples to 100% keyword args on structure construction * Cert parsing utility script that makes fleet provisioning easier * Hard-code positional parameter handling for GetShadowRequest, DeleteShadowRequest Co-authored-by: Bret Ambrose <[email protected]>
1 parent bbc2a3c commit 73a9dc9

File tree

6 files changed

+1622
-281
lines changed

6 files changed

+1622
-281
lines changed

awsiot/iotidentity.py

Lines changed: 239 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
1+
# Copyright Amazon.com, Inc. or its affiliates. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0.
33

44
# This file is generated
@@ -247,11 +247,30 @@ def subscribe_to_register_thing_rejected(self, request, qos, callback):
247247
payload_to_class_fn=ErrorResponse.from_payload)
248248

249249
class CreateCertificateFromCsrRequest(awsiot.ModeledClass):
250+
r"""
251+
Attributes:
252+
* *certificate_signing_request* (``str``)
253+
254+
All attributes are None by default, and may be set by keyword in the constructor.
255+
"""
256+
250257
__slots__ = ['certificate_signing_request']
251258

252-
def __init__(self, certificate_signing_request=None):
253-
# type: (typing.Optional[str]) -> None
254-
self.certificate_signing_request = certificate_signing_request # type: typing.Optional[str]
259+
def __init__(self, *args, **kwargs):
260+
r"""Initializes a CreateCertificateFromCsrRequest instance
261+
262+
:param \**kwargs:
263+
See below
264+
265+
:Keyword Arguments:
266+
* *certificate_signing_request* (``str``)
267+
"""
268+
269+
self.certificate_signing_request = kwargs.get('certificate_signing_request')
270+
271+
# for backwards compatibility, read any arguments that used to be accepted by position
272+
for key, val in zip(['certificate_signing_request'], args):
273+
setattr(self, key, val)
255274

256275
def to_payload(self):
257276
# type: () -> typing.Dict[str, typing.Any]
@@ -261,13 +280,36 @@ def to_payload(self):
261280
return payload
262281

263282
class CreateCertificateFromCsrResponse(awsiot.ModeledClass):
283+
r"""
284+
Attributes:
285+
* *certificate_id* (``str``)
286+
* *certificate_ownership_token* (``str``)
287+
* *certificate_pem* (``str``)
288+
289+
All attributes are None by default, and may be set by keyword in the constructor.
290+
"""
291+
264292
__slots__ = ['certificate_id', 'certificate_ownership_token', 'certificate_pem']
265293

266-
def __init__(self, certificate_id=None, certificate_ownership_token=None, certificate_pem=None):
267-
# type: (typing.Optional[str], typing.Optional[str], typing.Optional[str]) -> None
268-
self.certificate_id = certificate_id # type: typing.Optional[str]
269-
self.certificate_ownership_token = certificate_ownership_token # type: typing.Optional[str]
270-
self.certificate_pem = certificate_pem # type: typing.Optional[str]
294+
def __init__(self, *args, **kwargs):
295+
r"""Initializes a CreateCertificateFromCsrResponse instance
296+
297+
:param \**kwargs:
298+
See below
299+
300+
:Keyword Arguments:
301+
* *certificate_id* (``str``)
302+
* *certificate_ownership_token* (``str``)
303+
* *certificate_pem* (``str``)
304+
"""
305+
306+
self.certificate_id = kwargs.get('certificate_id')
307+
self.certificate_ownership_token = kwargs.get('certificate_ownership_token')
308+
self.certificate_pem = kwargs.get('certificate_pem')
309+
310+
# for backwards compatibility, read any arguments that used to be accepted by position
311+
for key, val in zip(['certificate_id', 'certificate_ownership_token', 'certificate_pem'], args):
312+
setattr(self, key, val)
271313

272314
@classmethod
273315
def from_payload(cls, payload):
@@ -285,28 +327,83 @@ def from_payload(cls, payload):
285327
return new
286328

287329
class CreateCertificateFromCsrSubscriptionRequest(awsiot.ModeledClass):
330+
r"""
331+
Attributes:
332+
333+
All attributes are None by default, and may be set by keyword in the constructor.
334+
"""
335+
288336
__slots__ = []
289337

290-
def __init__(self):
291-
# type: () -> None
292-
pass
338+
def __init__(self, *args, **kwargs):
339+
r"""Initializes a CreateCertificateFromCsrSubscriptionRequest instance
340+
341+
:param \**kwargs:
342+
See below
343+
344+
:Keyword Arguments:
345+
"""
346+
347+
# for backwards compatibility, read any arguments that used to be accepted by position
348+
for key, val in zip([], args):
349+
setattr(self, key, val)
293350

294351
class CreateKeysAndCertificateRequest(awsiot.ModeledClass):
352+
r"""
353+
Attributes:
354+
355+
All attributes are None by default, and may be set by keyword in the constructor.
356+
"""
357+
295358
__slots__ = []
296359

297-
def __init__(self):
298-
# type: () -> None
299-
pass
360+
def __init__(self, *args, **kwargs):
361+
r"""Initializes a CreateKeysAndCertificateRequest instance
362+
363+
:param \**kwargs:
364+
See below
365+
366+
:Keyword Arguments:
367+
"""
368+
369+
# for backwards compatibility, read any arguments that used to be accepted by position
370+
for key, val in zip([], args):
371+
setattr(self, key, val)
300372

301373
class CreateKeysAndCertificateResponse(awsiot.ModeledClass):
374+
r"""
375+
Attributes:
376+
* *certificate_id* (``str``)
377+
* *certificate_ownership_token* (``str``)
378+
* *certificate_pem* (``str``)
379+
* *private_key* (``str``)
380+
381+
All attributes are None by default, and may be set by keyword in the constructor.
382+
"""
383+
302384
__slots__ = ['certificate_id', 'certificate_ownership_token', 'certificate_pem', 'private_key']
303385

304-
def __init__(self, certificate_id=None, certificate_ownership_token=None, certificate_pem=None, private_key=None):
305-
# type: (typing.Optional[str], typing.Optional[str], typing.Optional[str], typing.Optional[str]) -> None
306-
self.certificate_id = certificate_id # type: typing.Optional[str]
307-
self.certificate_ownership_token = certificate_ownership_token # type: typing.Optional[str]
308-
self.certificate_pem = certificate_pem # type: typing.Optional[str]
309-
self.private_key = private_key # type: typing.Optional[str]
386+
def __init__(self, *args, **kwargs):
387+
r"""Initializes a CreateKeysAndCertificateResponse instance
388+
389+
:param \**kwargs:
390+
See below
391+
392+
:Keyword Arguments:
393+
* *certificate_id* (``str``)
394+
* *certificate_ownership_token* (``str``)
395+
* *certificate_pem* (``str``)
396+
* *private_key* (``str``)
397+
"""
398+
399+
self.certificate_id = kwargs.get('certificate_id')
400+
self.certificate_ownership_token = kwargs.get('certificate_ownership_token')
401+
self.certificate_pem = kwargs.get('certificate_pem')
402+
self.private_key = kwargs.get('private_key')
403+
404+
# for backwards compatibility, read any arguments that used to be accepted by position
405+
for key, val in zip(['certificate_id', 'certificate_ownership_token', 'certificate_pem', 'private_key'], args):
406+
setattr(self, key, val)
310407

311408
@classmethod
312409
def from_payload(cls, payload):
@@ -327,20 +424,58 @@ def from_payload(cls, payload):
327424
return new
328425

329426
class CreateKeysAndCertificateSubscriptionRequest(awsiot.ModeledClass):
427+
r"""
428+
Attributes:
429+
430+
All attributes are None by default, and may be set by keyword in the constructor.
431+
"""
432+
330433
__slots__ = []
331434

332-
def __init__(self):
333-
# type: () -> None
334-
pass
435+
def __init__(self, *args, **kwargs):
436+
r"""Initializes a CreateKeysAndCertificateSubscriptionRequest instance
437+
438+
:param \**kwargs:
439+
See below
440+
441+
:Keyword Arguments:
442+
"""
443+
444+
# for backwards compatibility, read any arguments that used to be accepted by position
445+
for key, val in zip([], args):
446+
setattr(self, key, val)
335447

336448
class ErrorResponse(awsiot.ModeledClass):
449+
r"""
450+
Attributes:
451+
* *error_code* (``str``)
452+
* *error_message* (``str``)
453+
* *status_code* (``int``)
454+
455+
All attributes are None by default, and may be set by keyword in the constructor.
456+
"""
457+
337458
__slots__ = ['error_code', 'error_message', 'status_code']
338459

339-
def __init__(self, error_code=None, error_message=None, status_code=None):
340-
# type: (typing.Optional[str], typing.Optional[str], typing.Optional[int]) -> None
341-
self.error_code = error_code # type: typing.Optional[str]
342-
self.error_message = error_message # type: typing.Optional[str]
343-
self.status_code = status_code # type: typing.Optional[int]
460+
def __init__(self, *args, **kwargs):
461+
r"""Initializes a ErrorResponse instance
462+
463+
:param \**kwargs:
464+
See below
465+
466+
:Keyword Arguments:
467+
* *error_code* (``str``)
468+
* *error_message* (``str``)
469+
* *status_code* (``int``)
470+
"""
471+
472+
self.error_code = kwargs.get('error_code')
473+
self.error_message = kwargs.get('error_message')
474+
self.status_code = kwargs.get('status_code')
475+
476+
# for backwards compatibility, read any arguments that used to be accepted by position
477+
for key, val in zip(['error_code', 'error_message', 'status_code'], args):
478+
setattr(self, key, val)
344479

345480
@classmethod
346481
def from_payload(cls, payload):
@@ -358,13 +493,36 @@ def from_payload(cls, payload):
358493
return new
359494

360495
class RegisterThingRequest(awsiot.ModeledClass):
496+
r"""
497+
Attributes:
498+
* *certificate_ownership_token* (``str``)
499+
* *parameters* (``typing.Dict[str, str]``)
500+
* *template_name* (``str``)
501+
502+
All attributes are None by default, and may be set by keyword in the constructor.
503+
"""
504+
361505
__slots__ = ['certificate_ownership_token', 'parameters', 'template_name']
362506

363-
def __init__(self, certificate_ownership_token=None, parameters=None, template_name=None):
364-
# type: (typing.Optional[str], typing.Optional[typing.Dict[str, str]], typing.Optional[str]) -> None
365-
self.certificate_ownership_token = certificate_ownership_token # type: typing.Optional[str]
366-
self.parameters = parameters # type: typing.Optional[typing.Dict[str, str]]
367-
self.template_name = template_name # type: typing.Optional[str]
507+
def __init__(self, *args, **kwargs):
508+
r"""Initializes a RegisterThingRequest instance
509+
510+
:param \**kwargs:
511+
See below
512+
513+
:Keyword Arguments:
514+
* *certificate_ownership_token* (``str``)
515+
* *parameters* (``typing.Dict[str, str]``)
516+
* *template_name* (``str``)
517+
"""
518+
519+
self.certificate_ownership_token = kwargs.get('certificate_ownership_token')
520+
self.parameters = kwargs.get('parameters')
521+
self.template_name = kwargs.get('template_name')
522+
523+
# for backwards compatibility, read any arguments that used to be accepted by position
524+
for key, val in zip(['certificate_ownership_token', 'parameters', 'template_name'], args):
525+
setattr(self, key, val)
368526

369527
def to_payload(self):
370528
# type: () -> typing.Dict[str, typing.Any]
@@ -376,12 +534,33 @@ def to_payload(self):
376534
return payload
377535

378536
class RegisterThingResponse(awsiot.ModeledClass):
537+
r"""
538+
Attributes:
539+
* *device_configuration* (``typing.Dict[str, str]``)
540+
* *thing_name* (``str``)
541+
542+
All attributes are None by default, and may be set by keyword in the constructor.
543+
"""
544+
379545
__slots__ = ['device_configuration', 'thing_name']
380546

381-
def __init__(self, device_configuration=None, thing_name=None):
382-
# type: (typing.Optional[typing.Dict[str, str]], typing.Optional[str]) -> None
383-
self.device_configuration = device_configuration # type: typing.Optional[typing.Dict[str, str]]
384-
self.thing_name = thing_name # type: typing.Optional[str]
547+
def __init__(self, *args, **kwargs):
548+
r"""Initializes a RegisterThingResponse instance
549+
550+
:param \**kwargs:
551+
See below
552+
553+
:Keyword Arguments:
554+
* *device_configuration* (``typing.Dict[str, str]``)
555+
* *thing_name* (``str``)
556+
"""
557+
558+
self.device_configuration = kwargs.get('device_configuration')
559+
self.thing_name = kwargs.get('thing_name')
560+
561+
# for backwards compatibility, read any arguments that used to be accepted by position
562+
for key, val in zip(['device_configuration', 'thing_name'], args):
563+
setattr(self, key, val)
385564

386565
@classmethod
387566
def from_payload(cls, payload):
@@ -396,9 +575,28 @@ def from_payload(cls, payload):
396575
return new
397576

398577
class RegisterThingSubscriptionRequest(awsiot.ModeledClass):
578+
r"""
579+
Attributes:
580+
* *template_name* (``str``)
581+
582+
All attributes are None by default, and may be set by keyword in the constructor.
583+
"""
584+
399585
__slots__ = ['template_name']
400586

401-
def __init__(self, template_name=None):
402-
# type: (typing.Optional[str]) -> None
403-
self.template_name = template_name # type: typing.Optional[str]
587+
def __init__(self, *args, **kwargs):
588+
r"""Initializes a RegisterThingSubscriptionRequest instance
589+
590+
:param \**kwargs:
591+
See below
592+
593+
:Keyword Arguments:
594+
* *template_name* (``str``)
595+
"""
596+
597+
self.template_name = kwargs.get('template_name')
598+
599+
# for backwards compatibility, read any arguments that used to be accepted by position
600+
for key, val in zip(['template_name'], args):
601+
setattr(self, key, val)
404602

0 commit comments

Comments
 (0)