Closed ah-cog closed 4 years ago
Thanks for taking a look, Spence. I'm still working on it and thinking about a couple things... just a heads up. I'm hoping to wrap it up today though.
One if the questions I'm thinking about is whether network interfaces should have their own functions, or if accessing the object is sufficient for now.
On Mon, Apr 6, 2020, 10:57 AM spencer-kt notifications@github.com wrote:
@spencer-kt commented on this pull request.
In cogniac/gateway.py https://github.com/Cogniac/cogniac-sdk-py/pull/61#discussion_r404282315:
- if not connection and not url_prefix:
- raise Exception("A URL must be specified for either a CloudCore or EdgeFlow API.")
- if connection and not gateway_dict:
- raise Exception("Missing gateway object.")
This logic doesn't account for connection=None cases. Does this break if it's None?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Cogniac/cogniac-sdk-py/pull/61#pullrequestreview-388487893, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFV5QOTS4OO3TIPMJXJI73RLIJYPANCNFSM4MCO7SKA .
Here are some tested usage examples to get a feel for the current state of this branch:
Note: This is revised. Previous variations are in edit history.
EDGEFLOW_ID = 'my_edgeflow_id'
# Connect to Core.
cc = CogniacConnection()
# Get all tenant EdgeFlows.
edgeflows = cc.get_all_edgeflows()
pprint(edgeflows)
# Get a specific EdgeFlow object.
# Note: The EdgeFlow's `ip_address` field will be used for local EdgeFlow API requests.
edgeflow = cc.get_edgeflow(EDGEFLOW_ID)
# SDK calls to EdgeFlow APIs.
edgeflow_version = edgeflow.get_version()
print(edgeflow_version)
# media_detections = edgeflow.process_media(subject_uid=SUBJECT_UID,
# filename=IMAGE_FILEPATH)
# SDK calls to Core APIs.
# edgeflow.flush_upload_queue()
# edgeflow.factory_reset()
# edgeflow.upgrade()
edgeflow.reboot()
# edgeflow.status()
In the above examples, CogniacEdgeFlow
is both the gateway object/client (CloudCore) and a client interface to a local EdgeFlow. I'm considering separating this into two classes, EdgeFlow
for the object/client interface, and a separate EdgeFlowClient
for local access.
I think this may clarify the purpose and prevent overloading the single class. Any preferences on that?
how about delete gateway? can we add it to make it easier?
Gateway is going to be deleted by itself as a side effect of factory reset. https://github.com/Cogniac/gateway/issues/166
Changes
CogniacGateway
object to include APIs to send events to EF via CloudCore.get_all_gateways
andget_gateways
functions toCogniacConnection
object.url_prefix
parameter toget_gateway
to use a local gateway. If nourl_prefix
is specified, local EF API calls will fail.CogniacGateway
withurl_prefix
. In this case, CloudCore APIs will fail.Next
network_interfaces
in this PR, create a follow-up issue to discuss. Suggest creating additional, distinct class for network interfaces such asNetworkInterface
.