pyegeria 0.5.9.1__py3-none-any.whl → 0.5.9.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,6 +17,7 @@ from examples.widgets.cli.ops_config import Config
17
17
  from examples.widgets.personal.monitor_open_todos import display_todos
18
18
  from examples.widgets.personal.monitor_my_todos import display_my_todos
19
19
  from examples.widgets.personal.list_my_profile import display_my_profiles
20
+ from examples.widgets.personal.list_my_roles import display_my_roles
20
21
 
21
22
 
22
23
 
@@ -100,6 +101,18 @@ def show_my_profile(ctx):
100
101
  display_my_profiles( c.view_server, c.view_server_url,
101
102
  c.userid, c.password, c.jupyter, c.width)
102
103
 
104
+ @show.command('my-roles')
105
+ @click.pass_context
106
+ def show_my_roles(ctx):
107
+ """Display my profiles
108
+
109
+ Usage: show my-profile
110
+
111
+ """
112
+ c = ctx.obj
113
+ display_my_roles( c.view_server, c.view_server_url,
114
+ c.userid, c.password, c.jupyter, c.width)
115
+
103
116
 
104
117
  @show.command('my-to-dos')
105
118
  @click.pass_context
@@ -13,9 +13,12 @@ import argparse
13
13
  import time
14
14
  import sys
15
15
 
16
- from rich import box
16
+ from rich import box, print
17
17
  from rich.console import Console
18
18
  from rich.table import Table
19
+ from rich.tree import Tree
20
+ from rich.panel import Panel
21
+ from rich.markdown import Markdown
19
22
 
20
23
  from pyegeria import (
21
24
  InvalidParameterException,
@@ -38,81 +41,78 @@ EGERIA_ADMIN_PASSWORD = os.environ.get('ADMIN_PASSWORD', 'secret')
38
41
  EGERIA_USER = os.environ.get('EGERIA_USER', 'erinoverview')
39
42
  EGERIA_USER_PASSWORD = os.environ.get('EGERIA_USER_PASSWORD', 'secret')
40
43
  EGERIA_JUPYTER = bool(os.environ.get('EGERIA_JUPYTER', 'False'))
41
- EGERIA_WIDTH = int(os.environ.get('EGERIA_WIDTH', '200'))
44
+ EGERIA_WIDTH = int(os.environ.get('EGERIA_WIDTH', '250'))
42
45
 
43
- def display_my_profiles(server: str, url: str, username: str, user_pass:str,
46
+ def display_my_profile(server: str, url: str, username: str, user_pass:str,
44
47
  jupyter:bool=EGERIA_JUPYTER, width:int = EGERIA_WIDTH):
45
48
 
46
- m_client = MyProfile(server, url, user_id=username, user_pwd=user_pass)
47
- token = m_client.create_egeria_bearer_token(username, user_pass)
48
- my_profiles = m_client.get_my_profile()
49
- if type(my_profiles) is str:
50
- print(f"No profiles found for {username}")
51
- sys.exit(1)
52
-
53
- def generate_table() -> Table:
54
- """Make a new table."""
49
+ try:
50
+ m_client = MyProfile(server, url, user_id=username, user_pwd=user_pass)
51
+ token = m_client.create_egeria_bearer_token(username, user_pass)
52
+ my_profiles = m_client.get_my_profile()
53
+ if type(my_profiles) is str:
54
+ print(f"No profiles found for {username}")
55
+ sys.exit(1)
56
+
57
+ console = Console(width=width, force_terminal=not jupyter, soft_wrap=True)
58
+
59
+ profile_props = my_profiles.get('profileProperties','---')
60
+ name = profile_props["fullName"]
61
+ tree = Tree(Panel(f"Profile of {name}",title = "Personal Profile"),
62
+ expanded=True,style="bright_white on black", guide_style="bold bright_blue")
63
+
64
+ profile_props_md = f"\n* GUID: {my_profiles["elementHeader"]["guid"]}\n"
65
+ if type(profile_props) is dict:
66
+ for key in profile_props.keys():
67
+ if type(profile_props[key]) is str:
68
+ profile_props_md += f"* {key}: {profile_props[key]}\n"
69
+ elif type(profile_props[key]) is dict:
70
+ p_md = '\n* Additional Details:\n'
71
+ for k in profile_props[key].keys():
72
+ p_md += f"\t* {k}: {profile_props[key][k]}\n"
73
+ profile_props_md += p_md
74
+ t1 = tree.add(Panel(Markdown(profile_props_md),title="Profile Properties"))
75
+
76
+
77
+ id_list_md=""
78
+ for identities in my_profiles["userIdentities"]:
79
+ id_list_md += f"* {identities['userIdentity']['properties']['userId']}\n"
80
+ t2 = tree.add(Panel(Markdown(id_list_md), title="Identities"))
81
+
82
+ contact_methods = my_profiles['contactMethods']
83
+ for method in contact_methods:
84
+ contact = method['properties']
85
+ contact_methods_md = ""
86
+ for key in contact.keys():
87
+ contact_methods_md += f"* {key}: {contact[key]}\n"
88
+ t3 = tree.add(Panel(Markdown(contact_methods_md), title="Contact Methods"))
89
+
90
+ my_roles = my_profiles["roles"]
55
91
  table = Table(
56
- title=f"My Profile Information {url} @ {time.asctime()}",
57
- # style = "black on grey66",
58
- header_style="white on dark_blue",
59
- show_lines=True,
92
+ title = f" Roles of {name}",
93
+ show_lines= True,
60
94
  box=box.ROUNDED,
61
- caption=f"My Profile from Server '{server}' @ Platform - {url}\n Press 'q' to Quit",
62
- expand=True
95
+ expand= True,
63
96
  )
64
-
65
- table.add_column("Name")
66
- table.add_column("Job Title")
67
- table.add_column("userId")
68
- table.add_column("myGUID")
69
97
  table.add_column("Role Type")
70
98
  table.add_column("Role")
71
99
  table.add_column("Role GUID")
72
-
73
- if len(my_profiles) == 0:
74
- name = " "
75
- job_title = " "
76
- user_id = " "
77
- my_guid = " "
78
- role_type = " "
79
- role = " "
80
- role_guid = " "
81
- else:
82
- name = my_profiles["profileProperties"]["fullName"]
83
- job_title = my_profiles["profileProperties"]["jobTitle"]
84
- id_list=" "
85
- for identities in my_profiles["userIdentities"]:
86
- id_list = f"{identities['userIdentity']['properties']['userId']} {id_list}"
87
-
88
- my_guid = my_profiles["elementHeader"]["guid"]
89
-
90
- my_roles = my_profiles["roles"]
91
- for a_role in my_roles:
92
- my_role_props = a_role["properties"]
93
- role_type = my_role_props["typeName"]
94
- role = my_role_props.get("title"," ")
95
- role_guid = a_role["elementHeader"]["guid"]
96
- table.add_row(
97
- name, job_title, str(id_list), my_guid, role_type, role, role_guid
98
- )
99
-
100
- m_client.close_session()
101
- return table
102
-
103
- try:
104
- # with Live(generate_table(), refresh_per_second=4, screen=True) as live:
105
- # while True:
106
- # time.sleep(2)
107
- # live.update(generate_table())
108
- console = Console(width=width, force_terminal=not jupyter)
109
- with console.pager():
110
- console.print(generate_table())
111
-
100
+ for a_role in my_roles:
101
+ my_role_props = a_role["properties"]
102
+ role_type = my_role_props["typeName"]
103
+ role = my_role_props.get("title"," ")
104
+ role_guid = a_role["elementHeader"]["guid"]
105
+ table.add_row(
106
+ role_type, role, role_guid
107
+ )
108
+ t4 = tree.add(Panel(table, title="Roles" ),expanded=True)
109
+
110
+ print(tree)
112
111
 
113
112
  except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
114
113
  print_exception_response(e)
115
- assert e.related_http_code != "200", "Invalid parameters"
114
+ finally:
115
+ m_client.close_session()
116
116
 
117
117
  def main():
118
118
  parser = argparse.ArgumentParser()
@@ -128,7 +128,7 @@ def main():
128
128
  userid = args.userid if args.userid is not None else EGERIA_USER
129
129
  user_pass = args.password if args.password is not None else EGERIA_USER_PASSWORD
130
130
 
131
- display_my_profiles(server, url, userid, user_pass)
131
+ display_my_profile(server, url, userid, user_pass)
132
132
 
133
133
  if __name__ == "__main__":
134
134
  main()
@@ -0,0 +1,134 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ SPDX-License-Identifier: Apache-2.0
4
+ Copyright Contributors to the ODPi Egeria project.
5
+
6
+ Unit tests for the Utils helper functions using the Pytest framework.
7
+
8
+
9
+ A simple display for my profile
10
+ """
11
+ import os
12
+ import argparse
13
+ import time
14
+ import sys
15
+
16
+ from rich import box
17
+ from rich.console import Console
18
+ from rich.table import Table
19
+
20
+ from pyegeria import (
21
+ InvalidParameterException,
22
+ PropertyServerException,
23
+ UserNotAuthorizedException,
24
+ print_exception_response,
25
+ )
26
+ from pyegeria.my_profile_omvs import MyProfile
27
+
28
+ disable_ssl_warnings = True
29
+ EGERIA_METADATA_STORE = os.environ.get("EGERIA_METADATA_STORE", "active-metadata-store")
30
+ EGERIA_KAFKA_ENDPOINT = os.environ.get('KAFKA_ENDPOINT', 'localhost:9092')
31
+ EGERIA_PLATFORM_URL = os.environ.get('EGERIA_PLATFORM_URL', 'https://localhost:9443')
32
+ EGERIA_VIEW_SERVER = os.environ.get('VIEW_SERVER', 'view-server')
33
+ EGERIA_VIEW_SERVER_URL = os.environ.get('EGERIA_VIEW_SERVER_URL', 'https://localhost:9443')
34
+ EGERIA_INTEGRATION_DAEMON = os.environ.get('INTEGRATION_DAEMON', 'integration-daemon')
35
+ EGERIA_INTEGRATION_DAEMON_URL = os.environ.get('EGERIA_INTEGRATION_DAEMON_URL', 'https://localhost:9443')
36
+ EGERIA_ADMIN_USER = os.environ.get('ADMIN_USER', 'garygeeke')
37
+ EGERIA_ADMIN_PASSWORD = os.environ.get('ADMIN_PASSWORD', 'secret')
38
+ EGERIA_USER = os.environ.get('EGERIA_USER', 'erinoverview')
39
+ EGERIA_USER_PASSWORD = os.environ.get('EGERIA_USER_PASSWORD', 'secret')
40
+ EGERIA_JUPYTER = bool(os.environ.get('EGERIA_JUPYTER', 'False'))
41
+ EGERIA_WIDTH = int(os.environ.get('EGERIA_WIDTH', '200'))
42
+
43
+ def display_my_roles(server: str, url: str, username: str, user_pass:str,
44
+ jupyter:bool=EGERIA_JUPYTER, width:int = EGERIA_WIDTH):
45
+
46
+ m_client = MyProfile(server, url, user_id=username, user_pwd=user_pass)
47
+ token = m_client.create_egeria_bearer_token(username, user_pass)
48
+ my_profiles = m_client.get_my_profile()
49
+ if type(my_profiles) is str:
50
+ print(f"No profiles found for {username}")
51
+ sys.exit(1)
52
+
53
+ def generate_table() -> Table:
54
+ """Make a new table."""
55
+ table = Table(
56
+ title=f"My Profile Information {url} @ {time.asctime()}",
57
+ # style = "black on grey66",
58
+ header_style="white on dark_blue",
59
+ show_lines=True,
60
+ box=box.ROUNDED,
61
+ caption=f"My Profile from Server '{server}' @ Platform - {url}\n Press 'q' to Quit",
62
+ expand=True
63
+ )
64
+
65
+ table.add_column("Name")
66
+ table.add_column("Job Title")
67
+ table.add_column("userId")
68
+ table.add_column("myGUID")
69
+ table.add_column("Role Type")
70
+ table.add_column("Role")
71
+ table.add_column("Role GUID")
72
+
73
+ if len(my_profiles) == 0:
74
+ name = " "
75
+ job_title = " "
76
+ user_id = " "
77
+ my_guid = " "
78
+ role_type = " "
79
+ role = " "
80
+ role_guid = " "
81
+ else:
82
+ name = my_profiles["profileProperties"]["fullName"]
83
+ job_title = my_profiles["profileProperties"]["jobTitle"]
84
+ id_list=" "
85
+ for identities in my_profiles["userIdentities"]:
86
+ id_list = f"{identities['userIdentity']['properties']['userId']} {id_list}"
87
+
88
+ my_guid = my_profiles["elementHeader"]["guid"]
89
+
90
+ my_roles = my_profiles["roles"]
91
+ for a_role in my_roles:
92
+ my_role_props = a_role["properties"]
93
+ role_type = my_role_props["typeName"]
94
+ role = my_role_props.get("title"," ")
95
+ role_guid = a_role["elementHeader"]["guid"]
96
+ table.add_row(
97
+ name, job_title, str(id_list), my_guid, role_type, role, role_guid
98
+ )
99
+
100
+ m_client.close_session()
101
+ return table
102
+
103
+ try:
104
+ # with Live(generate_table(), refresh_per_second=4, screen=True) as live:
105
+ # while True:
106
+ # time.sleep(2)
107
+ # live.update(generate_table())
108
+ console = Console(width=width, force_terminal=not jupyter)
109
+ with console.pager():
110
+ console.print(generate_table())
111
+
112
+
113
+ except (InvalidParameterException, PropertyServerException, UserNotAuthorizedException) as e:
114
+ print_exception_response(e)
115
+ assert e.related_http_code != "200", "Invalid parameters"
116
+
117
+ def main():
118
+ parser = argparse.ArgumentParser()
119
+ parser.add_argument("--server", help="Name of the server to display status for")
120
+ parser.add_argument("--url", help="URL Platform to connect to")
121
+ parser.add_argument("--userid", help="User Id")
122
+ parser.add_argument("--password", help="User Password")
123
+
124
+ args = parser.parse_args()
125
+
126
+ server = args.server if args.server is not None else EGERIA_VIEW_SERVER
127
+ url = args.url if args.url is not None else EGERIA_PLATFORM_URL
128
+ userid = args.userid if args.userid is not None else EGERIA_USER
129
+ user_pass = args.password if args.password is not None else EGERIA_USER_PASSWORD
130
+
131
+ display_my_roles(server, url, userid, user_pass)
132
+
133
+ if __name__ == "__main__":
134
+ main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyegeria
3
- Version: 0.5.9.1
3
+ Version: 0.5.9.2
4
4
  Summary: A python client for Egeria
5
5
  Home-page: https://github.com/odpi/egeria-python
6
6
  License: Apache 2.0
@@ -13,7 +13,7 @@ examples/widgets/catalog_user/list_tech_types.py,sha256=20T4v6L5qeebSsaL1nGkFMDA
13
13
  examples/widgets/catalog_user/list_todos.py,sha256=iiHvw0zM2khHDNKnrzNe2i0tqD_3xzrB5Z2Z0tP7N4k,5521
14
14
  examples/widgets/cli/__init__.py,sha256=ReG7mIcm5c512S_z1UZIpMtE67zlO_zj-1HhHWYS4fI,30
15
15
  examples/widgets/cli/egeria_cat.py,sha256=xEzI4Lbl3vyQlJLxMSmDVphhyjTUL1whSfbZi4I2Hwk,9324
16
- examples/widgets/cli/egeria_my.py,sha256=wni3UWzwxnk0hToeUwSLclfHY4Vi1ez4mtRqVGWVi8A,5341
16
+ examples/widgets/cli/egeria_my.py,sha256=sbnUe8Wis2FHGEGlYlg5syH8_LGymzTUMeNjVT4Serk,5676
17
17
  examples/widgets/cli/egeria_ops.py,sha256=ZxfijlBuDdOKdDgflKdJ0npGp5bB35qCzy-SHUGAk0k,10112
18
18
  examples/widgets/cli/egeria_tech.py,sha256=_DjPR5rslrZKk0NshpE_VNQf4YVxBGaVpNqT8YMgt9I,8917
19
19
  examples/widgets/cli/ops_config.py,sha256=BPfiU2mZA61aA1p1DHRA5eLWH8qaAwgWNoRmazzAlM4,1398
@@ -35,7 +35,8 @@ examples/widgets/operational/refresh_integration_daemon.py,sha256=QDB3dpAlLY8Phr
35
35
  examples/widgets/operational/restart_integration_daemon.py,sha256=fID7qGFL5RD6rfn9PgXf5kwI4MU0Ho_IGXnDVbKT5nU,2710
36
36
  examples/widgets/personal/README.md,sha256=ZheFhj_VoPMhcWjW3pGchHB0vH_A9PklSmrSkzKdrcQ,844
37
37
  examples/widgets/personal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
- examples/widgets/personal/list_my_profile.py,sha256=qtf6q4ibvBDsqbtudWc0PeCfGzfK01Na7zCmHbv1JWU,5084
38
+ examples/widgets/personal/list_my_profile.py,sha256=UUjX5PiExGNB-zmkk4Dq3dzUhHX08qMokt8UlOz8cXI,5423
39
+ examples/widgets/personal/list_my_roles.py,sha256=DCiNdnoHXQueUE5g73D3oRXfJ6LaUQGbibNtDRdicR8,5078
39
40
  examples/widgets/personal/monitor_my_todos.py,sha256=uc3WO-IiFdfjJ3gE2MgHBo18A8M6C5QHbCfRVI6qR28,6399
40
41
  examples/widgets/personal/monitor_open_todos.py,sha256=DIeWC-2tN1EtmgC2rWJfsGMVQhtNcngobJ8paBiXXBI,5396
41
42
  examples/widgets/tech/README.md,sha256=nxDnfr3BCiGgW5G1VxWxiwUWJXIe5wreNuUeRyIt_hY,1343
@@ -72,8 +73,8 @@ pyegeria/runtime_manager_omvs.py,sha256=oSVFeG_yBGXIvQR0EClLZqTZ6C5z5ReZzwm8cce8
72
73
  pyegeria/server_operations.py,sha256=ZX7FlJRrAC7RK4bq4wHWepEsYbbWlqkUZdsJrTplVVU,16534
73
74
  pyegeria/utils.py,sha256=pkVmS3RrbjaS9yz7FtOCwaOfV5FMqz-__Rt5koCnd9c,5374
74
75
  pyegeria/valid_metadata_omvs.py,sha256=aisdRodIwJSkyArAzfm_sEnBELh69xE8k4Nea-vHu8M,36745
75
- pyegeria-0.5.9.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
76
- pyegeria-0.5.9.1.dist-info/METADATA,sha256=Q1PdS7m48TAx-hQpd8czlwAeJL0OHlGLeXHVLrzoD_k,2688
77
- pyegeria-0.5.9.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
78
- pyegeria-0.5.9.1.dist-info/entry_points.txt,sha256=YLwELMauo52P2zmfF3ovfayZGcUEVQ2XQnCF4xNzG1M,2781
79
- pyegeria-0.5.9.1.dist-info/RECORD,,
76
+ pyegeria-0.5.9.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
77
+ pyegeria-0.5.9.2.dist-info/METADATA,sha256=GSr79SGcTVVqKYkXukWeD5WB3P1pTx3Y3vZ30AN3USw,2688
78
+ pyegeria-0.5.9.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
79
+ pyegeria-0.5.9.2.dist-info/entry_points.txt,sha256=YLwELMauo52P2zmfF3ovfayZGcUEVQ2XQnCF4xNzG1M,2781
80
+ pyegeria-0.5.9.2.dist-info/RECORD,,