wasm-action 0.0.2__tar.gz → 0.0.4__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 (76) hide show
  1. {wasm_action-0.0.2 → wasm_action-0.0.4}/PKG-INFO +20 -4
  2. {wasm_action-0.0.2 → wasm_action-0.0.4}/README.md +18 -3
  3. {wasm_action-0.0.2 → wasm_action-0.0.4}/pyproject.toml +11 -2
  4. wasm_action-0.0.4/src/warg_openapi/models/package_record.py +217 -0
  5. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/processing_record.py +11 -2
  6. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/prove_inclusion422_response.py +35 -0
  7. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/published_record.py +11 -2
  8. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/rejected_record.py +11 -2
  9. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/sourcing_record.py +11 -2
  10. wasm_action-0.0.4/src/wasm_action/__init__.py +9 -0
  11. wasm_action-0.0.4/src/wasm_action/cli.py +68 -0
  12. wasm_action-0.0.4/src/wasm_action/lib.py +170 -0
  13. wasm_action-0.0.4/src/wasm_action/registry.py +48 -0
  14. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/wasm_action/util.py +9 -36
  15. wasm_action-0.0.2/src/wasm_action/warg_pull.py → wasm_action-0.0.4/src/wasm_action/warg/actions.py +80 -6
  16. wasm_action-0.0.4/src/wasm_action/warg/client.py +201 -0
  17. wasm_action-0.0.2/src/wasm_action/warg_crypto.py → wasm_action-0.0.4/src/wasm_action/warg/crypto.py +5 -1
  18. wasm_action-0.0.2/src/warg_openapi/models/package_record.py +0 -93
  19. wasm_action-0.0.2/src/wasm_action/action.py +0 -123
  20. wasm_action-0.0.2/src/wasm_action/model.py +0 -28
  21. wasm_action-0.0.2/src/wasm_action/warg_client.py +0 -78
  22. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/__init__.py +0 -0
  23. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/api/__init__.py +0 -0
  24. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/api/content_api.py +0 -0
  25. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/api/fetch_api.py +0 -0
  26. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/api/ledger_api.py +0 -0
  27. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/api/monitor_api.py +0 -0
  28. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/api/package_api.py +0 -0
  29. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/api/proof_api.py +0 -0
  30. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/api_client.py +0 -0
  31. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/api_response.py +0 -0
  32. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/configuration.py +0 -0
  33. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/exceptions.py +0 -0
  34. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/__init__.py +0 -0
  35. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/bundle_failure_error.py +0 -0
  36. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/checkpoint.py +0 -0
  37. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/checkpoint_verification_response.py +0 -0
  38. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/content_sources_response.py +0 -0
  39. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/envelope_body.py +0 -0
  40. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/error.py +0 -0
  41. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/fetch_logs404_response.py +0 -0
  42. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/fetch_logs_id_not_found_error.py +0 -0
  43. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/fetch_logs_log_length_not_found_error.py +0 -0
  44. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/fetch_logs_request.py +0 -0
  45. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/fetch_logs_response.py +0 -0
  46. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/fetch_names404_response.py +0 -0
  47. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/fetch_package_names_request.py +0 -0
  48. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/fetch_package_names_response.py +0 -0
  49. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/fetch_warning.py +0 -0
  50. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/get_content_sources404_response.py +0 -0
  51. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/get_package_record404_response.py +0 -0
  52. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/http_get.py +0 -0
  53. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/http_upload.py +0 -0
  54. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/http_upload_headers.py +0 -0
  55. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/incorrect_proof_error.py +0 -0
  56. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/ledger_sources_response.py +0 -0
  57. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/ledger_sources_response_sources_inner.py +0 -0
  58. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/missing_content.py +0 -0
  59. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/package_not_included_error.py +0 -0
  60. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/prove_consistency404_response.py +0 -0
  61. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/prove_consistency_request.py +0 -0
  62. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/prove_consistency_response.py +0 -0
  63. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/prove_inclusion404_response.py +0 -0
  64. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/prove_inclusion_request.py +0 -0
  65. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/prove_inclusion_response.py +0 -0
  66. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/publish_package_record404_response.py +0 -0
  67. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/publish_package_record409_response.py +0 -0
  68. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/publish_package_record_request.py +0 -0
  69. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/published_record_envelope.py +0 -0
  70. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/signature.py +0 -0
  71. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/signed_checkpoint.py +0 -0
  72. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/models/timestamped_checkpoint.py +0 -0
  73. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/py.typed +0 -0
  74. {wasm_action-0.0.2 → wasm_action-0.0.4}/src/warg_openapi/rest.py +0 -0
  75. {wasm_action-0.0.2/src/wasm_action → wasm_action-0.0.4/src/wasm_action/warg}/__init__.py +0 -0
  76. /wasm_action-0.0.2/src/wasm_action/warg_proto.py → /wasm_action-0.0.4/src/wasm_action/warg/proto.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: wasm-action
3
- Version: 0.0.2
3
+ Version: 0.0.4
4
4
  Summary: Interact with WebAssembly registries.
5
5
  Requires-Dist: click>=8.2.1
6
6
  Requires-Dist: cryptography>=45.0.6
@@ -13,6 +13,7 @@ Requires-Dist: semver>=3.0.4
13
13
  Requires-Dist: urllib3>=1.25.3
14
14
  Requires-Dist: validators>=0.35.0
15
15
  Requires-Python: >=3.10
16
+ Project-URL: Repository, https://github.com/xelato/wasm-action
16
17
  Description-Content-Type: text/markdown
17
18
 
18
19
  # wasm-action
@@ -20,10 +21,10 @@ Description-Content-Type: text/markdown
20
21
  **Interact with WebAssembly registries.**
21
22
 
22
23
  ## Features
23
- * Versatile use as a GitHub [action](https://github.com/marketplace/actions/wasm-action), CLI or Python [library](https://pypi.org/project/wasm-action/).
24
+ * Versatile use as GitHub [action](https://github.com/marketplace/actions/wasm-action), CLI or Python [library](https://pypi.org/project/wasm-action/).
24
25
  * Supported registry types: warg (wa.dev)
25
26
  * Supported artifact types: wasm
26
- * Supported actions: pull (public and private packages)
27
+ * Supported actions: push, pull
27
28
  * Supports Python 3.10+ on Linux, MacOS and Windows
28
29
 
29
30
  ## Usage
@@ -63,6 +64,19 @@ To pull a private package define your [token](https://wa.dev/account/credentials
63
64
  |filename|Download location|foo-bar_1.2.3.wasm|
64
65
  |digest|File hash|sha256:2afffac0...|
65
66
 
67
+ ### Push to registry
68
+ ```
69
+ - uses: xelato/wasm-action
70
+ with:
71
+ action: push
72
+ registry: wa.dev
73
+ package: foo:bar@1.2.3
74
+ path: files/foo_bar_1.2.3.wasm
75
+ env:
76
+ WARG_TOKEN: ${{ secrets.WARG_TOKEN }}
77
+ WARG_PRIVATE_KEY: ${{ secrets.WARG_PRIVATE_KEY }}
78
+ ```
79
+
66
80
  ## CLI
67
81
  The tool can be run without installing using [uv](https://docs.astral.sh/uv/).
68
82
  ```
@@ -112,6 +126,8 @@ The package is [published](http://pypi.org/project/wasm-action/) to the Python P
112
126
  $ pip install wasm-action
113
127
  ```
114
128
  ```
115
- > import wasm_action as wa
129
+ >>> import wasm_action as wa
130
+ >>> wa.pull('wa.dev', 'wasi:io')
131
+ PackageDownload(namespace='wasi', name='io', version='0.2.0', content='...', digest='sha256:c33b1dbf050f64229ff4decbf9a3d3420e0643a86f5f0cea29f81054820020a6')
116
132
  ```
117
133
  However, the library interface is not yet standardised and may (and will!) change.
@@ -3,10 +3,10 @@
3
3
  **Interact with WebAssembly registries.**
4
4
 
5
5
  ## Features
6
- * Versatile use as a GitHub [action](https://github.com/marketplace/actions/wasm-action), CLI or Python [library](https://pypi.org/project/wasm-action/).
6
+ * Versatile use as GitHub [action](https://github.com/marketplace/actions/wasm-action), CLI or Python [library](https://pypi.org/project/wasm-action/).
7
7
  * Supported registry types: warg (wa.dev)
8
8
  * Supported artifact types: wasm
9
- * Supported actions: pull (public and private packages)
9
+ * Supported actions: push, pull
10
10
  * Supports Python 3.10+ on Linux, MacOS and Windows
11
11
 
12
12
  ## Usage
@@ -46,6 +46,19 @@ To pull a private package define your [token](https://wa.dev/account/credentials
46
46
  |filename|Download location|foo-bar_1.2.3.wasm|
47
47
  |digest|File hash|sha256:2afffac0...|
48
48
 
49
+ ### Push to registry
50
+ ```
51
+ - uses: xelato/wasm-action
52
+ with:
53
+ action: push
54
+ registry: wa.dev
55
+ package: foo:bar@1.2.3
56
+ path: files/foo_bar_1.2.3.wasm
57
+ env:
58
+ WARG_TOKEN: ${{ secrets.WARG_TOKEN }}
59
+ WARG_PRIVATE_KEY: ${{ secrets.WARG_PRIVATE_KEY }}
60
+ ```
61
+
49
62
  ## CLI
50
63
  The tool can be run without installing using [uv](https://docs.astral.sh/uv/).
51
64
  ```
@@ -95,6 +108,8 @@ The package is [published](http://pypi.org/project/wasm-action/) to the Python P
95
108
  $ pip install wasm-action
96
109
  ```
97
110
  ```
98
- > import wasm_action as wa
111
+ >>> import wasm_action as wa
112
+ >>> wa.pull('wa.dev', 'wasi:io')
113
+ PackageDownload(namespace='wasi', name='io', version='0.2.0', content='...', digest='sha256:c33b1dbf050f64229ff4decbf9a3d3420e0643a86f5f0cea29f81054820020a6')
99
114
  ```
100
115
  However, the library interface is not yet standardised and may (and will!) change.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "wasm-action"
3
- version = "0.0.2"
3
+ version = "0.0.4"
4
4
  description = "Interact with WebAssembly registries."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -17,8 +17,11 @@ dependencies = [
17
17
  "validators>=0.35.0",
18
18
  ]
19
19
 
20
+ [project.urls]
21
+ Repository = "https://github.com/xelato/wasm-action"
22
+
20
23
  [project.scripts]
21
- wasm-action = "wasm_action.action:main"
24
+ wasm-action = "wasm_action.cli:cli"
22
25
 
23
26
  [build-system]
24
27
  requires = ["uv_build>=0.9.3,<0.10.0"]
@@ -26,3 +29,9 @@ build-backend = "uv_build"
26
29
 
27
30
  [tool.uv.build-backend]
28
31
  module-name = ["wasm_action", "warg_openapi"]
32
+
33
+ [dependency-groups]
34
+ dev = [
35
+ "pytest>=9.0.2",
36
+ "vcrpy>=8.1.0",
37
+ ]
@@ -0,0 +1,217 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Warg Registry API
5
+
6
+ [warg](https://warg.io/) is an open source protocol for WebAssembly component registries.
7
+
8
+ The version of the OpenAPI document: 1.0.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ from inspect import getfullargspec
17
+ import json
18
+ import pprint
19
+ import re # noqa: F401
20
+
21
+ from typing import Any, List, Optional
22
+ from pydantic import BaseModel, Field, StrictStr, ValidationError, validator
23
+ from warg_openapi.models.processing_record import ProcessingRecord
24
+ from warg_openapi.models.published_record import PublishedRecord
25
+ from warg_openapi.models.rejected_record import RejectedRecord
26
+ from warg_openapi.models.sourcing_record import SourcingRecord
27
+ from typing import Union, Any, List, TYPE_CHECKING
28
+ from pydantic import StrictStr, Field
29
+
30
+ PACKAGERECORD_ONE_OF_SCHEMAS = ["ProcessingRecord", "PublishedRecord", "RejectedRecord", "SourcingRecord"]
31
+
32
+ class PackageRecord(BaseModel):
33
+ """
34
+ A package log record.
35
+ """
36
+ # data type: SourcingRecord
37
+ oneof_schema_1_validator: Optional[SourcingRecord] = None
38
+ # data type: ProcessingRecord
39
+ oneof_schema_2_validator: Optional[ProcessingRecord] = None
40
+ # data type: RejectedRecord
41
+ oneof_schema_3_validator: Optional[RejectedRecord] = None
42
+ # data type: PublishedRecord
43
+ oneof_schema_4_validator: Optional[PublishedRecord] = None
44
+ if TYPE_CHECKING:
45
+ actual_instance: Union[ProcessingRecord, PublishedRecord, RejectedRecord, SourcingRecord]
46
+ else:
47
+ actual_instance: Any
48
+ one_of_schemas: List[str] = Field(PACKAGERECORD_ONE_OF_SCHEMAS, const=True)
49
+
50
+ class Config:
51
+ validate_assignment = True
52
+
53
+ discriminator_value_class_map = {
54
+ }
55
+
56
+ def __init__(self, *args, **kwargs) -> None:
57
+ if args:
58
+ if len(args) > 1:
59
+ raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
60
+ if kwargs:
61
+ raise ValueError("If a position argument is used, keyword arguments cannot be used.")
62
+ super().__init__(actual_instance=args[0])
63
+ else:
64
+ super().__init__(**kwargs)
65
+
66
+ @validator('actual_instance')
67
+ def actual_instance_must_validate_oneof(cls, v):
68
+ instance = PackageRecord.construct()
69
+ error_messages = []
70
+ match = 0
71
+ # validate data type: SourcingRecord
72
+ if not isinstance(v, SourcingRecord):
73
+ error_messages.append(f"Error! Input type `{type(v)}` is not `SourcingRecord`")
74
+ else:
75
+ match += 1
76
+ # validate data type: ProcessingRecord
77
+ if not isinstance(v, ProcessingRecord):
78
+ error_messages.append(f"Error! Input type `{type(v)}` is not `ProcessingRecord`")
79
+ else:
80
+ match += 1
81
+ # validate data type: RejectedRecord
82
+ if not isinstance(v, RejectedRecord):
83
+ error_messages.append(f"Error! Input type `{type(v)}` is not `RejectedRecord`")
84
+ else:
85
+ match += 1
86
+ # validate data type: PublishedRecord
87
+ if not isinstance(v, PublishedRecord):
88
+ error_messages.append(f"Error! Input type `{type(v)}` is not `PublishedRecord`")
89
+ else:
90
+ match += 1
91
+ if match > 1:
92
+ # more than 1 match
93
+ raise ValueError("Multiple matches found when setting `actual_instance` in PackageRecord with oneOf schemas: ProcessingRecord, PublishedRecord, RejectedRecord, SourcingRecord. Details: " + ", ".join(error_messages))
94
+ elif match == 0:
95
+ # no match
96
+ raise ValueError("No match found when setting `actual_instance` in PackageRecord with oneOf schemas: ProcessingRecord, PublishedRecord, RejectedRecord, SourcingRecord. Details: " + ", ".join(error_messages))
97
+ else:
98
+ return v
99
+
100
+ @classmethod
101
+ def from_dict(cls, obj: dict) -> PackageRecord:
102
+ return cls.from_json(json.dumps(obj))
103
+
104
+ @classmethod
105
+ def from_json(cls, json_str: str) -> PackageRecord:
106
+ """Returns the object represented by the json string"""
107
+ instance = PackageRecord.construct()
108
+ error_messages = []
109
+ match = 0
110
+
111
+ # use oneOf discriminator to lookup the data type
112
+ _data_type = json.loads(json_str).get("state")
113
+ if not _data_type:
114
+ raise ValueError("Failed to lookup data type from the field `state` in the input.")
115
+
116
+ # check if data type is `ProcessingRecord`
117
+ if _data_type == "processing":
118
+ instance.actual_instance = ProcessingRecord.from_json(json_str)
119
+ return instance
120
+
121
+ # check if data type is `PublishedRecord`
122
+ if _data_type == "published":
123
+ instance.actual_instance = PublishedRecord.from_json(json_str)
124
+ return instance
125
+
126
+ # check if data type is `RejectedRecord`
127
+ if _data_type == "rejected":
128
+ instance.actual_instance = RejectedRecord.from_json(json_str)
129
+ return instance
130
+
131
+ # check if data type is `SourcingRecord`
132
+ if _data_type == "sourcing":
133
+ instance.actual_instance = SourcingRecord.from_json(json_str)
134
+ return instance
135
+
136
+ # check if data type is `ProcessingRecord`
137
+ if _data_type == "ProcessingRecord":
138
+ instance.actual_instance = ProcessingRecord.from_json(json_str)
139
+ return instance
140
+
141
+ # check if data type is `PublishedRecord`
142
+ if _data_type == "PublishedRecord":
143
+ instance.actual_instance = PublishedRecord.from_json(json_str)
144
+ return instance
145
+
146
+ # check if data type is `RejectedRecord`
147
+ if _data_type == "RejectedRecord":
148
+ instance.actual_instance = RejectedRecord.from_json(json_str)
149
+ return instance
150
+
151
+ # check if data type is `SourcingRecord`
152
+ if _data_type == "SourcingRecord":
153
+ instance.actual_instance = SourcingRecord.from_json(json_str)
154
+ return instance
155
+
156
+ # deserialize data into SourcingRecord
157
+ try:
158
+ instance.actual_instance = SourcingRecord.from_json(json_str)
159
+ match += 1
160
+ except (ValidationError, ValueError) as e:
161
+ error_messages.append(str(e))
162
+ # deserialize data into ProcessingRecord
163
+ try:
164
+ instance.actual_instance = ProcessingRecord.from_json(json_str)
165
+ match += 1
166
+ except (ValidationError, ValueError) as e:
167
+ error_messages.append(str(e))
168
+ # deserialize data into RejectedRecord
169
+ try:
170
+ instance.actual_instance = RejectedRecord.from_json(json_str)
171
+ match += 1
172
+ except (ValidationError, ValueError) as e:
173
+ error_messages.append(str(e))
174
+ # deserialize data into PublishedRecord
175
+ try:
176
+ instance.actual_instance = PublishedRecord.from_json(json_str)
177
+ match += 1
178
+ except (ValidationError, ValueError) as e:
179
+ error_messages.append(str(e))
180
+
181
+ if match > 1:
182
+ # more than 1 match
183
+ raise ValueError("Multiple matches found when deserializing the JSON string into PackageRecord with oneOf schemas: ProcessingRecord, PublishedRecord, RejectedRecord, SourcingRecord. Details: " + ", ".join(error_messages))
184
+ elif match == 0:
185
+ # no match
186
+ raise ValueError("No match found when deserializing the JSON string into PackageRecord with oneOf schemas: ProcessingRecord, PublishedRecord, RejectedRecord, SourcingRecord. Details: " + ", ".join(error_messages))
187
+ else:
188
+ return instance
189
+
190
+ def to_json(self) -> str:
191
+ """Returns the JSON representation of the actual instance"""
192
+ if self.actual_instance is None:
193
+ return "null"
194
+
195
+ to_json = getattr(self.actual_instance, "to_json", None)
196
+ if callable(to_json):
197
+ return self.actual_instance.to_json()
198
+ else:
199
+ return json.dumps(self.actual_instance)
200
+
201
+ def to_dict(self) -> dict:
202
+ """Returns the dict representation of the actual instance"""
203
+ if self.actual_instance is None:
204
+ return None
205
+
206
+ to_dict = getattr(self.actual_instance, "to_dict", None)
207
+ if callable(to_dict):
208
+ return self.actual_instance.to_dict()
209
+ else:
210
+ # primitive type
211
+ return self.actual_instance
212
+
213
+ def to_str(self) -> str:
214
+ """Returns the string representation of the actual instance"""
215
+ return pprint.pformat(self.dict())
216
+
217
+
@@ -19,14 +19,22 @@ import json
19
19
 
20
20
 
21
21
 
22
- from pydantic import BaseModel, Field, StrictStr, validator
22
+ from pydantic import BaseModel, Field, StrictStr, constr, validator
23
23
 
24
24
  class ProcessingRecord(BaseModel):
25
25
  """
26
26
  A record that is being processed. # noqa: E501
27
27
  """
28
+ record_id: constr(strict=True) = Field(default=..., alias="recordId", description="Represents a supported hash.")
28
29
  state: StrictStr = Field(default=..., description="The state of the package record.")
29
- __properties = ["state"]
30
+ __properties = ["recordId", "state"]
31
+
32
+ @validator('record_id')
33
+ def record_id_validate_regular_expression(cls, value):
34
+ """Validates the regular expression"""
35
+ if not re.match(r"^[a-z0-9-]+:[a-f0-9]+$", value):
36
+ raise ValueError(r"must validate the regular expression /^[a-z0-9-]+:[a-f0-9]+$/")
37
+ return value
30
38
 
31
39
  @validator('state')
32
40
  def state_validate_enum(cls, value):
@@ -71,6 +79,7 @@ class ProcessingRecord(BaseModel):
71
79
  return ProcessingRecord.parse_obj(obj)
72
80
 
73
81
  _obj = ProcessingRecord.parse_obj({
82
+ "record_id": obj.get("recordId"),
74
83
  "state": obj.get("state")
75
84
  })
76
85
  return _obj
@@ -100,6 +100,41 @@ class ProveInclusion422Response(BaseModel):
100
100
  error_messages = []
101
101
  match = 0
102
102
 
103
+ # use oneOf discriminator to lookup the data type
104
+ _data_type = json.loads(json_str).get("reason")
105
+ if not _data_type:
106
+ raise ValueError("Failed to lookup data type from the field `reason` in the input.")
107
+
108
+ # check if data type is `BundleFailureError`
109
+ if _data_type == "failure":
110
+ instance.actual_instance = BundleFailureError.from_json(json_str)
111
+ return instance
112
+
113
+ # check if data type is `IncorrectProofError`
114
+ if _data_type == "incorrectProof":
115
+ instance.actual_instance = IncorrectProofError.from_json(json_str)
116
+ return instance
117
+
118
+ # check if data type is `PackageNotIncludedError`
119
+ if _data_type == "packageNotIncluded":
120
+ instance.actual_instance = PackageNotIncludedError.from_json(json_str)
121
+ return instance
122
+
123
+ # check if data type is `BundleFailureError`
124
+ if _data_type == "BundleFailureError":
125
+ instance.actual_instance = BundleFailureError.from_json(json_str)
126
+ return instance
127
+
128
+ # check if data type is `IncorrectProofError`
129
+ if _data_type == "IncorrectProofError":
130
+ instance.actual_instance = IncorrectProofError.from_json(json_str)
131
+ return instance
132
+
133
+ # check if data type is `PackageNotIncludedError`
134
+ if _data_type == "PackageNotIncludedError":
135
+ instance.actual_instance = PackageNotIncludedError.from_json(json_str)
136
+ return instance
137
+
103
138
  # deserialize data into PackageNotIncludedError
104
139
  try:
105
140
  instance.actual_instance = PackageNotIncludedError.from_json(json_str)
@@ -19,15 +19,23 @@ import json
19
19
 
20
20
 
21
21
 
22
- from pydantic import BaseModel, Field, StrictInt, StrictStr, validator
22
+ from pydantic import BaseModel, Field, StrictInt, StrictStr, constr, validator
23
23
 
24
24
  class PublishedRecord(BaseModel):
25
25
  """
26
26
  A record that has been published to the log. # noqa: E501
27
27
  """
28
+ record_id: constr(strict=True) = Field(default=..., alias="recordId", description="Represents a supported hash.")
28
29
  state: StrictStr = Field(default=..., description="The state of the package record.")
29
30
  registry_index: StrictInt = Field(default=..., alias="registryIndex", description="The index of the record in the registry log.")
30
- __properties = ["state", "registryIndex"]
31
+ __properties = ["recordId", "state", "registryIndex"]
32
+
33
+ @validator('record_id')
34
+ def record_id_validate_regular_expression(cls, value):
35
+ """Validates the regular expression"""
36
+ if not re.match(r"^[a-z0-9-]+:[a-f0-9]+$", value):
37
+ raise ValueError(r"must validate the regular expression /^[a-z0-9-]+:[a-f0-9]+$/")
38
+ return value
31
39
 
32
40
  @validator('state')
33
41
  def state_validate_enum(cls, value):
@@ -72,6 +80,7 @@ class PublishedRecord(BaseModel):
72
80
  return PublishedRecord.parse_obj(obj)
73
81
 
74
82
  _obj = PublishedRecord.parse_obj({
83
+ "record_id": obj.get("recordId"),
75
84
  "state": obj.get("state"),
76
85
  "registry_index": obj.get("registryIndex")
77
86
  })
@@ -19,15 +19,23 @@ import json
19
19
 
20
20
 
21
21
 
22
- from pydantic import BaseModel, Field, StrictStr, validator
22
+ from pydantic import BaseModel, Field, StrictStr, constr, validator
23
23
 
24
24
  class RejectedRecord(BaseModel):
25
25
  """
26
26
  A rejected package record. # noqa: E501
27
27
  """
28
+ record_id: constr(strict=True) = Field(default=..., alias="recordId", description="Represents a supported hash.")
28
29
  state: StrictStr = Field(default=..., description="The state of the package record.")
29
30
  reason: StrictStr = Field(default=..., description="The reason the package record was rejected.")
30
- __properties = ["state", "reason"]
31
+ __properties = ["recordId", "state", "reason"]
32
+
33
+ @validator('record_id')
34
+ def record_id_validate_regular_expression(cls, value):
35
+ """Validates the regular expression"""
36
+ if not re.match(r"^[a-z0-9-]+:[a-f0-9]+$", value):
37
+ raise ValueError(r"must validate the regular expression /^[a-z0-9-]+:[a-f0-9]+$/")
38
+ return value
31
39
 
32
40
  @validator('state')
33
41
  def state_validate_enum(cls, value):
@@ -72,6 +80,7 @@ class RejectedRecord(BaseModel):
72
80
  return RejectedRecord.parse_obj(obj)
73
81
 
74
82
  _obj = RejectedRecord.parse_obj({
83
+ "record_id": obj.get("recordId"),
75
84
  "state": obj.get("state"),
76
85
  "reason": obj.get("reason")
77
86
  })
@@ -19,15 +19,23 @@ import json
19
19
 
20
20
 
21
21
  from typing import Any, Dict
22
- from pydantic import BaseModel, Field, StrictStr, validator
22
+ from pydantic import BaseModel, Field, StrictStr, constr, validator
23
23
 
24
24
  class SourcingRecord(BaseModel):
25
25
  """
26
26
  The package record is sourcing content. # noqa: E501
27
27
  """
28
+ record_id: constr(strict=True) = Field(default=..., alias="recordId", description="Represents a supported hash.")
28
29
  state: StrictStr = Field(default=..., description="The state of the package record.")
29
30
  missing_content: Dict[str, Any] = Field(default=..., alias="missingContent", description="The map of content digest to missing content info.")
30
- __properties = ["state", "missingContent"]
31
+ __properties = ["recordId", "state", "missingContent"]
32
+
33
+ @validator('record_id')
34
+ def record_id_validate_regular_expression(cls, value):
35
+ """Validates the regular expression"""
36
+ if not re.match(r"^[a-z0-9-]+:[a-f0-9]+$", value):
37
+ raise ValueError(r"must validate the regular expression /^[a-z0-9-]+:[a-f0-9]+$/")
38
+ return value
31
39
 
32
40
  @validator('state')
33
41
  def state_validate_enum(cls, value):
@@ -72,6 +80,7 @@ class SourcingRecord(BaseModel):
72
80
  return SourcingRecord.parse_obj(obj)
73
81
 
74
82
  _obj = SourcingRecord.parse_obj({
83
+ "record_id": obj.get("recordId"),
75
84
  "state": obj.get("state"),
76
85
  "missing_content": obj.get("missingContent")
77
86
  })
@@ -0,0 +1,9 @@
1
+
2
+ import importlib.metadata
3
+
4
+ try:
5
+ __version__ = importlib.metadata.version("wasm-action")
6
+ except importlib.metadata.PackageNotFoundError:
7
+ __version__ = "0.0.0"
8
+
9
+ from .lib import push, pull
@@ -0,0 +1,68 @@
1
+ import sys
2
+ import click
3
+ import importlib.metadata
4
+
5
+ from . import lib
6
+
7
+ @click.group()
8
+ def cli():
9
+ pass
10
+
11
+
12
+ @cli.command(help="Print version")
13
+ def version():
14
+ try:
15
+ version = importlib.metadata.version("wasm-action")
16
+ except importlib.metadata.PackageNotFoundError:
17
+ version = "0.0.0"
18
+ print(version)
19
+
20
+
21
+ @cli.command(help="Push to registry")
22
+ @click.option('--registry', required=True, help="registry domain name")
23
+ @click.option('--package', required=True, help="package spec")
24
+ @click.option('--path', required=True, help="filename")
25
+ @click.option('--warg-token', required=False, envvar='WARG_TOKEN', help="warg token (or $WARG_TOKEN)")
26
+ @click.option('--warg-private-key', required=False, envvar='WARG_PRIVATE_KEY', help="warg private key (or $WARG_PRIVATE_KEY)")
27
+ def push(registry, package, path, warg_token, warg_private_key):
28
+
29
+ try:
30
+
31
+ lib.push_file(
32
+ registry=registry,
33
+ package=package,
34
+ path=path,
35
+ warg_token=warg_token,
36
+ warg_private_key=warg_private_key,
37
+ cli=True,
38
+ )
39
+
40
+ except Exception as e:
41
+ print(e)
42
+ sys.exit(1)
43
+
44
+
45
+ @cli.command(help="Pull from registry")
46
+ @click.option('--registry', required=True, help="registry domain name")
47
+ @click.option('--package', required=True, help="package spec")
48
+ @click.option('--path', required=False, help="filename")
49
+ @click.option('--warg-token', required=False, envvar='WARG_TOKEN', help="warg token (or $WARG_TOKEN)")
50
+ def pull(registry, package, path=None, warg_token=None):
51
+
52
+ try:
53
+
54
+ lib.pull_file(
55
+ registry=registry,
56
+ package=package,
57
+ path=path,
58
+ warg_token=warg_token,
59
+ cli=True,
60
+ )
61
+
62
+ except Exception as e:
63
+ print(e)
64
+ sys.exit(1)
65
+
66
+
67
+ if __name__ == "__main__":
68
+ cli()