crc-pulp-npm-client 20250819.1__py3-none-any.whl → 20250821.1__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.

Potentially problematic release.


This version of crc-pulp-npm-client might be problematic. Click here for more details.

Files changed (49) hide show
  1. crc-pulp_npm-client/api_client.py +1 -1
  2. crc-pulp_npm-client/configuration.py +3 -3
  3. {crc_pulp_npm_client-20250819.1.dist-info → crc_pulp_npm_client-20250821.1.dist-info}/METADATA +1 -1
  4. crc_pulp_npm_client-20250821.1.dist-info/RECORD +45 -0
  5. crc_pulp_npm_client-20250821.1.dist-info/top_level.txt +1 -0
  6. crc_pulp_npm_client-20250819.1.dist-info/RECORD +0 -86
  7. crc_pulp_npm_client-20250819.1.dist-info/top_level.txt +0 -2
  8. services-pulp_npm-client/__init__.py +0 -2
  9. services-pulp_npm-client/api/__init__.py +0 -9
  10. services-pulp_npm-client/api/content_packages_api.py +0 -1964
  11. services-pulp_npm-client/api/distributions_npm_api.py +0 -2934
  12. services-pulp_npm-client/api/remotes_npm_api.py +0 -2962
  13. services-pulp_npm-client/api/repositories_npm_api.py +0 -3604
  14. services-pulp_npm-client/api/repositories_npm_versions_api.py +0 -1670
  15. services-pulp_npm-client/api_client.py +0 -798
  16. services-pulp_npm-client/api_response.py +0 -21
  17. services-pulp_npm-client/configuration.py +0 -628
  18. services-pulp_npm-client/exceptions.py +0 -200
  19. services-pulp_npm-client/models/__init__.py +0 -44
  20. services-pulp_npm-client/models/async_operation_response.py +0 -88
  21. services-pulp_npm-client/models/content_summary_response.py +0 -92
  22. services-pulp_npm-client/models/npm_npm_distribution.py +0 -116
  23. services-pulp_npm-client/models/npm_npm_distribution_response.py +0 -140
  24. services-pulp_npm-client/models/npm_npm_remote.py +0 -205
  25. services-pulp_npm-client/models/npm_npm_remote_response.py +0 -199
  26. services-pulp_npm-client/models/npm_npm_remote_response_hidden_fields_inner.py +0 -90
  27. services-pulp_npm-client/models/npm_npm_repository.py +0 -112
  28. services-pulp_npm-client/models/npm_npm_repository_response.py +0 -137
  29. services-pulp_npm-client/models/npm_package_response.py +0 -113
  30. services-pulp_npm-client/models/paginated_repository_version_response_list.py +0 -112
  31. services-pulp_npm-client/models/paginatednpm_npm_distribution_response_list.py +0 -112
  32. services-pulp_npm-client/models/paginatednpm_npm_remote_response_list.py +0 -112
  33. services-pulp_npm-client/models/paginatednpm_npm_repository_response_list.py +0 -112
  34. services-pulp_npm-client/models/paginatednpm_package_response_list.py +0 -112
  35. services-pulp_npm-client/models/patchednpm_npm_distribution.py +0 -116
  36. services-pulp_npm-client/models/patchednpm_npm_remote.py +0 -205
  37. services-pulp_npm-client/models/patchednpm_npm_repository.py +0 -112
  38. services-pulp_npm-client/models/policy_enum.py +0 -39
  39. services-pulp_npm-client/models/repair.py +0 -88
  40. services-pulp_npm-client/models/repository_add_remove_content.py +0 -93
  41. services-pulp_npm-client/models/repository_sync_url.py +0 -90
  42. services-pulp_npm-client/models/repository_version_response.py +0 -121
  43. services-pulp_npm-client/models/set_label.py +0 -103
  44. services-pulp_npm-client/models/set_label_response.py +0 -103
  45. services-pulp_npm-client/models/unset_label.py +0 -96
  46. services-pulp_npm-client/models/unset_label_response.py +0 -100
  47. services-pulp_npm-client/py.typed +0 -0
  48. services-pulp_npm-client/rest.py +0 -258
  49. {crc_pulp_npm_client-20250819.1.dist-info → crc_pulp_npm_client-20250821.1.dist-info}/WHEEL +0 -0
@@ -1,200 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Pulp 3 API
5
-
6
- Fetch, Upload, Organize, and Distribute Software Packages
7
-
8
- The version of the OpenAPI document: v3
9
- Contact: pulp-list@redhat.com
10
- Generated by OpenAPI Generator (https://openapi-generator.tech)
11
-
12
- Do not edit the class manually.
13
- """ # noqa: E501
14
-
15
- from typing import Any, Optional
16
- from typing_extensions import Self
17
-
18
- class OpenApiException(Exception):
19
- """The base exception class for all OpenAPIExceptions"""
20
-
21
-
22
- class ApiTypeError(OpenApiException, TypeError):
23
- def __init__(self, msg, path_to_item=None, valid_classes=None,
24
- key_type=None) -> None:
25
- """ Raises an exception for TypeErrors
26
-
27
- Args:
28
- msg (str): the exception message
29
-
30
- Keyword Args:
31
- path_to_item (list): a list of keys an indices to get to the
32
- current_item
33
- None if unset
34
- valid_classes (tuple): the primitive classes that current item
35
- should be an instance of
36
- None if unset
37
- key_type (bool): False if our value is a value in a dict
38
- True if it is a key in a dict
39
- False if our item is an item in a list
40
- None if unset
41
- """
42
- self.path_to_item = path_to_item
43
- self.valid_classes = valid_classes
44
- self.key_type = key_type
45
- full_msg = msg
46
- if path_to_item:
47
- full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
48
- super(ApiTypeError, self).__init__(full_msg)
49
-
50
-
51
- class ApiValueError(OpenApiException, ValueError):
52
- def __init__(self, msg, path_to_item=None) -> None:
53
- """
54
- Args:
55
- msg (str): the exception message
56
-
57
- Keyword Args:
58
- path_to_item (list) the path to the exception in the
59
- received_data dict. None if unset
60
- """
61
-
62
- self.path_to_item = path_to_item
63
- full_msg = msg
64
- if path_to_item:
65
- full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
66
- super(ApiValueError, self).__init__(full_msg)
67
-
68
-
69
- class ApiAttributeError(OpenApiException, AttributeError):
70
- def __init__(self, msg, path_to_item=None) -> None:
71
- """
72
- Raised when an attribute reference or assignment fails.
73
-
74
- Args:
75
- msg (str): the exception message
76
-
77
- Keyword Args:
78
- path_to_item (None/list) the path to the exception in the
79
- received_data dict
80
- """
81
- self.path_to_item = path_to_item
82
- full_msg = msg
83
- if path_to_item:
84
- full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
85
- super(ApiAttributeError, self).__init__(full_msg)
86
-
87
-
88
- class ApiKeyError(OpenApiException, KeyError):
89
- def __init__(self, msg, path_to_item=None) -> None:
90
- """
91
- Args:
92
- msg (str): the exception message
93
-
94
- Keyword Args:
95
- path_to_item (None/list) the path to the exception in the
96
- received_data dict
97
- """
98
- self.path_to_item = path_to_item
99
- full_msg = msg
100
- if path_to_item:
101
- full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
102
- super(ApiKeyError, self).__init__(full_msg)
103
-
104
-
105
- class ApiException(OpenApiException):
106
-
107
- def __init__(
108
- self,
109
- status=None,
110
- reason=None,
111
- http_resp=None,
112
- *,
113
- body: Optional[str] = None,
114
- data: Optional[Any] = None,
115
- ) -> None:
116
- self.status = status
117
- self.reason = reason
118
- self.body = body
119
- self.data = data
120
- self.headers = None
121
-
122
- if http_resp:
123
- if self.status is None:
124
- self.status = http_resp.status
125
- if self.reason is None:
126
- self.reason = http_resp.reason
127
- if self.body is None:
128
- try:
129
- self.body = http_resp.data.decode('utf-8')
130
- except Exception:
131
- pass
132
- self.headers = http_resp.getheaders()
133
-
134
- @classmethod
135
- def from_response(
136
- cls,
137
- *,
138
- http_resp,
139
- body: Optional[str],
140
- data: Optional[Any],
141
- ) -> Self:
142
- if http_resp.status == 400:
143
- raise BadRequestException(http_resp=http_resp, body=body, data=data)
144
-
145
- if http_resp.status == 401:
146
- raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
147
-
148
- if http_resp.status == 403:
149
- raise ForbiddenException(http_resp=http_resp, body=body, data=data)
150
-
151
- if http_resp.status == 404:
152
- raise NotFoundException(http_resp=http_resp, body=body, data=data)
153
-
154
- if 500 <= http_resp.status <= 599:
155
- raise ServiceException(http_resp=http_resp, body=body, data=data)
156
- raise ApiException(http_resp=http_resp, body=body, data=data)
157
-
158
- def __str__(self):
159
- """Custom error messages for exception"""
160
- error_message = "({0})\n"\
161
- "Reason: {1}\n".format(self.status, self.reason)
162
- if self.headers:
163
- error_message += "HTTP response headers: {0}\n".format(
164
- self.headers)
165
-
166
- if self.data or self.body:
167
- error_message += "HTTP response body: {0}\n".format(self.data or self.body)
168
-
169
- return error_message
170
-
171
-
172
- class BadRequestException(ApiException):
173
- pass
174
-
175
-
176
- class NotFoundException(ApiException):
177
- pass
178
-
179
-
180
- class UnauthorizedException(ApiException):
181
- pass
182
-
183
-
184
- class ForbiddenException(ApiException):
185
- pass
186
-
187
-
188
- class ServiceException(ApiException):
189
- pass
190
-
191
-
192
- def render_path(path_to_item):
193
- """Returns a string representation of a path"""
194
- result = ""
195
- for pth in path_to_item:
196
- if isinstance(pth, int):
197
- result += "[{0}]".format(pth)
198
- else:
199
- result += "['{0}']".format(pth)
200
- return result
@@ -1,44 +0,0 @@
1
- # coding: utf-8
2
-
3
- # flake8: noqa
4
- """
5
- Pulp 3 API
6
-
7
- Fetch, Upload, Organize, and Distribute Software Packages
8
-
9
- The version of the OpenAPI document: v3
10
- Contact: pulp-list@redhat.com
11
- Generated by OpenAPI Generator (https://openapi-generator.tech)
12
-
13
- Do not edit the class manually.
14
- """ # noqa: E501
15
-
16
-
17
- # import models into model package
18
- from services-pulp_npm-client.models.async_operation_response import AsyncOperationResponse
19
- from services-pulp_npm-client.models.content_summary_response import ContentSummaryResponse
20
- from services-pulp_npm-client.models.npm_npm_distribution import NpmNpmDistribution
21
- from services-pulp_npm-client.models.npm_npm_distribution_response import NpmNpmDistributionResponse
22
- from services-pulp_npm-client.models.npm_npm_remote import NpmNpmRemote
23
- from services-pulp_npm-client.models.npm_npm_remote_response import NpmNpmRemoteResponse
24
- from services-pulp_npm-client.models.npm_npm_remote_response_hidden_fields_inner import NpmNpmRemoteResponseHiddenFieldsInner
25
- from services-pulp_npm-client.models.npm_npm_repository import NpmNpmRepository
26
- from services-pulp_npm-client.models.npm_npm_repository_response import NpmNpmRepositoryResponse
27
- from services-pulp_npm-client.models.npm_package_response import NpmPackageResponse
28
- from services-pulp_npm-client.models.paginated_repository_version_response_list import PaginatedRepositoryVersionResponseList
29
- from services-pulp_npm-client.models.paginatednpm_npm_distribution_response_list import PaginatednpmNpmDistributionResponseList
30
- from services-pulp_npm-client.models.paginatednpm_npm_remote_response_list import PaginatednpmNpmRemoteResponseList
31
- from services-pulp_npm-client.models.paginatednpm_npm_repository_response_list import PaginatednpmNpmRepositoryResponseList
32
- from services-pulp_npm-client.models.paginatednpm_package_response_list import PaginatednpmPackageResponseList
33
- from services-pulp_npm-client.models.patchednpm_npm_distribution import PatchednpmNpmDistribution
34
- from services-pulp_npm-client.models.patchednpm_npm_remote import PatchednpmNpmRemote
35
- from services-pulp_npm-client.models.patchednpm_npm_repository import PatchednpmNpmRepository
36
- from services-pulp_npm-client.models.policy_enum import PolicyEnum
37
- from services-pulp_npm-client.models.repair import Repair
38
- from services-pulp_npm-client.models.repository_add_remove_content import RepositoryAddRemoveContent
39
- from services-pulp_npm-client.models.repository_sync_url import RepositorySyncURL
40
- from services-pulp_npm-client.models.repository_version_response import RepositoryVersionResponse
41
- from services-pulp_npm-client.models.set_label import SetLabel
42
- from services-pulp_npm-client.models.set_label_response import SetLabelResponse
43
- from services-pulp_npm-client.models.unset_label import UnsetLabel
44
- from services-pulp_npm-client.models.unset_label_response import UnsetLabelResponse
@@ -1,88 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Pulp 3 API
5
-
6
- Fetch, Upload, Organize, and Distribute Software Packages
7
-
8
- The version of the OpenAPI document: v3
9
- Contact: pulp-list@redhat.com
10
- Generated by OpenAPI Generator (https://openapi-generator.tech)
11
-
12
- Do not edit the class manually.
13
- """ # noqa: E501
14
-
15
-
16
- from __future__ import annotations
17
- import pprint
18
- import re # noqa: F401
19
- import json
20
-
21
- from pydantic import BaseModel, ConfigDict, Field, StrictStr
22
- from typing import Any, ClassVar, Dict, List
23
- from typing import Optional, Set
24
- from typing_extensions import Self
25
-
26
- class AsyncOperationResponse(BaseModel):
27
- """
28
- Serializer for asynchronous operations.
29
- """ # noqa: E501
30
- task: StrictStr = Field(description="The href of the task.")
31
- __properties: ClassVar[List[str]] = ["task"]
32
-
33
- model_config = ConfigDict(
34
- populate_by_name=True,
35
- validate_assignment=True,
36
- protected_namespaces=(),
37
- )
38
-
39
-
40
- def to_str(self) -> str:
41
- """Returns the string representation of the model using alias"""
42
- return pprint.pformat(self.model_dump(by_alias=True))
43
-
44
- def to_json(self) -> str:
45
- """Returns the JSON representation of the model using alias"""
46
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
47
- return json.dumps(self.to_dict())
48
-
49
- @classmethod
50
- def from_json(cls, json_str: str) -> Optional[Self]:
51
- """Create an instance of AsyncOperationResponse from a JSON string"""
52
- return cls.from_dict(json.loads(json_str))
53
-
54
- def to_dict(self) -> Dict[str, Any]:
55
- """Return the dictionary representation of the model using alias.
56
-
57
- This has the following differences from calling pydantic's
58
- `self.model_dump(by_alias=True)`:
59
-
60
- * `None` is only added to the output dict for nullable fields that
61
- were set at model initialization. Other fields with value `None`
62
- are ignored.
63
- """
64
- excluded_fields: Set[str] = set([
65
- ])
66
-
67
- _dict = self.model_dump(
68
- by_alias=True,
69
- exclude=excluded_fields,
70
- exclude_none=True,
71
- )
72
- return _dict
73
-
74
- @classmethod
75
- def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
76
- """Create an instance of AsyncOperationResponse from a dict"""
77
- if obj is None:
78
- return None
79
-
80
- if not isinstance(obj, dict):
81
- return cls.model_validate(obj)
82
-
83
- _obj = cls.model_validate({
84
- "task": obj.get("task")
85
- })
86
- return _obj
87
-
88
-
@@ -1,92 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Pulp 3 API
5
-
6
- Fetch, Upload, Organize, and Distribute Software Packages
7
-
8
- The version of the OpenAPI document: v3
9
- Contact: pulp-list@redhat.com
10
- Generated by OpenAPI Generator (https://openapi-generator.tech)
11
-
12
- Do not edit the class manually.
13
- """ # noqa: E501
14
-
15
-
16
- from __future__ import annotations
17
- import pprint
18
- import re # noqa: F401
19
- import json
20
-
21
- from pydantic import BaseModel, ConfigDict
22
- from typing import Any, ClassVar, Dict, List
23
- from typing import Optional, Set
24
- from typing_extensions import Self
25
-
26
- class ContentSummaryResponse(BaseModel):
27
- """
28
- Serializer for the RepositoryVersion content summary
29
- """ # noqa: E501
30
- added: Dict[str, Dict[str, Any]]
31
- removed: Dict[str, Dict[str, Any]]
32
- present: Dict[str, Dict[str, Any]]
33
- __properties: ClassVar[List[str]] = ["added", "removed", "present"]
34
-
35
- model_config = ConfigDict(
36
- populate_by_name=True,
37
- validate_assignment=True,
38
- protected_namespaces=(),
39
- )
40
-
41
-
42
- def to_str(self) -> str:
43
- """Returns the string representation of the model using alias"""
44
- return pprint.pformat(self.model_dump(by_alias=True))
45
-
46
- def to_json(self) -> str:
47
- """Returns the JSON representation of the model using alias"""
48
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
49
- return json.dumps(self.to_dict())
50
-
51
- @classmethod
52
- def from_json(cls, json_str: str) -> Optional[Self]:
53
- """Create an instance of ContentSummaryResponse from a JSON string"""
54
- return cls.from_dict(json.loads(json_str))
55
-
56
- def to_dict(self) -> Dict[str, Any]:
57
- """Return the dictionary representation of the model using alias.
58
-
59
- This has the following differences from calling pydantic's
60
- `self.model_dump(by_alias=True)`:
61
-
62
- * `None` is only added to the output dict for nullable fields that
63
- were set at model initialization. Other fields with value `None`
64
- are ignored.
65
- """
66
- excluded_fields: Set[str] = set([
67
- ])
68
-
69
- _dict = self.model_dump(
70
- by_alias=True,
71
- exclude=excluded_fields,
72
- exclude_none=True,
73
- )
74
- return _dict
75
-
76
- @classmethod
77
- def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
78
- """Create an instance of ContentSummaryResponse from a dict"""
79
- if obj is None:
80
- return None
81
-
82
- if not isinstance(obj, dict):
83
- return cls.model_validate(obj)
84
-
85
- _obj = cls.model_validate({
86
- "added": obj.get("added"),
87
- "removed": obj.get("removed"),
88
- "present": obj.get("present")
89
- })
90
- return _obj
91
-
92
-
@@ -1,116 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Pulp 3 API
5
-
6
- Fetch, Upload, Organize, and Distribute Software Packages
7
-
8
- The version of the OpenAPI document: v3
9
- Contact: pulp-list@redhat.com
10
- Generated by OpenAPI Generator (https://openapi-generator.tech)
11
-
12
- Do not edit the class manually.
13
- """ # noqa: E501
14
-
15
-
16
- from __future__ import annotations
17
- import pprint
18
- import re # noqa: F401
19
- import json
20
-
21
- from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
22
- from typing import Any, ClassVar, Dict, List, Optional
23
- from typing_extensions import Annotated
24
- from typing import Optional, Set
25
- from typing_extensions import Self
26
-
27
- class NpmNpmDistribution(BaseModel):
28
- """
29
- Serializer for NPM Distributions.
30
- """ # noqa: E501
31
- base_path: Annotated[str, Field(min_length=1, strict=True)] = Field(description="The base (relative) path component of the published url. Avoid paths that overlap with other distribution base paths (e.g. \"foo\" and \"foo/bar\")")
32
- content_guard: Optional[StrictStr] = Field(default=None, description="An optional content-guard.")
33
- hidden: Optional[StrictBool] = Field(default=False, description="Whether this distribution should be shown in the content app.")
34
- pulp_labels: Optional[Dict[str, Optional[StrictStr]]] = None
35
- name: Annotated[str, Field(min_length=1, strict=True)] = Field(description="A unique name. Ex, `rawhide` and `stable`.")
36
- repository: Optional[StrictStr] = Field(default=None, description="The latest RepositoryVersion for this Repository will be served.")
37
- remote: Optional[StrictStr] = Field(default=None, description="Remote that can be used to fetch content when using pull-through caching.")
38
- __properties: ClassVar[List[str]] = ["base_path", "content_guard", "hidden", "pulp_labels", "name", "repository", "remote"]
39
-
40
- model_config = ConfigDict(
41
- populate_by_name=True,
42
- validate_assignment=True,
43
- protected_namespaces=(),
44
- )
45
-
46
-
47
- def to_str(self) -> str:
48
- """Returns the string representation of the model using alias"""
49
- return pprint.pformat(self.model_dump(by_alias=True))
50
-
51
- def to_json(self) -> str:
52
- """Returns the JSON representation of the model using alias"""
53
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
54
- return json.dumps(self.to_dict())
55
-
56
- @classmethod
57
- def from_json(cls, json_str: str) -> Optional[Self]:
58
- """Create an instance of NpmNpmDistribution from a JSON string"""
59
- return cls.from_dict(json.loads(json_str))
60
-
61
- def to_dict(self) -> Dict[str, Any]:
62
- """Return the dictionary representation of the model using alias.
63
-
64
- This has the following differences from calling pydantic's
65
- `self.model_dump(by_alias=True)`:
66
-
67
- * `None` is only added to the output dict for nullable fields that
68
- were set at model initialization. Other fields with value `None`
69
- are ignored.
70
- """
71
- excluded_fields: Set[str] = set([
72
- ])
73
-
74
- _dict = self.model_dump(
75
- by_alias=True,
76
- exclude=excluded_fields,
77
- exclude_none=True,
78
- )
79
- # set to None if content_guard (nullable) is None
80
- # and model_fields_set contains the field
81
- if self.content_guard is None and "content_guard" in self.model_fields_set:
82
- _dict['content_guard'] = None
83
-
84
- # set to None if repository (nullable) is None
85
- # and model_fields_set contains the field
86
- if self.repository is None and "repository" in self.model_fields_set:
87
- _dict['repository'] = None
88
-
89
- # set to None if remote (nullable) is None
90
- # and model_fields_set contains the field
91
- if self.remote is None and "remote" in self.model_fields_set:
92
- _dict['remote'] = None
93
-
94
- return _dict
95
-
96
- @classmethod
97
- def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
98
- """Create an instance of NpmNpmDistribution from a dict"""
99
- if obj is None:
100
- return None
101
-
102
- if not isinstance(obj, dict):
103
- return cls.model_validate(obj)
104
-
105
- _obj = cls.model_validate({
106
- "base_path": obj.get("base_path"),
107
- "content_guard": obj.get("content_guard"),
108
- "hidden": obj.get("hidden") if obj.get("hidden") is not None else False,
109
- "pulp_labels": obj.get("pulp_labels"),
110
- "name": obj.get("name"),
111
- "repository": obj.get("repository"),
112
- "remote": obj.get("remote")
113
- })
114
- return _obj
115
-
116
-
@@ -1,140 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Pulp 3 API
5
-
6
- Fetch, Upload, Organize, and Distribute Software Packages
7
-
8
- The version of the OpenAPI document: v3
9
- Contact: pulp-list@redhat.com
10
- Generated by OpenAPI Generator (https://openapi-generator.tech)
11
-
12
- Do not edit the class manually.
13
- """ # noqa: E501
14
-
15
-
16
- from __future__ import annotations
17
- import pprint
18
- import re # noqa: F401
19
- import json
20
-
21
- from datetime import datetime
22
- from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
23
- from typing import Any, ClassVar, Dict, List, Optional
24
- from typing import Optional, Set
25
- from typing_extensions import Self
26
-
27
- class NpmNpmDistributionResponse(BaseModel):
28
- """
29
- Serializer for NPM Distributions.
30
- """ # noqa: E501
31
- pulp_href: Optional[StrictStr] = None
32
- prn: Optional[StrictStr] = Field(default=None, description="The Pulp Resource Name (PRN).")
33
- pulp_created: Optional[datetime] = Field(default=None, description="Timestamp of creation.")
34
- pulp_last_updated: Optional[datetime] = Field(default=None, description="Timestamp of the last time this resource was updated. Note: for immutable resources - like content, repository versions, and publication - pulp_created and pulp_last_updated dates will be the same.")
35
- base_path: StrictStr = Field(description="The base (relative) path component of the published url. Avoid paths that overlap with other distribution base paths (e.g. \"foo\" and \"foo/bar\")")
36
- base_url: Optional[StrictStr] = Field(default=None, description="The URL for accessing the publication as defined by this distribution.")
37
- content_guard: Optional[StrictStr] = Field(default=None, description="An optional content-guard.")
38
- no_content_change_since: Optional[StrictStr] = Field(default=None, description="Timestamp since when the distributed content served by this distribution has not changed. If equals to `null`, no guarantee is provided about content changes.")
39
- hidden: Optional[StrictBool] = Field(default=False, description="Whether this distribution should be shown in the content app.")
40
- pulp_labels: Optional[Dict[str, Optional[StrictStr]]] = None
41
- name: StrictStr = Field(description="A unique name. Ex, `rawhide` and `stable`.")
42
- repository: Optional[StrictStr] = Field(default=None, description="The latest RepositoryVersion for this Repository will be served.")
43
- remote: Optional[StrictStr] = Field(default=None, description="Remote that can be used to fetch content when using pull-through caching.")
44
- __properties: ClassVar[List[str]] = ["pulp_href", "prn", "pulp_created", "pulp_last_updated", "base_path", "base_url", "content_guard", "no_content_change_since", "hidden", "pulp_labels", "name", "repository", "remote"]
45
-
46
- model_config = ConfigDict(
47
- populate_by_name=True,
48
- validate_assignment=True,
49
- protected_namespaces=(),
50
- )
51
-
52
-
53
- def to_str(self) -> str:
54
- """Returns the string representation of the model using alias"""
55
- return pprint.pformat(self.model_dump(by_alias=True))
56
-
57
- def to_json(self) -> str:
58
- """Returns the JSON representation of the model using alias"""
59
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
60
- return json.dumps(self.to_dict())
61
-
62
- @classmethod
63
- def from_json(cls, json_str: str) -> Optional[Self]:
64
- """Create an instance of NpmNpmDistributionResponse from a JSON string"""
65
- return cls.from_dict(json.loads(json_str))
66
-
67
- def to_dict(self) -> Dict[str, Any]:
68
- """Return the dictionary representation of the model using alias.
69
-
70
- This has the following differences from calling pydantic's
71
- `self.model_dump(by_alias=True)`:
72
-
73
- * `None` is only added to the output dict for nullable fields that
74
- were set at model initialization. Other fields with value `None`
75
- are ignored.
76
- * OpenAPI `readOnly` fields are excluded.
77
- * OpenAPI `readOnly` fields are excluded.
78
- * OpenAPI `readOnly` fields are excluded.
79
- * OpenAPI `readOnly` fields are excluded.
80
- * OpenAPI `readOnly` fields are excluded.
81
- * OpenAPI `readOnly` fields are excluded.
82
- """
83
- excluded_fields: Set[str] = set([
84
- "pulp_href",
85
- "prn",
86
- "pulp_created",
87
- "pulp_last_updated",
88
- "base_url",
89
- "no_content_change_since",
90
- ])
91
-
92
- _dict = self.model_dump(
93
- by_alias=True,
94
- exclude=excluded_fields,
95
- exclude_none=True,
96
- )
97
- # set to None if content_guard (nullable) is None
98
- # and model_fields_set contains the field
99
- if self.content_guard is None and "content_guard" in self.model_fields_set:
100
- _dict['content_guard'] = None
101
-
102
- # set to None if repository (nullable) is None
103
- # and model_fields_set contains the field
104
- if self.repository is None and "repository" in self.model_fields_set:
105
- _dict['repository'] = None
106
-
107
- # set to None if remote (nullable) is None
108
- # and model_fields_set contains the field
109
- if self.remote is None and "remote" in self.model_fields_set:
110
- _dict['remote'] = None
111
-
112
- return _dict
113
-
114
- @classmethod
115
- def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
116
- """Create an instance of NpmNpmDistributionResponse from a dict"""
117
- if obj is None:
118
- return None
119
-
120
- if not isinstance(obj, dict):
121
- return cls.model_validate(obj)
122
-
123
- _obj = cls.model_validate({
124
- "pulp_href": obj.get("pulp_href"),
125
- "prn": obj.get("prn"),
126
- "pulp_created": obj.get("pulp_created"),
127
- "pulp_last_updated": obj.get("pulp_last_updated"),
128
- "base_path": obj.get("base_path"),
129
- "base_url": obj.get("base_url"),
130
- "content_guard": obj.get("content_guard"),
131
- "no_content_change_since": obj.get("no_content_change_since"),
132
- "hidden": obj.get("hidden") if obj.get("hidden") is not None else False,
133
- "pulp_labels": obj.get("pulp_labels"),
134
- "name": obj.get("name"),
135
- "repository": obj.get("repository"),
136
- "remote": obj.get("remote")
137
- })
138
- return _obj
139
-
140
-