From 0ed95fff4a3fc4ffc17e1e27685b8437e23c7404 Mon Sep 17 00:00:00 2001 From: aws Date: Thu, 17 Sep 2020 00:39:45 +0000 Subject: [PATCH] Release of Version 1.6.0 --- CHANGELOG.rst | 5 + README.rst | 2 + docs/.buildinfo | 2 +- docs/_apidoc/greengrasssdk.IoTDataPlane.html | 8 +- docs/_apidoc/greengrasssdk.Lambda.html | 60 +- .../_apidoc/greengrasssdk.SecretsManager.html | 8 +- docs/_apidoc/greengrasssdk.client.html | 8 +- docs/_apidoc/greengrasssdk.html | 9 +- .../greengrasssdk.stream_manager.data.html | 1465 +++- ...eengrasssdk.stream_manager.exceptions.html | 32 +- .../_apidoc/greengrasssdk.stream_manager.html | 9 +- ...dk.stream_manager.streammanagerclient.html | 31 +- .../greengrasssdk.stream_manager.util.html | 45 +- ...ngrasssdk.stream_manager.utilinternal.html | 262 + docs/_apidoc/greengrasssdk.utils.html | 8 +- docs/_apidoc/greengrasssdk.utils.testing.html | 8 +- docs/_apidoc/modules.html | 8 +- docs/_modules/greengrasssdk/IoTDataPlane.html | 8 +- docs/_modules/greengrasssdk/Lambda.html | 48 +- .../greengrasssdk/SecretsManager.html | 8 +- docs/_modules/greengrasssdk/client.html | 8 +- .../greengrasssdk/stream_manager/data.html | 7065 +++++++++++----- .../stream_manager/exceptions.html | 24 +- .../stream_manager/streammanagerclient.html | 127 +- .../greengrasssdk/stream_manager/util.html | 194 +- .../stream_manager/utilinternal.html | 415 + .../_modules/greengrasssdk/utils/testing.html | 8 +- docs/_modules/index.html | 9 +- .../greengrasssdk.stream_manager.rst.txt | 1 + ...asssdk.stream_manager.utilinternal.rst.txt | 7 + docs/_static/documentation_options.js | 2 +- docs/genindex.html | 397 +- docs/index.html | 13 +- docs/objects.inv | Bin 2471 -> 3624 bytes docs/py-modindex.html | 13 +- docs/search.html | 8 +- docs/searchindex.js | 2 +- .../greengrassHelloWorldCounter.py | 2 +- .../stream_manager_ioT_siteWise.py | 97 + examples/StreamManagerS3/stream_manager_s3.py | 127 + greengrasssdk/Lambda.py | 40 +- greengrasssdk/__init__.py | 2 +- greengrasssdk/stream_manager/__init__.py | 25 + greengrasssdk/stream_manager/data/__init__.py | 7119 ++++++++++++----- greengrasssdk/stream_manager/exceptions.py | 16 + .../stream_manager/streammanagerclient.py | 119 +- greengrasssdk/stream_manager/util.py | 174 +- greengrasssdk/stream_manager/utilinternal.py | 211 + 48 files changed, 13767 insertions(+), 4492 deletions(-) create mode 100644 docs/_apidoc/greengrasssdk.stream_manager.utilinternal.html create mode 100644 docs/_modules/greengrasssdk/stream_manager/utilinternal.html create mode 100644 docs/_sources/_apidoc/greengrasssdk.stream_manager.utilinternal.rst.txt create mode 100644 examples/StreamManagerIoTSiteWise/stream_manager_ioT_siteWise.py create mode 100644 examples/StreamManagerS3/stream_manager_s3.py create mode 100644 greengrasssdk/stream_manager/utilinternal.py diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a125aa8..d54b50e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,11 @@ CHANGELOG ========= +1.6.0 +===== +Stream manager supports automatic data export to AWS S3 and AWS IoT SiteWise, provides new API method to update existing streams, and pause or resume exporting. +Support Python3.8 lambda runtime. + 1.5.0 ===== diff --git a/README.rst b/README.rst index 47e55e0..6ff09da 100644 --- a/README.rst +++ b/README.rst @@ -70,6 +70,8 @@ As new features are added to AWS IoT Greengrass, newer versions of the AWS IoT G +-------------+------------------------+ | 1.10.x | 1.0.x-1.5.x | +-------------+------------------------+ +| 1.11.x | 1.0.x-1.6.x | ++-------------+------------------------+ ============== Stream Manager diff --git a/docs/.buildinfo b/docs/.buildinfo index 283747b..b549457 100644 --- a/docs/.buildinfo +++ b/docs/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: b47998532a53416a32a84e3eaee97038 +config: 080f03067e86a18925b920088836fb92 tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/_apidoc/greengrasssdk.IoTDataPlane.html b/docs/_apidoc/greengrasssdk.IoTDataPlane.html index 1375421..f9ed535 100644 --- a/docs/_apidoc/greengrasssdk.IoTDataPlane.html +++ b/docs/_apidoc/greengrasssdk.IoTDataPlane.html @@ -8,7 +8,7 @@ - greengrasssdk.IoTDataPlane module — Greengrass Core Python SDK 1.5.0 documentation + greengrasssdk.IoTDataPlane module — Greengrass Core Python SDK 1.6.0 documentation @@ -56,7 +56,7 @@
- 1.5.0 + 1.6.0
@@ -297,7 +297,7 @@

- © Copyright 2019, Amazon.com. + © Copyright 2020, Amazon.com.

@@ -319,7 +319,7 @@ + + + + + + +
+ + + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + + + + +
+ +
    + +
  • Docs »
  • + +
  • greengrasssdk.stream_manager.utilinternal module
  • + + +
  • + + + View page source + + +
  • + +
+ + +
+
+
+
+ +
+

greengrasssdk.stream_manager.utilinternal module

+
+
+class greengrasssdk.stream_manager.utilinternal.UtilInternal[source]
+

Bases: object

+
+
+static sync(coro, loop: asyncio.events.AbstractEventLoop)[source]
+
+ +
+
+static del_empty_arrays(d)[source]
+
+ +
+
+static serialize_to_json_with_empty_array_as_null(data)[source]
+
+ +
+
+static int_to_bytes(i, length=4)[source]
+
+ +
+
+static int_from_bytes(b)[source]
+
+ +
+
+static encode_frame(frame) → Sequence[bytes][source]
+
+ +
+
+static get_request_id()[source]
+
+ +
+
+static is_invalid(o)[source]
+
+ +
+
+static raise_on_error_response(response)[source]
+
+ +
+ +
+ + +
+ +
+ + +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/_apidoc/greengrasssdk.utils.html b/docs/_apidoc/greengrasssdk.utils.html index 51bbef4..ca6738b 100644 --- a/docs/_apidoc/greengrasssdk.utils.html +++ b/docs/_apidoc/greengrasssdk.utils.html @@ -8,7 +8,7 @@ - greengrasssdk.utils package — Greengrass Core Python SDK 1.5.0 documentation + greengrasssdk.utils package — Greengrass Core Python SDK 1.6.0 documentation @@ -56,7 +56,7 @@
- 1.5.0 + 1.6.0
@@ -173,7 +173,7 @@

Submodules

- © Copyright 2019, Amazon.com. + © Copyright 2020, Amazon.com.

@@ -195,7 +195,7 @@

Submodules var DOCUMENTATION_OPTIONS = { URL_ROOT:'../', - VERSION:'1.5.0', + VERSION:'1.6.0', LANGUAGE:'None', COLLAPSE_INDEX:false, FILE_SUFFIX:'.html', diff --git a/docs/_apidoc/greengrasssdk.utils.testing.html b/docs/_apidoc/greengrasssdk.utils.testing.html index e76f1be..70d5c0d 100644 --- a/docs/_apidoc/greengrasssdk.utils.testing.html +++ b/docs/_apidoc/greengrasssdk.utils.testing.html @@ -8,7 +8,7 @@ - greengrasssdk.utils.testing module — Greengrass Core Python SDK 1.5.0 documentation + greengrasssdk.utils.testing module — Greengrass Core Python SDK 1.6.0 documentation @@ -56,7 +56,7 @@
- 1.5.0 + 1.6.0
@@ -170,7 +170,7 @@

- © Copyright 2019, Amazon.com. + © Copyright 2020, Amazon.com.

@@ -192,7 +192,7 @@ + + + + + + +
+ + + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + + + + +
+ +
    + +
  • Docs »
  • + +
  • Module code »
  • + +
  • greengrasssdk.stream_manager.utilinternal
  • + + +
  • + +
  • + +
+ + +
+
+
+
+ +

Source code for greengrasssdk.stream_manager.utilinternal

+import asyncio
+import json
+import re
+import uuid
+from typing import Sequence
+
+from .data import ResponseStatusCode
+from .exceptions import (
+    InvalidRequestException,
+    MessageStoreReadErrorException,
+    NotEnoughMessagesException,
+    RequestPayloadTooLargeException,
+    ResourceNotFoundException,
+    ResponsePayloadTooLargeException,
+    ServerOutOfMemoryException,
+    ServerTimeoutException,
+    StreamManagerException,
+    UnauthorizedException,
+    UnknownFailureException,
+    UnknownOperationException,
+    UpdateFailedException,
+    UpdateNotAllowedException,
+)
+
+
+
[docs]class UtilInternal: + __ENDIAN = "big" + _MAX_PACKET_SIZE = 1 << 30 + +
[docs] @staticmethod + def sync(coro, loop: asyncio.AbstractEventLoop): + if asyncio.iscoroutine(coro): + # Run async function in the loop and return the value or raise the exception + return asyncio.run_coroutine_threadsafe(coro, loop=loop).result() + + return coro
+ + """ + Delete keys with the value ``None`` in a dictionary, recursively. + This alters the input so you may wish to ``copy`` the dict first. + """ + +
[docs] @staticmethod + def del_empty_arrays(d): + + for key, value in list(d.items()): + if isinstance(value, list) and len(value) == 0: + del d[key] + elif isinstance(value, dict): + UtilInternal.del_empty_arrays(value) + return d
+ +
[docs] @staticmethod + def serialize_to_json_with_empty_array_as_null(data): + s = json.dumps(UtilInternal.del_empty_arrays(data.as_dict())) + + return s.encode()
+ +
[docs] @staticmethod + def int_to_bytes(i, length=4): + return int.to_bytes(i, length=length, byteorder=UtilInternal.__ENDIAN, signed=True)
+ +
[docs] @staticmethod + def int_from_bytes(b): + return int.from_bytes(b, byteorder=UtilInternal.__ENDIAN, signed=True)
+ +
[docs] @staticmethod + def encode_frame(frame) -> Sequence[bytes]: + if len(frame.payload) + 1 > UtilInternal._MAX_PACKET_SIZE: + raise RequestPayloadTooLargeException() + return [ + bytes( + [ + *UtilInternal.int_to_bytes(len(frame.payload) + 1), + *UtilInternal.int_to_bytes(frame.operation.value, length=1), + ] + ), + frame.payload, + ]
+ +
[docs] @staticmethod + def get_request_id(): + return str(uuid.uuid4())
+ +
[docs] @staticmethod + def is_invalid(o): + if not hasattr(o, "_validations_map"): + return False + if not hasattr(o, "_types_map"): + return False + for prop_name, validations in o._validations_map.items(): + if not hasattr(o, prop_name): + return "Object is malformed, missing property: {}".format(prop_name) + # Validate all properties on lists + if type(getattr(o, prop_name)) == list: + for i, v in enumerate(getattr(o, prop_name)): + result = UtilInternal.is_invalid(v) + if result: + return "Property {}[{}] is invalid because {}".format(prop_name, i, result) + + # Recurse down to check validity of objects within objects + result = UtilInternal.is_invalid(getattr(o, prop_name)) + if result: + return "Property {} is invalid because {}".format(prop_name, result) + + # Validate the property + if "required" in validations and validations["required"] and getattr(o, prop_name) is None: + return "Property {} is required, but was None".format(prop_name) + if ( + "minLength" in validations + and getattr(o, prop_name) is not None + and len(getattr(o, prop_name)) < validations["minLength"] + ): + return "Property {} must have a minimum length of {}, but found length of {}".format( + prop_name, validations["minLength"], len(getattr(o, prop_name)) + ) + if ( + "maxLength" in validations + and getattr(o, prop_name) is not None + and len(getattr(o, prop_name)) > validations["maxLength"] + ): + return "Property {} must have a maximum length of {}, but found length of {}".format( + prop_name, validations["maxLength"], len(getattr(o, prop_name)) + ) + if ( + "minItems" in validations + and getattr(o, prop_name) is not None + and len(getattr(o, prop_name)) < validations["minItems"] + ): + return "Property {} must have at least {} items, but found {}".format( + prop_name, validations["minItems"], len(getattr(o, prop_name)) + ) + if ( + "maxItems" in validations + and getattr(o, prop_name) is not None + and len(getattr(o, prop_name)) > validations["maxItems"] + ): + return "Property {} must have at most {} items, but found {}".format( + prop_name, validations["maxItems"], len(getattr(o, prop_name)) + ) + if ( + "maximum" in validations + and getattr(o, prop_name) is not None + and getattr(o, prop_name) > validations["maximum"] + ): + return "Property {} must be at most {}".format(prop_name, validations["maximum"]) + if ( + "minimum" in validations + and getattr(o, prop_name) is not None + and getattr(o, prop_name) < validations["minimum"] + ): + return "Property {} must be at least {}".format(prop_name, validations["minimum"]) + if ( + "pattern" in validations + and getattr(o, prop_name) is not None + and re.fullmatch(validations["pattern"], getattr(o, prop_name)) is None + ): + return "Property {} must match regex {}".format(prop_name, validations["pattern"]) + + for prop_name, types in o._types_map.items(): + # Validate all properties with their respective types + if "type" in types and getattr(o, prop_name) is not None: + result = isinstance(getattr(o, prop_name), types["type"]) + if not result: + return "Property {} is invalid because it must be of type {}".format( + prop_name, types["type"].__name__ + ) + if types["type"] == list and "subtype" in types: + for i, v in enumerate(getattr(o, prop_name)): + result = isinstance(v, types["subtype"]) + if not result: + return "Property {}[{}] is invalid because it must be of type {}".format( + prop_name, i, types["subtype"].__name__ + ) + + return False
+ +
[docs] @staticmethod + def raise_on_error_response(response): + if response.status == ResponseStatusCode.Success: + return + elif response.status == ResponseStatusCode.InvalidRequest: + raise InvalidRequestException(response.error_message, response.status, response.request_id) + elif response.status == ResponseStatusCode.RequestPayloadTooLarge: + raise RequestPayloadTooLargeException(response.error_message, response.status, response.request_id) + elif response.status == ResponseStatusCode.ResourceNotFound: + raise ResourceNotFoundException(response.error_message, response.status, response.request_id) + elif response.status == ResponseStatusCode.ResponsePayloadTooLarge: + raise ResponsePayloadTooLargeException(response.error_message, response.status, response.request_id) + elif response.status == ResponseStatusCode.ServerTimeout: + raise ServerTimeoutException(response.error_message, response.status, response.request_id) + elif response.status == ResponseStatusCode.Unauthorized: + raise UnauthorizedException(response.error_message, response.status, response.request_id) + elif response.status == ResponseStatusCode.UnknownFailure: + raise UnknownFailureException(response.error_message, response.status, response.request_id) + elif response.status == ResponseStatusCode.NotEnoughMessages: + raise NotEnoughMessagesException(response.error_message, response.status, response.request_id) + elif response.status == ResponseStatusCode.MessageStoreReadError: + raise MessageStoreReadErrorException(response.error_message, response.status, response.request_id) + elif response.status == ResponseStatusCode.OutOfMemoryError: + raise ServerOutOfMemoryException(response.error_message, response.status, response.request_id) + elif response.status == ResponseStatusCode.UpdateFailed: + raise UpdateFailedException(response.error_message, response.status, response.request_id) + elif response.status == ResponseStatusCode.UpdateNotAllowed: + raise UpdateNotAllowedException(response.error_message, response.status, response.request_id) + elif response.status == ResponseStatusCode.UnknownOperation: + raise UnknownOperationException(response.error_message, response.status, response.request_id) + else: + raise StreamManagerException( + "Client is not able to understand this server response status code", "Unrecognized", response.request_id + )
+
+ +
+ +
+ + +
+
+ +
+ +
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/_modules/greengrasssdk/utils/testing.html b/docs/_modules/greengrasssdk/utils/testing.html index 6560244..2be77f8 100644 --- a/docs/_modules/greengrasssdk/utils/testing.html +++ b/docs/_modules/greengrasssdk/utils/testing.html @@ -8,7 +8,7 @@ - greengrasssdk.utils.testing — Greengrass Core Python SDK 1.5.0 documentation + greengrasssdk.utils.testing — Greengrass Core Python SDK 1.6.0 documentation @@ -56,7 +56,7 @@
- 1.5.0 + 1.6.0
@@ -190,7 +190,7 @@

Source code for greengrasssdk.utils.testing

 
   

- © Copyright 2019, Amazon.com. + © Copyright 2020, Amazon.com.

@@ -212,7 +212,7 @@

Source code for greengrasssdk.utils.testing