Skip to content

Commit f341399

Browse files
committed
merge with master
2 parents 8915627 + 2ccf700 commit f341399

29 files changed

+2661
-180
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This project is written in Python and is displayed in jupyter notebooks.
1919

2020
You need to install:
2121
1. [Docker](https://docs.docker.com/get-docker/)
22-
1. The **source-to-image** (s2i) tool is also required to build the docker images used in the demo. S2I can be downloaded [here](https://github.com/openshift/source-to-image). The website gives instructions for installing on other platforms.
22+
1. The **source-to-image** (s2i) tool is also required to build the docker images used in the demo. S2I can be downloaded [here](https://github.com/openshift/source-to-image). The website gives instructions for installing on other platforms like MACOS, Linux, Windows.
2323
Verify that **s2i** is in your PATH. If not, then edit your PATH and add the directory where **s2i** is installed. The **manage** script will look for the **s2i** executable on your PATH. If it is not found you will get a message asking you to download and set it on your PATH.
2424
- If you are using a Mac and have Homebrew installed, the following command will install s2i: `brew install source-to-image`
2525
- If you are using Linux, go to the [releases](https://github.com/openshift/source-to-image/releases/latest) page and download the correct distribution for your machine. Choose either the linux-386 or the linux-amd64 links for 32 and 64-bit, respectively. Unpack the downloaded tar with `tar -xvf "Release.tar.gz"`

libs/aries-basic-controller/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A simple pip installable package for controlling aries agents through admin API
44

55
# Install
66

7-
Current version 0.1.1
7+
Current version 0.2
88

99
`python3 -m pip install aries_basic_controller`
1010

libs/aries-basic-controller/aries_basic_controller/aries_controller.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
from .controllers.credential import CredentialController
1717
from .controllers.server import ServerController
1818
from .controllers.oob import OOBController
19+
from .controllers.action_menu import ActionMenuController
20+
from .controllers.revocation import RevocationController
1921

2022
import logging
2123

@@ -25,8 +27,19 @@ class AriesAgentController:
2527

2628
## TODO rethink how to initialise. Too many args?
2729
## is it important to let users config connections/issuer etc
28-
def __init__(self, webhook_host: str, webhook_port: int, admin_url: str, webhook_base: str = "",
29-
connections: bool = True, messaging: bool = True, issuer: bool = True, api_key: str = None):
30+
def __init__(
31+
self,
32+
webhook_host: str,
33+
webhook_port: int,
34+
admin_url: str,
35+
webhook_base: str = "",
36+
connections: bool = True,
37+
messaging: bool = True,
38+
issuer: bool = True,
39+
action_menu: bool = True,
40+
revocations: bool = True,
41+
api_key: str = None,
42+
):
3043

3144
self.webhook_site = None
3245
self.admin_url = admin_url
@@ -62,7 +75,13 @@ def __init__(self, webhook_host: str, webhook_port: int, admin_url: str, webhook
6275
self.issuer = IssuerController(self.admin_url, self.client_session, self.connections,
6376
self.wallet, self.definitions)
6477

65-
78+
if action_menu:
79+
self.action_menu = ActionMenuController(self.admin_url, self.client_session)
80+
if revocations:
81+
self.revocations = RevocationController(
82+
self.admin_url,
83+
self.client_session
84+
)
6685

6786
def register_listeners(self, listeners, defaults=True):
6887
if defaults:
@@ -73,7 +92,6 @@ def register_listeners(self, listeners, defaults=True):
7392
if self.proofs:
7493
pub.subscribe(self.proofs.default_handler, "present_proof")
7594

76-
7795
for listener in listeners:
7896
pub.subscribe(listener["handler"], listener["topic"])
7997

@@ -96,11 +114,7 @@ async def handle_webhook(self, topic, payload):
96114
pub.sendMessage(topic, payload=payload)
97115
return web.Response(status=200)
98116

99-
100117
async def terminate(self):
101118
await self.client_session.close()
102119
if self.webhook_site:
103120
await self.webhook_site.stop()
104-
105-
106-
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from .base import BaseController
2+
from ..models.connection import Connection
3+
4+
from aiohttp import (
5+
ClientSession,
6+
)
7+
import logging
8+
import asyncio
9+
10+
class ActionMenuController(BaseController):
11+
12+
def __init__(self, admin_url: str, client_session: ClientSession):
13+
super().__init__(admin_url, client_session)
14+
15+
async def close_menu(self, connection_id: str):
16+
return await self.admin_POST(f"/action-menu/{connection_id}/close")
17+
18+
async def get_menu(self, connection_id: str):
19+
return await self.admin_POST(f"/action-menu/{connection_id}/fetch")
20+
21+
async def request_menu(self, connection_id: str):
22+
return await self.admin_POST(f"/action-menu/{connection_id}/request")
23+
24+
async def perform(self, connection_id: str, menu_params, menu_option_name):
25+
body = {
26+
"params": menu_params,
27+
"name": menu_option_name
28+
}
29+
30+
return await self.admin_POST(f"/action-menu/{connection_id}/perform", json_data=body)
31+
32+
async def send_menu(
33+
self,
34+
connection_id: str,
35+
menu_description: str,
36+
menu_errormsg: str,
37+
menu_title: str,
38+
menu_options,
39+
):
40+
body = {
41+
"menu": {
42+
"description": menu_description,
43+
"errormsg": menu_errormsg,
44+
"title": menu_title,
45+
"options": menu_options
46+
}
47+
}
48+
49+
return await self.admin_POST(f"/connections/{connection_id}/send-menu", json_data=body)

libs/aries-basic-controller/aries_basic_controller/controllers/base.py

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
EVENT_LOGGER = logging.getLogger("event")
1818

19+
1920
class repr_json:
2021
def __init__(self, val):
2122
self.val = val
@@ -52,7 +53,6 @@ def handle_output(self, *output, source: str = None, **kwargs):
5253
color = None
5354
log_msg(*output, color=color, prefix=self.prefix_str, end=end, **kwargs)
5455

55-
5656
async def admin_request(
5757
self, method, path, json_data=None, text=False, params=None, data=None
5858
) -> ClientResponse:
@@ -71,7 +71,6 @@ async def admin_request(
7171
raise Exception(f"Error decoding JSON: {resp_text}") from e
7272
return resp_text
7373

74-
7574
async def admin_GET(self, path, text=False, params=None) -> ClientResponse:
7675
try:
7776
EVENT_LOGGER.debug("Controller GET %s request to Agent", path)
@@ -95,13 +94,54 @@ async def admin_POST(
9594
)
9695
response = await self.admin_request("POST", path, json_data, text, params, data)
9796
EVENT_LOGGER.debug(
98-
"Response from POST %s received: \n%s", path, repr_json(response),
97+
"Response from POST %s received: \n%s",
98+
path,
99+
repr_json(response),
99100
)
100101
return response
101102
except ClientError as e:
102103
self.log(f"Error during POST {path}: {str(e)}")
103104
raise
104105

106+
async def admin_PATCH(
107+
self, path, json_data=None, text=False, params=None, data=None
108+
) -> ClientResponse:
109+
try:
110+
EVENT_LOGGER.debug(
111+
"Controller PATCH %s request to Agent%s",
112+
path,
113+
(" with data: \n{}".format(repr_json(json_data)) if json_data else ""),
114+
)
115+
response = await self.admin_request("PATCH", path, json_data, text, params, data)
116+
EVENT_LOGGER.debug(
117+
"Response from PATCH %s received: \n%s",
118+
path,
119+
repr_json(response)
120+
)
121+
return response
122+
except ClientError as e:
123+
self.log(f"Error during PATCH {path}: {str(e)}")
124+
raise
125+
126+
async def admin_PUT(
127+
self, path, json_data=None, text=False, params=None, data=None
128+
) -> ClientResponse:
129+
try:
130+
EVENT_LOGGER.debug(
131+
"Controller PUT %s request to Agent%s",
132+
path,
133+
(" with data: \n{}".format(repr_json(json_data)) if json_data else ""),
134+
)
135+
response = await self.admin_request("PUT", path, json_data, text, params, data)
136+
EVENT_LOGGER.debug(
137+
"Response from PUT %s received: \n%s",
138+
path,
139+
repr_json(response)
140+
)
141+
return response
142+
except ClientError as e:
143+
self.log(f"Error during PUT {path}: {str(e)}")
144+
raise
105145

106146
async def admin_DELETE(
107147
self, path, text=False, params=None

libs/aries-basic-controller/aries_basic_controller/controllers/credential.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ async def get_all(self, wql_query: str = None, count: int = None, start: int = N
3030
return await self.admin_GET("/credentials", params=params)
3131

3232
async def is_revoked(self, credential_id):
33-
return await self.admin_GET(f"credential/revoked/{credential_id}")
33+
return await self.admin_GET(f"/credential/revoked/{credential_id}")

0 commit comments

Comments
 (0)