okdata-cli 4.3.0__tar.gz → 4.4.0__tar.gz

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.
Files changed (55) hide show
  1. {okdata_cli-4.3.0/okdata_cli.egg-info → okdata_cli-4.4.0}/PKG-INFO +3 -2
  2. okdata_cli-4.3.0/okdata/cli/commands/pubs/client.py → okdata_cli-4.4.0/okdata/cli/commands/pubs/clients.py +31 -0
  3. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/commands/pubs/pubs.py +17 -9
  4. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/commands/pubs/questions.py +10 -37
  5. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/commands/pubs/wizards.py +3 -3
  6. {okdata_cli-4.3.0 → okdata_cli-4.4.0/okdata_cli.egg-info}/PKG-INFO +3 -2
  7. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata_cli.egg-info/SOURCES.txt +1 -1
  8. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/setup.py +1 -1
  9. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/LICENSE +0 -0
  10. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/README.md +0 -0
  11. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/__init__.py +0 -0
  12. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/__init__.py +0 -0
  13. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/__main__.py +0 -0
  14. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/command.py +0 -0
  15. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/commands/__init__.py +0 -0
  16. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/commands/datasets/__init__.py +0 -0
  17. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/commands/datasets/datasets.py +0 -0
  18. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/commands/datasets/questions.py +0 -0
  19. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/commands/datasets/wizards.py +0 -0
  20. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/commands/permissions.py +0 -0
  21. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/commands/pubs/__init__.py +0 -0
  22. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/commands/status.py +0 -0
  23. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/commands/teams/questions.py +0 -0
  24. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/commands/teams/teams.py +0 -0
  25. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/commands/teams/util.py +0 -0
  26. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/commands/teams/wizards.py +0 -0
  27. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/commands/validators.py +0 -0
  28. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/commands/wizard.py +0 -0
  29. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/data/output-format/datasets_config.json +0 -0
  30. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/data/output-format/datasets_copy_file_config.json +0 -0
  31. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/data/output-format/datasets_copy_file_config_2.json +0 -0
  32. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/data/output-format/datasets_dataset_config.json +0 -0
  33. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/data/output-format/datasets_dataset_version_config.json +0 -0
  34. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/data/output-format/datasets_dataset_version_edition_config.json +0 -0
  35. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/data/output-format/datasets_dataset_version_edition_distributions_config.json +0 -0
  36. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/data/output-format/datasets_dataset_versions_config.json +0 -0
  37. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/data/output-format/my_permissions_config.json +0 -0
  38. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/data/output-format/permissions_config.json +0 -0
  39. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/data/output-format/pubs_audit_log_config.json +0 -0
  40. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/data/output-format/pubs_clients_config.json +0 -0
  41. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/data/output-format/pubs_multiple_client_keys_config.json +0 -0
  42. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/data/output-format/pubs_single_client_keys_config.json +0 -0
  43. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/data/output-format/status_config.json +0 -0
  44. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/data/output-format/status_history_config.json +0 -0
  45. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/data/output-format/team_members_config.json +0 -0
  46. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/data/output-format/teams_config.json +0 -0
  47. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/io.py +0 -0
  48. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata/cli/output.py +0 -0
  49. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata_cli.egg-info/dependency_links.txt +0 -0
  50. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata_cli.egg-info/entry_points.txt +0 -0
  51. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata_cli.egg-info/namespace_packages.txt +0 -0
  52. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata_cli.egg-info/requires.txt +0 -0
  53. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/okdata_cli.egg-info/top_level.txt +0 -0
  54. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/pyproject.toml +0 -0
  55. {okdata_cli-4.3.0 → okdata_cli-4.4.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: okdata-cli
3
- Version: 4.3.0
3
+ Version: 4.4.0
4
4
  Summary: CLI for services provided by Oslo Origo
5
5
  Home-page: https://github.com/oslokommune/okdata-cli/
6
6
  Author: Oslo Origo
@@ -29,6 +29,7 @@ Dynamic: description
29
29
  Dynamic: description-content-type
30
30
  Dynamic: home-page
31
31
  Dynamic: license
32
+ Dynamic: license-file
32
33
  Dynamic: requires-dist
33
34
  Dynamic: requires-python
34
35
  Dynamic: summary
@@ -98,3 +98,34 @@ class PubsClient(SDK):
98
98
  url = f"{self.api_url}/audit/{env}/{client_id}/log"
99
99
  log.info(f"Fetching audit log from: {url}")
100
100
  return self.get(url).json()
101
+
102
+
103
+ class ProvidersClient(SDK):
104
+ def __init__(self, config=None, auth=None, env=None):
105
+ self.__name__ = "providers"
106
+ super().__init__(config, auth, env)
107
+ self.api_url = "https://api.data{}.oslo.systems/maskinporten/providers".format(
108
+ "-dev" if self.config.config["env"] == "dev" else ""
109
+ )
110
+
111
+ def get_providers(self):
112
+ log.info(f"Listing providers from: {self.api_url}")
113
+ providers = self.get(self.api_url).json()
114
+ return {p["provider_id"]: p["name"] for p in providers}
115
+
116
+
117
+ class ScopesClient(SDK):
118
+ def __init__(self, config=None, auth=None, env=None):
119
+ self.__name__ = "scopes"
120
+ super().__init__(config, auth, env)
121
+ self.api_url = "https://api.data{}.oslo.systems/maskinporten/scopes".format(
122
+ "-dev" if self.config.config["env"] == "dev" else ""
123
+ )
124
+
125
+ def get_scopes(self):
126
+ log.info(f"Listing scopes from: {self.api_url}")
127
+ scopes = self.get(self.api_url).json()
128
+ scopes_dict = {}
129
+ for scope in scopes:
130
+ scopes_dict.setdefault(scope["provider_id"], []).append(scope["scope"])
131
+ return scopes_dict
@@ -1,18 +1,14 @@
1
1
  import base64
2
2
  from datetime import datetime
3
+ from functools import cached_property
3
4
  from operator import itemgetter
4
5
 
5
6
  from okdata.sdk.team.client import TeamClient
6
7
 
7
8
  from okdata.cli import MAINTAINER
8
9
  from okdata.cli.command import BASE_COMMAND_OPTIONS, BaseCommand, confirm_to_continue
9
- from okdata.cli.commands.pubs.client import PubsClient
10
- from okdata.cli.commands.pubs.questions import (
11
- NoClientsError,
12
- NoKeysError,
13
- client_types,
14
- providers,
15
- )
10
+ from okdata.cli.commands.pubs.clients import ProvidersClient, PubsClient, ScopesClient
11
+ from okdata.cli.commands.pubs.questions import NoClientsError, NoKeysError, client_types
16
12
  from okdata.cli.commands.pubs.wizards import (
17
13
  audit_log_wizard,
18
14
  create_client_wizard,
@@ -54,6 +50,16 @@ Options:{BASE_COMMAND_OPTIONS}
54
50
  super().__init__()
55
51
  self.pubs_client = PubsClient(env=self.opt("env"))
56
52
  self.team_client = TeamClient(env=self.opt("env"))
53
+ self.providers_client = ProvidersClient(env=self.opt("env"))
54
+ self.scopes_client = ScopesClient(env=self.opt("env"))
55
+
56
+ @cached_property
57
+ def _providers(self):
58
+ return self.providers_client.get_providers()
59
+
60
+ @cached_property
61
+ def _scopes(self):
62
+ return self.scopes_client.get_scopes()
57
63
 
58
64
  def handler(self):
59
65
  if self.cmd("create-client"):
@@ -73,7 +79,9 @@ Options:{BASE_COMMAND_OPTIONS}
73
79
 
74
80
  def create_client(self):
75
81
  try:
76
- config = create_client_wizard(self.team_client)
82
+ config = create_client_wizard(
83
+ self.team_client, self._providers, self._scopes
84
+ )
77
85
  except NoTeamError:
78
86
  self.print(
79
87
  "We haven't yet registered you as member of any Origo team. "
@@ -91,7 +99,7 @@ Options:{BASE_COMMAND_OPTIONS}
91
99
  confirm_to_continue(
92
100
  "Will create a new {} client{} in {}{}.".format(
93
101
  client_types[client_type_id],
94
- f" for {providers[provider_id]}" if provider_id else "",
102
+ f" for {self._providers[provider_id]}" if provider_id else "",
95
103
  env,
96
104
  f" with scopes {scopes}" if scopes else "",
97
105
  )
@@ -1,4 +1,4 @@
1
- from operator import itemgetter
1
+ from operator import attrgetter, itemgetter
2
2
 
3
3
  from questionary import Choice
4
4
 
@@ -15,38 +15,6 @@ client_types = {
15
15
  "maskinporten": "Maskinporten",
16
16
  }
17
17
 
18
- providers = {
19
- "freg": "Folkeregisteret",
20
- "krr": "Kontaktregisteret",
21
- "skatt": "Skatteetaten",
22
- }
23
-
24
- _scopes = {
25
- "freg": [
26
- "folkeregister:deling/offentligmedhjemmel",
27
- "folkeregister:deling/offentligutenhjemmel",
28
- ],
29
- "krr": [
30
- "krr:global/digitalpost.read",
31
- "krr:global/kontaktinformasjon.read",
32
- ],
33
- "skatt": [
34
- "skatteetaten:arbeidsgiveravgift",
35
- "skatteetaten:avregning",
36
- "skatteetaten:boligsparingforungdom",
37
- "skatteetaten:inntekt",
38
- "skatteetaten:inntektsmottakere",
39
- "skatteetaten:mvameldingsopplysning",
40
- "skatteetaten:oppdragutenlandskevirksomheter",
41
- "skatteetaten:restanser",
42
- "skatteetaten:skattemelding",
43
- "skatteetaten:skatteplikt",
44
- "skatteetaten:spesifisertsummertskattegrunnlag",
45
- "skatteetaten:summertskattegrunnlag",
46
- "skatteetaten:tjenestepensjonsavtale",
47
- ],
48
- }
49
-
50
18
  _environments = [
51
19
  "test",
52
20
  "prod",
@@ -87,24 +55,29 @@ def q_client_type():
87
55
  }
88
56
 
89
57
 
90
- def q_provider():
58
+ def q_provider(providers):
91
59
  return {
92
60
  **required_style,
93
61
  "type": "select",
94
62
  "name": "provider_id",
95
63
  "message": "Provider",
96
- "choices": [Choice(pname, pid) for pid, pname in providers.items()],
64
+ "choices": sorted(
65
+ [Choice(pname, pid) for pid, pname in providers.items()],
66
+ key=attrgetter("title"),
67
+ ),
97
68
  "when": lambda x: x.get("client_type_id") == "maskinporten",
98
69
  }
99
70
 
100
71
 
101
- def q_scopes():
72
+ def q_scopes(scopes):
102
73
  return {
103
74
  **required_style,
104
75
  "type": "checkbox",
105
76
  "name": "scopes",
106
77
  "message": "Scopes",
107
- "choices": lambda x: _scopes[x["provider_id"]] if "provider_id" in x else [],
78
+ "choices": lambda x: (
79
+ sorted(scopes[x["provider_id"]]) if "provider_id" in x else []
80
+ ),
108
81
  "validate": (lambda choices: bool(choices) or "Select at least one scope"),
109
82
  "when": lambda x: x.get("client_type_id") == "maskinporten",
110
83
  }
@@ -20,13 +20,13 @@ from okdata.cli.commands.teams.questions import q_team
20
20
  from okdata.cli.commands.wizard import run_questionnaire
21
21
 
22
22
 
23
- def create_client_wizard(team_client):
23
+ def create_client_wizard(team_client, providers, scopes):
24
24
  choices = run_questionnaire(
25
25
  q_env(),
26
26
  q_team(team_client),
27
27
  q_client_type(),
28
- q_provider(),
29
- q_scopes(),
28
+ q_provider(providers),
29
+ q_scopes(scopes),
30
30
  q_integration(),
31
31
  q_redirect_uris(),
32
32
  q_post_logout_redirect_uris(),
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: okdata-cli
3
- Version: 4.3.0
3
+ Version: 4.4.0
4
4
  Summary: CLI for services provided by Oslo Origo
5
5
  Home-page: https://github.com/oslokommune/okdata-cli/
6
6
  Author: Oslo Origo
@@ -29,6 +29,7 @@ Dynamic: description
29
29
  Dynamic: description-content-type
30
30
  Dynamic: home-page
31
31
  Dynamic: license
32
+ Dynamic: license-file
32
33
  Dynamic: requires-dist
33
34
  Dynamic: requires-python
34
35
  Dynamic: summary
@@ -18,7 +18,7 @@ okdata/cli/commands/datasets/datasets.py
18
18
  okdata/cli/commands/datasets/questions.py
19
19
  okdata/cli/commands/datasets/wizards.py
20
20
  okdata/cli/commands/pubs/__init__.py
21
- okdata/cli/commands/pubs/client.py
21
+ okdata/cli/commands/pubs/clients.py
22
22
  okdata/cli/commands/pubs/pubs.py
23
23
  okdata/cli/commands/pubs/questions.py
24
24
  okdata/cli/commands/pubs/wizards.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="okdata-cli",
8
- version="4.3.0",
8
+ version="4.4.0",
9
9
  author="Oslo Origo",
10
10
  author_email="dataspeilet@oslo.kommune.no",
11
11
  description="CLI for services provided by Oslo Origo",
File without changes
File without changes
File without changes
File without changes
File without changes