Skip to content

Commit

Permalink
feat: change version and add limit in custom token
Browse files Browse the repository at this point in the history
  • Loading branch information
cowan-macady committed Sep 7, 2023
1 parent 89281ab commit 9579790
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
indykite_sdk/ingest.py

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.29.0"
".": "1.28.0"
}
7 changes: 0 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
# Changelog

## [1.29.0](https://github.com/indykite/indykite-sdk-python/compare/v1.28.0...v1.29.0) (2023-08-29)


### Features

* separate stream from ingest ([1e094ee](https://github.com/indykite/indykite-sdk-python/commit/1e094ee26b4ff39df34bdd0a69c8a88e1142da26))

## [1.28.0](https://github.com/indykite/indykite-sdk-python/compare/v1.27.0...v1.28.0) (2023-08-23)


Expand Down
9 changes: 5 additions & 4 deletions indykite_sdk/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import time
import requests
import os
from datetime import datetime, timedelta
from google.protobuf.duration_pb2 import Duration
from indykite_sdk.utils.hash_methods import encrypt_bcrypt
from indykite_sdk.identity import IdentityClient
Expand Down Expand Up @@ -2877,8 +2878,8 @@ def main():

elif command == "stream_records":
# replace with actual values
record_id = "14589904"
external_id = "external-dt-id904"
record_id = "114589904"
external_id = "external-dt-id9004"
tenant_id = os.getenv('TENANT_ID')
type = "Person"
tags = []
Expand All @@ -2895,8 +2896,8 @@ def main():
properties)
record = client_ingest.record_upsert(record_id, upsert)

record_id2 = "14589905"
external_id = "lot-905"
record_id2 = "114589905"
external_id = "lot-9050"
type = "ParkingLot"
ingest_property = client_ingest.ingest_property("customProp905", "9654")
properties = [ingest_property]
Expand Down
5 changes: 4 additions & 1 deletion indykite_sdk/utils/jwt_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ def create_agent_jwt(credentials, client="identity"):
def create_jwt_message(credentials, client):
token_lifetime = None
now = datetime.now()
current_time = int(time.time())
time_2min = current_time + 120
time_day = current_time + 86400
if "tokenLifetime" in credentials.keys():
token_lifetime = get_int_from_datetime(now + parse_delta(credentials.get('tokenLifetime')))
if not isinstance(token_lifetime, int):
if not isinstance(token_lifetime, int) or token_lifetime < time_2min or token_lifetime > time_day:
token_lifetime = get_int_from_datetime(now + timedelta(hours=1))
if client == "config":
message = {
Expand Down
33 changes: 16 additions & 17 deletions tests/test_config_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -948,13 +948,20 @@ def test_update_knowledge_graph_schema_config_node_success(capsys):
assert client is not None

right_now = str(int(time.time()))
config_node_id = data.get_kg_schema_config_node_id()
response = client.read_config_node(config_node_id)
assert response is not None

def mocked_update_config_node(request: pb2.UpdateConfigNodeRequest):
return pb2.UpdateConfigNodeResponse("id",
right_now,
right_now,
"etag",
[],
"Automation "+right_now,
"description "+right_now,
knowledge_graph_schema_config)

knowledge_graph_schema_config = data.get_kg_schema()
config_node_response = client.update_knowledge_graph_schema_config_node(response.id,
response.etag,
config_node_response = client.update_knowledge_graph_schema_config_node("id",
"etag",
"Automation "+right_now,
"description "+right_now,
knowledge_graph_schema_config)
Expand All @@ -969,18 +976,14 @@ def test_update_knowledge_graph_schema_config_node_empty(capsys):
assert client is not None

right_now = str(int(time.time()))
config_node_id = data.get_kg_schema_config_node_id()
response = client.read_config_node(config_node_id)
assert response is not None

knowledge_graph_schema_config = data.get_kg_schema()

def mocked_update_config_node(request: pb2.UpdateConfigNodeRequest):
return None

client.stub.UpdateConfigNode = mocked_update_config_node
config_node_response = client.update_knowledge_graph_schema_config_node(response.id,
response.etag,
config_node_response = client.update_knowledge_graph_schema_config_node("id",
"etag",
"Automation " + right_now,
"description " + right_now,
knowledge_graph_schema_config,
Expand All @@ -994,12 +997,8 @@ def test_update_knowledge_graph_schema_config_node_exception(capsys):
assert client is not None

right_now = str(int(time.time()))
config_node_id = data.get_kg_schema_config_node_id()
response = client.read_config_node(config_node_id)
assert response is not None

config_node_response = client.update_knowledge_graph_schema_config_node(response.id,
response.etag,
config_node_response = client.update_knowledge_graph_schema_config_node("id",
"etag",
"Automation "+right_now,
"description "+right_now,
"description",
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.29.0"
__version__ = "1.28.0"

0 comments on commit 9579790

Please sign in to comment.