unitysvc-services 0.2.0__tar.gz → 0.2.1__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 (59) hide show
  1. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/PKG-INFO +1 -1
  2. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/pyproject.toml +1 -1
  3. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services/publisher.py +25 -108
  4. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services/query.py +18 -34
  5. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services.egg-info/PKG-INFO +1 -1
  6. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/CONTRIBUTING.md +0 -0
  7. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/HISTORY.md +0 -0
  8. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/LICENSE +0 -0
  9. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/MANIFEST.in +0 -0
  10. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/README.md +0 -0
  11. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/docs/api-reference.md +0 -0
  12. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/docs/cli-reference.md +0 -0
  13. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/docs/contributing.md +0 -0
  14. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/docs/data-structure.md +0 -0
  15. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/docs/development.md +0 -0
  16. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/docs/file-schemas.md +0 -0
  17. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/docs/getting-started.md +0 -0
  18. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/docs/index.md +0 -0
  19. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/docs/installation.md +0 -0
  20. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/docs/usage.md +0 -0
  21. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/docs/workflows.md +0 -0
  22. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/setup.cfg +0 -0
  23. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services/__init__.py +0 -0
  24. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services/cli.py +0 -0
  25. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services/format_data.py +0 -0
  26. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services/list.py +0 -0
  27. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services/models/__init__.py +0 -0
  28. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services/models/base.py +0 -0
  29. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services/models/listing_v1.py +0 -0
  30. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services/models/provider_v1.py +0 -0
  31. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services/models/seller_v1.py +0 -0
  32. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services/models/service_v1.py +0 -0
  33. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services/populate.py +0 -0
  34. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services/scaffold.py +0 -0
  35. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services/update.py +0 -0
  36. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services/utils.py +0 -0
  37. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services/validator.py +0 -0
  38. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services.egg-info/SOURCES.txt +0 -0
  39. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services.egg-info/dependency_links.txt +0 -0
  40. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services.egg-info/entry_points.txt +0 -0
  41. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services.egg-info/requires.txt +0 -0
  42. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/src/unitysvc_services.egg-info/top_level.txt +0 -0
  43. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/tests/__init__.py +0 -0
  44. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/tests/example_data/README.md +0 -0
  45. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/tests/example_data/provider1/README.md +0 -0
  46. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/tests/example_data/provider1/provider.toml +0 -0
  47. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/tests/example_data/provider1/services/service1/code-example.md +0 -0
  48. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/tests/example_data/provider1/services/service1/service.toml +0 -0
  49. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/tests/example_data/provider1/services/service1/svcreseller.toml +0 -0
  50. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/tests/example_data/provider1/terms-of-service.md +0 -0
  51. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/tests/example_data/provider2/README.md +0 -0
  52. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/tests/example_data/provider2/provider.json +0 -0
  53. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/tests/example_data/provider2/services/service2/code-example.md +0 -0
  54. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/tests/example_data/provider2/services/service2/service.json +0 -0
  55. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/tests/example_data/provider2/services/service2/svcreseller.json +0 -0
  56. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/tests/example_data/provider2/terms-of-service.md +0 -0
  57. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/tests/example_data/seller.json +0 -0
  58. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/tests/test_utils.py +0 -0
  59. {unitysvc_services-0.2.0 → unitysvc_services-0.2.1}/tests/test_validator.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: unitysvc-services
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: SDK for digital service providers on UnitySVC
5
5
  Author-email: Bo Peng <bo.peng@unitysvc.com>
6
6
  Maintainer-email: Bo Peng <bo.peng@unitysvc.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "unitysvc-services"
3
- version = "0.2.0"
3
+ version = "0.2.1"
4
4
  description = "SDK for digital service providers on UnitySVC"
5
5
  readme = "README.md"
6
6
  authors = [{ name = "Bo Peng", email = "bo.peng@unitysvc.com" }]
@@ -19,12 +19,19 @@ from .validator import DataValidator
19
19
  class ServiceDataPublisher:
20
20
  """Publishes service data to UnitySVC backend endpoints."""
21
21
 
22
- def __init__(self, base_url: str, api_key: str):
23
- self.base_url = base_url.rstrip("/")
24
- self.api_key = api_key
22
+ def __init__(self):
23
+ self.base_url = os.environ.get("UNITYSVC_BASE_URL")
24
+ if not self.base_url:
25
+ raise ValueError("UNITYSVC_BASE_URL environment variable not set")
26
+
27
+ self.api_key = os.environ.get("UNITYSVC_API_KEY")
28
+ if not self.api_key:
29
+ raise ValueError("UNITYSVC_API_KEY environment variable not set")
30
+
31
+ self.base_url = self.base_url.rstrip("/")
25
32
  self.client = httpx.Client(
26
33
  headers={
27
- "X-API-Key": api_key,
34
+ "X-API-Key": self.api_key,
28
35
  "Content-Type": "application/json",
29
36
  },
30
37
  timeout=30.0,
@@ -573,29 +580,11 @@ def publish_callback(
573
580
  console.print(f"[red]✗[/red] Path not found: {data_path}", style="bold red")
574
581
  raise typer.Exit(code=1)
575
582
 
576
- # Get backend URL from environment
577
- backend_url = os.getenv("UNITYSVC_BASE_URL")
578
- if not backend_url:
579
- console.print(
580
- "[red]✗[/red] UNITYSVC_BASE_URL environment variable not set.",
581
- style="bold red",
582
- )
583
- raise typer.Exit(code=1)
584
-
585
- # Get API key from environment
586
- api_key = os.getenv("UNITYSVC_API_KEY")
587
- if not api_key:
588
- console.print(
589
- "[red]✗[/red] UNITYSVC_API_KEY environment variable not set.",
590
- style="bold red",
591
- )
592
- raise typer.Exit(code=1)
593
-
594
583
  console.print(f"[bold blue]Publishing all data from:[/bold blue] {data_path}")
595
- console.print(f"[bold blue]Backend URL:[/bold blue] {backend_url}\n")
584
+ console.print(f"[bold blue]Backend URL:[/bold blue] {os.getenv('UNITYSVC_BASE_URL', 'N/A')}\n")
596
585
 
597
586
  try:
598
- with ServiceDataPublisher(backend_url, api_key) as publisher:
587
+ with ServiceDataPublisher() as publisher:
599
588
  # Call the publish_all_models method
600
589
  all_results = publisher.publish_all_models(data_path)
601
590
 
@@ -678,37 +667,19 @@ def publish_providers(
678
667
  console.print(f"[red]✗[/red] Path not found: {data_path}", style="bold red")
679
668
  raise typer.Exit(code=1)
680
669
 
681
- # Get backend URL from environment
682
- backend_url = os.getenv("UNITYSVC_BASE_URL")
683
- if not backend_url:
684
- console.print(
685
- "[red]✗[/red] UNITYSVC_BASE_URL environment variable not set.",
686
- style="bold red",
687
- )
688
- raise typer.Exit(code=1)
689
-
690
- # Get API key from environment
691
- api_key = os.getenv("UNITYSVC_API_KEY")
692
- if not api_key:
693
- console.print(
694
- "[red]✗[/red] UNITYSVC_API_KEY environment variable not set.",
695
- style="bold red",
696
- )
697
- raise typer.Exit(code=1)
698
-
699
670
  try:
700
- with ServiceDataPublisher(backend_url, api_key) as publisher:
671
+ with ServiceDataPublisher() as publisher:
701
672
  # Handle single file
702
673
  if data_path.is_file():
703
674
  console.print(f"[blue]Publishing provider:[/blue] {data_path}")
704
- console.print(f"[blue]Backend URL:[/blue] {backend_url}\n")
675
+ console.print(f"[blue]Backend URL:[/blue] {os.getenv('UNITYSVC_BASE_URL', 'N/A')}\n")
705
676
  result = publisher.post_provider(data_path)
706
677
  console.print("[green]✓[/green] Provider published successfully!")
707
678
  console.print(f"[cyan]Response:[/cyan] {json.dumps(result, indent=2)}")
708
679
  # Handle directory
709
680
  else:
710
681
  console.print(f"[blue]Scanning for providers in:[/blue] {data_path}")
711
- console.print(f"[blue]Backend URL:[/blue] {backend_url}\n")
682
+ console.print(f"[blue]Backend URL:[/blue] {os.getenv('UNITYSVC_BASE_URL', 'N/A')}\n")
712
683
  results = publisher.publish_all_providers(data_path)
713
684
 
714
685
  # Display summary
@@ -755,37 +726,19 @@ def publish_sellers(
755
726
  console.print(f"[red]✗[/red] Path not found: {data_path}", style="bold red")
756
727
  raise typer.Exit(code=1)
757
728
 
758
- # Get backend URL from environment
759
- backend_url = os.getenv("UNITYSVC_BASE_URL")
760
- if not backend_url:
761
- console.print(
762
- "[red]✗[/red] UNITYSVC_BASE_URL environment variable not set.",
763
- style="bold red",
764
- )
765
- raise typer.Exit(code=1)
766
-
767
- # Get API key from environment
768
- api_key = os.getenv("UNITYSVC_API_KEY")
769
- if not api_key:
770
- console.print(
771
- "[red]✗[/red] UNITYSVC_API_KEY environment variable not set.",
772
- style="bold red",
773
- )
774
- raise typer.Exit(code=1)
775
-
776
729
  try:
777
- with ServiceDataPublisher(backend_url, api_key) as publisher:
730
+ with ServiceDataPublisher() as publisher:
778
731
  # Handle single file
779
732
  if data_path.is_file():
780
733
  console.print(f"[blue]Publishing seller:[/blue] {data_path}")
781
- console.print(f"[blue]Backend URL:[/blue] {backend_url}\n")
734
+ console.print(f"[blue]Backend URL:[/blue] {os.getenv('UNITYSVC_BASE_URL', 'N/A')}\n")
782
735
  result = publisher.post_seller(data_path)
783
736
  console.print("[green]✓[/green] Seller published successfully!")
784
737
  console.print(f"[cyan]Response:[/cyan] {json.dumps(result, indent=2)}")
785
738
  # Handle directory
786
739
  else:
787
740
  console.print(f"[blue]Scanning for sellers in:[/blue] {data_path}")
788
- console.print(f"[blue]Backend URL:[/blue] {backend_url}\n")
741
+ console.print(f"[blue]Backend URL:[/blue] {os.getenv('UNITYSVC_BASE_URL', 'N/A')}\n")
789
742
  results = publisher.publish_all_sellers(data_path)
790
743
 
791
744
  console.print("\n[bold]Publishing Summary:[/bold]")
@@ -830,37 +783,19 @@ def publish_offerings(
830
783
  console.print(f"[red]✗[/red] Path not found: {data_path}", style="bold red")
831
784
  raise typer.Exit(code=1)
832
785
 
833
- # Get backend URL from environment
834
- backend_url = os.getenv("UNITYSVC_BASE_URL")
835
- if not backend_url:
836
- console.print(
837
- "[red]✗[/red] UNITYSVC_BASE_URL environment variable not set.",
838
- style="bold red",
839
- )
840
- raise typer.Exit(code=1)
841
-
842
- # Get API key from environment
843
- api_key = os.getenv("UNITYSVC_API_KEY")
844
- if not api_key:
845
- console.print(
846
- "[red]✗[/red] UNITYSVC_API_KEY environment variable not set.",
847
- style="bold red",
848
- )
849
- raise typer.Exit(code=1)
850
-
851
786
  try:
852
- with ServiceDataPublisher(backend_url, api_key) as publisher:
787
+ with ServiceDataPublisher() as publisher:
853
788
  # Handle single file
854
789
  if data_path.is_file():
855
790
  console.print(f"[blue]Publishing service offering:[/blue] {data_path}")
856
- console.print(f"[blue]Backend URL:[/blue] {backend_url}\n")
791
+ console.print(f"[blue]Backend URL:[/blue] {os.getenv('UNITYSVC_BASE_URL', 'N/A')}\n")
857
792
  result = publisher.post_service_offering(data_path)
858
793
  console.print("[green]✓[/green] Service offering published successfully!")
859
794
  console.print(f"[cyan]Response:[/cyan] {json.dumps(result, indent=2)}")
860
795
  # Handle directory
861
796
  else:
862
797
  console.print(f"[blue]Scanning for service offerings in:[/blue] {data_path}")
863
- console.print(f"[blue]Backend URL:[/blue] {backend_url}\n")
798
+ console.print(f"[blue]Backend URL:[/blue] {os.getenv('UNITYSVC_BASE_URL', 'N/A')}\n")
864
799
  results = publisher.publish_all_offerings(data_path)
865
800
 
866
801
  console.print("\n[bold]Publishing Summary:[/bold]")
@@ -906,37 +841,19 @@ def publish_listings(
906
841
  console.print(f"[red]✗[/red] Path not found: {data_path}", style="bold red")
907
842
  raise typer.Exit(code=1)
908
843
 
909
- # Get backend URL from environment
910
- backend_url = os.getenv("UNITYSVC_BASE_URL")
911
- if not backend_url:
912
- console.print(
913
- "[red]✗[/red] UNITYSVC_BASE_URL environment variable not set.",
914
- style="bold red",
915
- )
916
- raise typer.Exit(code=1)
917
-
918
- # Get API key from environment
919
- api_key = os.getenv("UNITYSVC_API_KEY")
920
- if not api_key:
921
- console.print(
922
- "[red]✗[/red] UNITYSVC_API_KEY environment variable not set.",
923
- style="bold red",
924
- )
925
- raise typer.Exit(code=1)
926
-
927
844
  try:
928
- with ServiceDataPublisher(backend_url, api_key) as publisher:
845
+ with ServiceDataPublisher() as publisher:
929
846
  # Handle single file
930
847
  if data_path.is_file():
931
848
  console.print(f"[blue]Publishing service listing:[/blue] {data_path}")
932
- console.print(f"[blue]Backend URL:[/blue] {backend_url}\n")
849
+ console.print(f"[blue]Backend URL:[/blue] {os.getenv('UNITYSVC_BASE_URL', 'N/A')}\n")
933
850
  result = publisher.post_service_listing(data_path)
934
851
  console.print("[green]✓[/green] Service listing published successfully!")
935
852
  console.print(f"[cyan]Response:[/cyan] {json.dumps(result, indent=2)}")
936
853
  # Handle directory
937
854
  else:
938
855
  console.print(f"[blue]Scanning for service listings in:[/blue] {data_path}")
939
- console.print(f"[blue]Backend URL:[/blue] {backend_url}\n")
856
+ console.print(f"[blue]Backend URL:[/blue] {os.getenv('UNITYSVC_BASE_URL', 'N/A')}\n")
940
857
  results = publisher.publish_all_listings(data_path)
941
858
 
942
859
  console.print("\n[bold]Publishing Summary:[/bold]")
@@ -16,26 +16,24 @@ console = Console()
16
16
  class ServiceDataQuery:
17
17
  """Query service data from UnitySVC backend endpoints."""
18
18
 
19
- def __init__(self, base_url: str, api_key: str):
20
- """Initialize query client with backend URL and API key.
21
-
22
- Args:
23
- base_url: UnitySVC backend URL
24
- api_key: API key for authentication
19
+ def __init__(self):
20
+ """Initialize query client from environment variables.
25
21
 
26
22
  Raises:
27
- ValueError: If base_url or api_key is not provided
23
+ ValueError: If required environment variables are not set
28
24
  """
29
- if not base_url:
30
- raise ValueError("UNITYSVC_BASE_URL environment variable not set.")
31
- if not api_key:
32
- raise ValueError("UNITYSVC_API_KEY environment variable not set.")
25
+ self.base_url = os.environ.get("UNITYSVC_BASE_URL")
26
+ if not self.base_url:
27
+ raise ValueError("UNITYSVC_BASE_URL environment variable not set")
28
+
29
+ self.api_key = os.environ.get("UNITYSVC_API_KEY")
30
+ if not self.api_key:
31
+ raise ValueError("UNITYSVC_API_KEY environment variable not set")
33
32
 
34
- self.base_url = base_url.rstrip("/")
35
- self.api_key = api_key
33
+ self.base_url = self.base_url.rstrip("/")
36
34
  self.client = httpx.Client(
37
35
  headers={
38
- "X-API-Key": api_key,
36
+ "X-API-Key": self.api_key,
39
37
  "Content-Type": "application/json",
40
38
  },
41
39
  timeout=30.0,
@@ -93,20 +91,6 @@ class ServiceDataQuery:
93
91
  """Context manager exit."""
94
92
  self.close()
95
93
 
96
- @staticmethod
97
- def from_env() -> "ServiceDataQuery":
98
- """Create ServiceDataQuery from environment variables.
99
-
100
- Returns:
101
- ServiceDataQuery instance
102
-
103
- Raises:
104
- ValueError: If required environment variables are not set
105
- """
106
- backend_url = os.getenv("UNITYSVC_BASE_URL") or ""
107
- api_key = os.getenv("UNITYSVC_API_KEY") or ""
108
- return ServiceDataQuery(base_url=backend_url, api_key=api_key)
109
-
110
94
 
111
95
  @app.command("sellers")
112
96
  def query_sellers(
@@ -119,7 +103,7 @@ def query_sellers(
119
103
  ):
120
104
  """Query all sellers from the backend."""
121
105
  try:
122
- with ServiceDataQuery.from_env() as query:
106
+ with ServiceDataQuery() as query:
123
107
  sellers = query.list_sellers()
124
108
 
125
109
  if format == "json":
@@ -166,7 +150,7 @@ def query_providers(
166
150
  ):
167
151
  """Query all providers from the backend."""
168
152
  try:
169
- with ServiceDataQuery.from_env() as query:
153
+ with ServiceDataQuery() as query:
170
154
  providers = query.list_providers()
171
155
 
172
156
  if format == "json":
@@ -209,7 +193,7 @@ def query_offerings(
209
193
  ):
210
194
  """Query all service offerings from UnitySVC backend."""
211
195
  try:
212
- with ServiceDataQuery.from_env() as query:
196
+ with ServiceDataQuery() as query:
213
197
  offerings = query.list_service_offerings()
214
198
 
215
199
  if format == "json":
@@ -257,7 +241,7 @@ def query_listings(
257
241
  ):
258
242
  """Query all service listings from UnitySVC backend."""
259
243
  try:
260
- with ServiceDataQuery.from_env() as query:
244
+ with ServiceDataQuery() as query:
261
245
  listings = query.list_service_listings()
262
246
 
263
247
  if format == "json":
@@ -304,7 +288,7 @@ def query_interfaces(
304
288
  ):
305
289
  """Query all access interfaces from UnitySVC backend (private endpoint)."""
306
290
  try:
307
- with ServiceDataQuery.from_env() as query:
291
+ with ServiceDataQuery() as query:
308
292
  data = query.list_access_interfaces()
309
293
 
310
294
  if format == "json":
@@ -353,7 +337,7 @@ def query_documents(
353
337
  ):
354
338
  """Query all documents from UnitySVC backend (private endpoint)."""
355
339
  try:
356
- with ServiceDataQuery.from_env() as query:
340
+ with ServiceDataQuery() as query:
357
341
  data = query.list_documents()
358
342
 
359
343
  if format == "json":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: unitysvc-services
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: SDK for digital service providers on UnitySVC
5
5
  Author-email: Bo Peng <bo.peng@unitysvc.com>
6
6
  Maintainer-email: Bo Peng <bo.peng@unitysvc.com>