python-service-builder 1.3.0__tar.gz → 2.0.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 (17) hide show
  1. {python_service_builder-1.3.0/python_service_builder.egg-info → python_service_builder-2.0.0}/PKG-INFO +1 -1
  2. {python_service_builder-1.3.0 → python_service_builder-2.0.0}/pyproject.toml +1 -1
  3. {python_service_builder-1.3.0 → python_service_builder-2.0.0/python_service_builder.egg-info}/PKG-INFO +1 -1
  4. {python_service_builder-1.3.0 → python_service_builder-2.0.0}/service_framework/__init__.py +10 -1
  5. {python_service_builder-1.3.0 → python_service_builder-2.0.0}/service_framework/list_services.py +8 -10
  6. python_service_builder-2.0.0/service_framework/services.py +666 -0
  7. {python_service_builder-1.3.0 → python_service_builder-2.0.0}/service_framework/services_test.py +1 -1
  8. python_service_builder-1.3.0/service_framework/services.py +0 -949
  9. {python_service_builder-1.3.0 → python_service_builder-2.0.0}/LICENSE +0 -0
  10. {python_service_builder-1.3.0 → python_service_builder-2.0.0}/README.md +0 -0
  11. {python_service_builder-1.3.0 → python_service_builder-2.0.0}/python_service_builder.egg-info/SOURCES.txt +0 -0
  12. {python_service_builder-1.3.0 → python_service_builder-2.0.0}/python_service_builder.egg-info/dependency_links.txt +0 -0
  13. {python_service_builder-1.3.0 → python_service_builder-2.0.0}/python_service_builder.egg-info/requires.txt +0 -0
  14. {python_service_builder-1.3.0 → python_service_builder-2.0.0}/python_service_builder.egg-info/top_level.txt +0 -0
  15. {python_service_builder-1.3.0 → python_service_builder-2.0.0}/service_framework/__init_test.py +0 -0
  16. {python_service_builder-1.3.0 → python_service_builder-2.0.0}/service_framework/service_builder.py +0 -0
  17. {python_service_builder-1.3.0 → python_service_builder-2.0.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-service-builder
3
- Version: 1.3.0
3
+ Version: 2.0.0
4
4
  Summary: Helper library for easier creation of Google services.
5
5
  Author-email: David Harcombe <david.harcombe@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -4,7 +4,7 @@ build-backend = 'setuptools.build_meta'
4
4
 
5
5
  [project]
6
6
  name = "python-service-builder"
7
- version = "1.3.0"
7
+ version = "2.0.0"
8
8
  authors = [{ name = "David Harcombe", email = "david.harcombe@gmail.com" }]
9
9
  description = "Helper library for easier creation of Google services."
10
10
  readme = "README.md"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-service-builder
3
- Version: 1.3.0
3
+ Version: 2.0.0
4
4
  Summary: Helper library for easier creation of Google services.
5
5
  Author-email: David Harcombe <david.harcombe@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -12,7 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
  import dataclasses
15
- from typing import Any, Callable, Mapping
15
+ from typing import Any, Callable, Mapping, Optional
16
16
 
17
17
  import dataclasses_json
18
18
 
@@ -113,3 +113,12 @@ def camel_field(default: Any = None,
113
113
  """
114
114
  return field(default=default, default_factory=default_factory,
115
115
  letter_case=dataclasses_json.LetterCase.CAMEL, **kwargs)
116
+
117
+
118
+ @dataclasses_json.dataclass_json
119
+ @dataclasses.dataclass
120
+ class ServiceDefinition(object):
121
+ """Defines a Google Service for the builder."""
122
+ service_name: Optional[str] = camel_field()
123
+ version: Optional[str] = camel_field()
124
+ discovery_service_url: Optional[str] = camel_field()
@@ -21,7 +21,6 @@ from pprint import pprint
21
21
  from typing import Mapping
22
22
  from urllib.request import urlopen
23
23
 
24
- import aenum as enum
25
24
  from absl import app
26
25
 
27
26
  from service_framework.services import ServiceDefinition
@@ -30,21 +29,19 @@ from service_framework.services import ServiceDefinition
30
29
  """
31
30
 
32
31
 
33
- class ServiceFinder(enum.EnumMeta):
32
+ class ServiceFinder(object):
34
33
  def __call__(cls, value, *args, **kwargs):
35
34
  api = ServiceLister().find(name=value.lower())
36
35
  if api:
37
- (service_name, version) = api[0]
36
+ (service_name, version, url) = api[value.upper()]
38
37
  definition = ServiceDefinition(
39
38
  service_name=service_name,
40
39
  version=version,
41
- discovery_service_url=(
42
- f'https://{service_name}.googleapis.com/$discovery/rest'
43
- f'?version={version}'))
40
+ discovery_service_url=url)
44
41
  return definition
45
42
 
46
43
  else:
47
- raise Exception(f'No service found for {value}')
44
+ raise Exception(f'No Google service found with the name {value}')
48
45
 
49
46
 
50
47
  class ServiceLister(object):
@@ -59,8 +56,7 @@ class ServiceLister(object):
59
56
 
60
57
  apis = {}
61
58
 
62
- parameters = {#'fields': 'items.name,items.version',
63
- 'preferred': 'true'}
59
+ parameters = {'preferred': 'true'}
64
60
  if name:
65
61
  parameters |= {'name': name}
66
62
 
@@ -90,7 +86,9 @@ def main(unused) -> None:
90
86
 
91
87
  # apis = ServiceLister().find(name='CHAT'.lower())
92
88
  apis = ServiceLister().find_all()
93
- pprint(apis, indent=2)
89
+ # pprint(apis, indent=2)
90
+ for k, v in apis.items():
91
+ print(f'{k} = ServiceDefinition{v}')
94
92
 
95
93
 
96
94
  if __name__ == '__main__':