diff --git a/awsiot/iotjobs.py b/awsiot/iotjobs.py index 018c3da3..2c16eb91 100644 --- a/awsiot/iotjobs.py +++ b/awsiot/iotjobs.py @@ -34,10 +34,10 @@ def publish_describe_job_execution(self, request, qos): request is successfully published. The Future's result will be an exception if the request cannot be published. """ - if not request.thing_name: - raise ValueError("request.thing_name is required") if not request.job_id: raise ValueError("request.job_id is required") + if not request.thing_name: + raise ValueError("request.thing_name is required") return self._publish_operation( topic='$aws/things/{0.thing_name}/jobs/{0.job_id}/get'.format(request), @@ -111,10 +111,10 @@ def publish_update_job_execution(self, request, qos): request is successfully published. The Future's result will be an exception if the request cannot be published. """ - if not request.thing_name: - raise ValueError("request.thing_name is required") if not request.job_id: raise ValueError("request.job_id is required") + if not request.thing_name: + raise ValueError("request.thing_name is required") return self._publish_operation( topic='$aws/things/{0.thing_name}/jobs/{0.job_id}/update'.format(request), @@ -143,10 +143,10 @@ def subscribe_to_describe_job_execution_accepted(self, request, qos, callback): to `unsubscribe()` to stop receiving messages. Note that messages may arrive before the subscription is acknowledged. """ - if not request.thing_name: - raise ValueError("request.thing_name is required") if not request.job_id: raise ValueError("request.job_id is required") + if not request.thing_name: + raise ValueError("request.thing_name is required") if not callable(callback): raise ValueError("callback is required") @@ -179,10 +179,10 @@ def subscribe_to_describe_job_execution_rejected(self, request, qos, callback): to `unsubscribe()` to stop receiving messages. Note that messages may arrive before the subscription is acknowledged. """ - if not request.thing_name: - raise ValueError("request.thing_name is required") if not request.job_id: raise ValueError("request.job_id is required") + if not request.thing_name: + raise ValueError("request.thing_name is required") if not callable(callback): raise ValueError("callback is required") diff --git a/awsiot/iotshadow.py b/awsiot/iotshadow.py index 61b3c6ca..d33888eb 100644 --- a/awsiot/iotshadow.py +++ b/awsiot/iotshadow.py @@ -195,10 +195,10 @@ def subscribe_to_delete_named_shadow_accepted(self, request, qos, callback): to `unsubscribe()` to stop receiving messages. Note that messages may arrive before the subscription is acknowledged. """ - if not request.thing_name: - raise ValueError("request.thing_name is required") if not request.shadow_name: raise ValueError("request.shadow_name is required") + if not request.thing_name: + raise ValueError("request.thing_name is required") if not callable(callback): raise ValueError("callback is required") @@ -231,10 +231,10 @@ def subscribe_to_delete_named_shadow_rejected(self, request, qos, callback): to `unsubscribe()` to stop receiving messages. Note that messages may arrive before the subscription is acknowledged. """ - if not request.thing_name: - raise ValueError("request.thing_name is required") if not request.shadow_name: raise ValueError("request.shadow_name is required") + if not request.thing_name: + raise ValueError("request.thing_name is required") if not callable(callback): raise ValueError("callback is required") @@ -335,10 +335,10 @@ def subscribe_to_get_named_shadow_accepted(self, request, qos, callback): to `unsubscribe()` to stop receiving messages. Note that messages may arrive before the subscription is acknowledged. """ - if not request.thing_name: - raise ValueError("request.thing_name is required") if not request.shadow_name: raise ValueError("request.shadow_name is required") + if not request.thing_name: + raise ValueError("request.thing_name is required") if not callable(callback): raise ValueError("callback is required") @@ -371,10 +371,10 @@ def subscribe_to_get_named_shadow_rejected(self, request, qos, callback): to `unsubscribe()` to stop receiving messages. Note that messages may arrive before the subscription is acknowledged. """ - if not request.thing_name: - raise ValueError("request.thing_name is required") if not request.shadow_name: raise ValueError("request.shadow_name is required") + if not request.thing_name: + raise ValueError("request.thing_name is required") if not callable(callback): raise ValueError("callback is required") @@ -475,10 +475,10 @@ def subscribe_to_named_shadow_delta_updated_events(self, request, qos, callback) to `unsubscribe()` to stop receiving messages. Note that messages may arrive before the subscription is acknowledged. """ - if not request.thing_name: - raise ValueError("request.thing_name is required") if not request.shadow_name: raise ValueError("request.shadow_name is required") + if not request.thing_name: + raise ValueError("request.thing_name is required") if not callable(callback): raise ValueError("callback is required") @@ -615,10 +615,10 @@ def subscribe_to_update_named_shadow_accepted(self, request, qos, callback): to `unsubscribe()` to stop receiving messages. Note that messages may arrive before the subscription is acknowledged. """ - if not request.thing_name: - raise ValueError("request.thing_name is required") if not request.shadow_name: raise ValueError("request.shadow_name is required") + if not request.thing_name: + raise ValueError("request.thing_name is required") if not callable(callback): raise ValueError("callback is required") @@ -651,10 +651,10 @@ def subscribe_to_update_named_shadow_rejected(self, request, qos, callback): to `unsubscribe()` to stop receiving messages. Note that messages may arrive before the subscription is acknowledged. """ - if not request.thing_name: - raise ValueError("request.thing_name is required") if not request.shadow_name: raise ValueError("request.shadow_name is required") + if not request.thing_name: + raise ValueError("request.thing_name is required") if not callable(callback): raise ValueError("callback is required") @@ -765,10 +765,8 @@ def __init__(self, *args, **kwargs): def to_payload(self): # type: () -> typing.Dict[str, typing.Any] payload = {} # type: typing.Dict[str, typing.Any] - if self.client_token is not None: payload['clientToken'] = self.client_token - return payload class DeleteNamedShadowSubscriptionRequest(awsiot.ModeledClass): @@ -826,10 +824,8 @@ def __init__(self, *args, **kwargs): def to_payload(self): # type: () -> typing.Dict[str, typing.Any] payload = {} # type: typing.Dict[str, typing.Any] - if self.client_token is not None: payload['clientToken'] = self.client_token - return payload class DeleteShadowResponse(awsiot.ModeledClass): @@ -981,10 +977,8 @@ def __init__(self, *args, **kwargs): def to_payload(self): # type: () -> typing.Dict[str, typing.Any] payload = {} # type: typing.Dict[str, typing.Any] - if self.client_token is not None: payload['clientToken'] = self.client_token - return payload class GetNamedShadowSubscriptionRequest(awsiot.ModeledClass): @@ -1042,10 +1036,8 @@ def __init__(self, *args, **kwargs): def to_payload(self): # type: () -> typing.Dict[str, typing.Any] payload = {} # type: typing.Dict[str, typing.Any] - if self.client_token is not None: payload['clientToken'] = self.client_token - return payload class GetShadowResponse(awsiot.ModeledClass): @@ -1346,19 +1338,16 @@ def from_payload(cls, payload): def to_payload(self): # type: () -> typing.Dict[str, typing.Any] payload = {} # type: typing.Dict[str, typing.Any] - if self.desired_is_nullable is True: payload['desired'] = self.desired else: if self.desired is not None: payload['desired'] = self.desired - if self.reported_is_nullable is True: payload['reported'] = self.reported else: if self.reported is not None: payload['reported'] = self.reported - return payload class ShadowStateWithDelta(awsiot.ModeledClass): @@ -1554,16 +1543,12 @@ def __init__(self, *args, **kwargs): def to_payload(self): # type: () -> typing.Dict[str, typing.Any] payload = {} # type: typing.Dict[str, typing.Any] - if self.client_token is not None: payload['clientToken'] = self.client_token - if self.state is not None: payload['state'] = self.state.to_payload() - if self.version is not None: payload['version'] = self.version - return payload class UpdateNamedShadowSubscriptionRequest(awsiot.ModeledClass): @@ -1627,16 +1612,12 @@ def __init__(self, *args, **kwargs): def to_payload(self): # type: () -> typing.Dict[str, typing.Any] payload = {} # type: typing.Dict[str, typing.Any] - if self.client_token is not None: payload['clientToken'] = self.client_token - if self.state is not None: payload['state'] = self.state.to_payload() - if self.version is not None: payload['version'] = self.version - return payload class UpdateShadowResponse(awsiot.ModeledClass): @@ -1717,3 +1698,4 @@ def __init__(self, *args, **kwargs): # for backwards compatibility, read any arguments that used to be accepted by position for key, val in zip(['thing_name'], args): setattr(self, key, val) +