-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb47dbf
commit 058f251
Showing
37 changed files
with
2,950 additions
and
136 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
43 changes: 0 additions & 43 deletions
43
examples/sdk-backend/app/api/app_with_agent_credentials.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
172 changes: 86 additions & 86 deletions
172
examples/sdk-backend/Pipfile.lock → examples/spaces/Pipfile.lock
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# IndyKite Python SDK spaces example | ||
Create an AppSpace, a tenant, an application, an application agent and get application agent credentials | ||
|
||
## Requirements | ||
|
||
* Python >= 3.10 | ||
* IndyKite account: Accounted created by logging in on https://console.indykite.id/ | ||
* Customer created on https://console.indykite.id/ | ||
* Service account created on https://console.indykite.id/ under the above customer | ||
|
||
## Installation | ||
* Copy example to local environment | ||
* In the spaces directory, run: | ||
|
||
pipenv install | ||
pipenv shell | ||
|
||
* Credentials: export the file as env variable in CLI (setex for Windows) | ||
|
||
export INDYKITE_SERVICE_ACCOUNT_CREDENTIALS_FILE=path_to_service_account_file | ||
|
||
* In spaces directory, run: | ||
|
||
flask run | ||
|
||
* You should get: | ||
|
||
Running on http://127.0.0.1:5000 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
from flask_openapi3 import APIBlueprint | ||
from flask_openapi3 import Tag | ||
from indykite_sdk.config import ConfigClient | ||
from app.config import API_PREFIX | ||
from app.form.app_with_agent_credentials import ApplicationWithAgentCredentialsCreate | ||
from app.utils.response import get_response, get_credentials_response, response_data | ||
from flask import Flask, render_template, request, url_for, flash, redirect, session | ||
import json | ||
|
||
__version__ = "/v1" | ||
__bp__ = "/app_with_agent_credentials" | ||
url_prefix = API_PREFIX + __version__ + __bp__ | ||
tag = Tag(name=" ApplicationWithAgentCredentials", description=" ApplicationWithAgentCredentials") | ||
api = APIBlueprint(__bp__, __name__, url_prefix=url_prefix, abp_tags=[tag]) | ||
|
||
|
||
@api.post("") | ||
def create_app_with_agent_credentials(body: ApplicationWithAgentCredentialsCreate): | ||
client_config = ConfigClient() | ||
app_with_agent_credentials = client_config.create_application_with_agent_credentials( | ||
body.app_space_id, | ||
body.tenant_id, | ||
body.application_name, | ||
body.application_agent_name, | ||
body.application_agent_credentials_name, | ||
"jwk", | ||
None, | ||
None) | ||
if app_with_agent_credentials: | ||
cred = {'ApplicationWithAgentCredentials': []} | ||
for k, v in app_with_agent_credentials.items(): | ||
app = {k: []} | ||
if k == "response_application_agent_credentials": | ||
app_dict = get_credentials_response(v) | ||
else: | ||
app_dict = json.loads(get_response(v)) | ||
app[k].append(app_dict) | ||
cred['ApplicationWithAgentCredentials'].append(app) | ||
return response_data("ApplicationWithAgentCredentialsCreate",cred) | ||
else: | ||
return response_data("ApplicationWithAgentCredentialsCreate", "Invalid app_with_agent_credentials creation") | ||
|
||
|
||
@api.get("/new") | ||
def new_app_with_agent_credentials(): | ||
return render_template('new_app_with_agent_credentials.html') | ||
|
||
|
||
@api.post("/new") | ||
def new_app_with_agent_credentials_post(): | ||
app_space_id = request.form['app_space_id'] | ||
tenant_id = request.form['tenant_id'] | ||
application_name = request.form['application_name'] | ||
application_agent_name = request.form['application_agent_name'] | ||
application_agent_credentials_name = request.form['application_agent_credentials_name'] | ||
|
||
if not app_space_id: | ||
flash('AppSpace id is required!') | ||
elif not tenant_id: | ||
flash('Tenant id is required!') | ||
elif not application_name: | ||
flash('Application name is required!') | ||
elif not application_agent_name: | ||
flash('Application agent name is required!') | ||
elif not application_agent_credentials_name: | ||
flash('Application agent credentials name is required!') | ||
else: | ||
client_config = ConfigClient() | ||
app_with_agent_credentials = client_config.create_application_with_agent_credentials( | ||
app_space_id, | ||
tenant_id, | ||
application_name, | ||
application_agent_name, | ||
application_agent_credentials_name, | ||
"jwk", | ||
None, | ||
None) | ||
if app_with_agent_credentials: | ||
cred = {'ApplicationWithAgentCredentials': []} | ||
for k, v in app_with_agent_credentials.items(): | ||
app = {k: []} | ||
if k == "response_application_agent_credentials": | ||
app_dict = get_credentials_response(v) | ||
if v.agent_config: | ||
ac = v.agent_config | ||
session['id'] = v.id | ||
session['kid'] = v.kid | ||
session['agent_config'] = ac.decode("utf-8") | ||
elif k == "response_application": | ||
session['response_application'] = json.loads(get_response(v)) | ||
elif k == "response_application_agent": | ||
session['response_application_agent'] = json.loads(get_response(v)) | ||
else: | ||
app_dict = json.loads(get_response(v)) | ||
#app[k].append(app_dict) | ||
#cred['ApplicationWithAgentCredentials'].append(app) | ||
|
||
#session['app_with_agent_credentials'] = get_response(cred) | ||
return render_template('index.html') | ||
else: | ||
session['app_with_agent_credentials'] = "Invalid app_with_agent_credentials creation" | ||
return render_template('index.html') | ||
return render_template('new_app_space.html') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* http://meyerweb.com/eric/tools/css/reset/ | ||
v2.0 | 20110126 | ||
License: none (public domain) | ||
*/ | ||
|
||
html, body, div, span, applet, object, iframe, | ||
h1, h2, h3, h4, h5, h6, p, blockquote, pre, | ||
a, abbr, acronym, address, big, cite, code, | ||
del, dfn, em, img, ins, kbd, q, s, samp, | ||
small, strike, strong, sub, sup, tt, var, | ||
b, u, i, center, | ||
dl, dt, dd, ol, ul, li, | ||
fieldset, form, label, legend, | ||
table, caption, tbody, tfoot, thead, tr, th, td, | ||
article, aside, canvas, details, embed, | ||
figure, figcaption, footer, header, hgroup, | ||
menu, nav, output, ruby, section, summary, | ||
time, mark, audio, video { | ||
margin: 0; | ||
padding: 0; | ||
border: 0; | ||
font-size: 100%; | ||
font: inherit; | ||
vertical-align: baseline; | ||
} | ||
/* HTML5 display-role reset for older browsers */ | ||
article, aside, details, figcaption, figure, | ||
footer, header, hgroup, menu, nav, section { | ||
display: block; | ||
} | ||
body { | ||
line-height: 1; | ||
} | ||
ol, ul { | ||
list-style: none; | ||
} | ||
blockquote, q { | ||
quotes: none; | ||
} | ||
blockquote:before, blockquote:after, | ||
q:before, q:after { | ||
content: ''; | ||
content: none; | ||
} | ||
table { | ||
border-collapse: collapse; | ||
border-spacing: 0; | ||
} |
Oops, something went wrong.