stackit-stackitmarketplace 0.1.0__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.
Files changed (31) hide show
  1. stackit/stackitmarketplace/__init__.py +84 -0
  2. stackit/stackitmarketplace/api/__init__.py +4 -0
  3. stackit/stackitmarketplace/api/default_api.py +1719 -0
  4. stackit/stackitmarketplace/api_client.py +627 -0
  5. stackit/stackitmarketplace/api_response.py +23 -0
  6. stackit/stackitmarketplace/configuration.py +138 -0
  7. stackit/stackitmarketplace/exceptions.py +199 -0
  8. stackit/stackitmarketplace/models/__init__.py +65 -0
  9. stackit/stackitmarketplace/models/catalog_pricing_option_highlight.py +84 -0
  10. stackit/stackitmarketplace/models/catalog_product_detail.py +246 -0
  11. stackit/stackitmarketplace/models/catalog_product_details_vendor.py +96 -0
  12. stackit/stackitmarketplace/models/catalog_product_highlight.py +94 -0
  13. stackit/stackitmarketplace/models/catalog_product_overview.py +132 -0
  14. stackit/stackitmarketplace/models/catalog_product_overview_vendor.py +86 -0
  15. stackit/stackitmarketplace/models/catalog_product_pricing_option.py +146 -0
  16. stackit/stackitmarketplace/models/catalog_product_support_resource.py +89 -0
  17. stackit/stackitmarketplace/models/catalog_product_vendor_terms.py +86 -0
  18. stackit/stackitmarketplace/models/current_subscription_state_response.py +103 -0
  19. stackit/stackitmarketplace/models/error_response.py +95 -0
  20. stackit/stackitmarketplace/models/list_catalog_products_response.py +109 -0
  21. stackit/stackitmarketplace/models/list_vendor_subscriptions_response.py +107 -0
  22. stackit/stackitmarketplace/models/requested_subscription_state_response.py +103 -0
  23. stackit/stackitmarketplace/models/resolve_customer_payload.py +82 -0
  24. stackit/stackitmarketplace/models/subscription_cancel_response.py +109 -0
  25. stackit/stackitmarketplace/models/subscription_product.py +130 -0
  26. stackit/stackitmarketplace/models/vendor_subscription.py +115 -0
  27. stackit/stackitmarketplace/py.typed +0 -0
  28. stackit/stackitmarketplace/rest.py +149 -0
  29. stackit_stackitmarketplace-0.1.0.dist-info/METADATA +44 -0
  30. stackit_stackitmarketplace-0.1.0.dist-info/RECORD +31 -0
  31. stackit_stackitmarketplace-0.1.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,138 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Marketplace API
5
+
6
+ API to manage STACKIT Marketplace.
7
+
8
+ The version of the OpenAPI document: 1
9
+ Contact: marketplace@stackit.de
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501 docstring might be too long
14
+
15
+ import os
16
+
17
+
18
+ class HostConfiguration:
19
+ def __init__(
20
+ self,
21
+ region=None,
22
+ server_index=None,
23
+ server_variables=None,
24
+ server_operation_index=None,
25
+ server_operation_variables=None,
26
+ ignore_operation_servers=False,
27
+ ) -> None:
28
+ print(
29
+ "WARNING: STACKIT will move to a new way of specifying regions, where the region is provided\n",
30
+ "as a function argument instead of being set in the client configuration.\n"
31
+ "Once all services have migrated, the methods to specify the region in the client configuration "
32
+ "will be removed.",
33
+ )
34
+ """Constructor
35
+ """
36
+ self._base_path = "https://stackit-marketplace.api.stackit.cloud"
37
+ """Default Base url
38
+ """
39
+ self.server_index = 0 if server_index is None else server_index
40
+ self.server_operation_index = server_operation_index or {}
41
+ """Default server index
42
+ """
43
+ self.server_variables = server_variables or {}
44
+ if region:
45
+ self.server_variables["region"] = "{}.".format(region)
46
+ self.server_operation_variables = server_operation_variables or {}
47
+ """Default server variables
48
+ """
49
+ self.ignore_operation_servers = ignore_operation_servers
50
+ """Ignore operation servers
51
+ """
52
+
53
+ def get_host_settings(self):
54
+ """Gets an array of host settings
55
+
56
+ :return: An array of host settings
57
+ """
58
+ return [
59
+ {
60
+ "url": "https://stackit-marketplace.api.stackit.cloud",
61
+ "description": "No description provided",
62
+ "variables": {
63
+ "region": {
64
+ "description": "No description provided",
65
+ "default_value": "global",
66
+ }
67
+ },
68
+ }
69
+ ]
70
+
71
+ def get_host_from_settings(self, index, variables=None, servers=None):
72
+ """Gets host URL based on the index and variables
73
+ :param index: array index of the host settings
74
+ :param variables: hash of variable and the corresponding value
75
+ :param servers: an array of host settings or None
76
+ :error: if a region is given for a global url
77
+ :return: URL based on host settings
78
+ """
79
+ if index is None:
80
+ return self._base_path
81
+
82
+ variables = {} if variables is None else variables
83
+ servers = self.get_host_settings() if servers is None else servers
84
+
85
+ try:
86
+ server = servers[index]
87
+ except IndexError:
88
+ raise ValueError(
89
+ "Invalid index {0} when selecting the host settings. "
90
+ "Must be less than {1}".format(index, len(servers))
91
+ )
92
+
93
+ url = server["url"]
94
+
95
+ # check if environment variable was provided for region
96
+ # if nothing was set this is None
97
+ region_env = os.environ.get("STACKIT_REGION")
98
+
99
+ # go through variables and replace placeholders
100
+ for variable_name, variable in server.get("variables", {}).items():
101
+ # If a region is provided by the user for a global url
102
+ # return an error (except for providing via environment variable).
103
+ # The region is provided as a function argument instead of being set in the client configuration.
104
+ if (
105
+ variable_name == "region"
106
+ and (variable["default_value"] == "global" or variable["default_value"] == "")
107
+ and region_env is None
108
+ and variables.get(variable_name) is not None
109
+ ):
110
+ raise ValueError(
111
+ "this API does not support setting a region in the the client configuration, "
112
+ "please check if the region can be specified as a function parameter"
113
+ )
114
+ used_value = variables.get(variable_name, variable["default_value"])
115
+
116
+ if "enum_values" in variable and used_value not in variable["enum_values"]:
117
+ given_value = variables[variable_name].replace(".", "")
118
+ valid_values = [v.replace(".", "") for v in variable["enum_values"]]
119
+ raise ValueError(
120
+ "The variable `{0}` in the host URL has invalid value '{1}'. Must be '{2}'.".format(
121
+ variable_name, given_value, valid_values
122
+ )
123
+ )
124
+
125
+ url = url.replace("{" + variable_name + "}", used_value)
126
+
127
+ return url
128
+
129
+ @property
130
+ def host(self):
131
+ """Return generated host."""
132
+ return self.get_host_from_settings(self.server_index, variables=self.server_variables)
133
+
134
+ @host.setter
135
+ def host(self, value):
136
+ """Fix base path."""
137
+ self._base_path = value
138
+ self.server_index = None
@@ -0,0 +1,199 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Marketplace API
5
+
6
+ API to manage STACKIT Marketplace.
7
+
8
+ The version of the OpenAPI document: 1
9
+ Contact: marketplace@stackit.de
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501 docstring might be too long
14
+
15
+ from typing import Any, Optional
16
+
17
+ from typing_extensions import Self
18
+
19
+
20
+ class OpenApiException(Exception):
21
+ """The base exception class for all OpenAPIExceptions"""
22
+
23
+
24
+ class ApiTypeError(OpenApiException, TypeError):
25
+ def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None) -> None:
26
+ """Raises an exception for TypeErrors
27
+
28
+ Args:
29
+ msg (str): the exception message
30
+
31
+ Keyword Args:
32
+ path_to_item (list): a list of keys an indices to get to the
33
+ current_item
34
+ None if unset
35
+ valid_classes (tuple): the primitive classes that current item
36
+ should be an instance of
37
+ None if unset
38
+ key_type (bool): False if our value is a value in a dict
39
+ True if it is a key in a dict
40
+ False if our item is an item in a list
41
+ None if unset
42
+ """
43
+ self.path_to_item = path_to_item
44
+ self.valid_classes = valid_classes
45
+ self.key_type = key_type
46
+ full_msg = msg
47
+ if path_to_item:
48
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
49
+ super(ApiTypeError, self).__init__(full_msg)
50
+
51
+
52
+ class ApiValueError(OpenApiException, ValueError):
53
+ def __init__(self, msg, path_to_item=None) -> None:
54
+ """
55
+ Args:
56
+ msg (str): the exception message
57
+
58
+ Keyword Args:
59
+ path_to_item (list) the path to the exception in the
60
+ received_data dict. None if unset
61
+ """
62
+
63
+ self.path_to_item = path_to_item
64
+ full_msg = msg
65
+ if path_to_item:
66
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
67
+ super(ApiValueError, self).__init__(full_msg)
68
+
69
+
70
+ class ApiAttributeError(OpenApiException, AttributeError):
71
+ def __init__(self, msg, path_to_item=None) -> None:
72
+ """
73
+ Raised when an attribute reference or assignment fails.
74
+
75
+ Args:
76
+ msg (str): the exception message
77
+
78
+ Keyword Args:
79
+ path_to_item (None/list) the path to the exception in the
80
+ received_data dict
81
+ """
82
+ self.path_to_item = path_to_item
83
+ full_msg = msg
84
+ if path_to_item:
85
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
86
+ super(ApiAttributeError, self).__init__(full_msg)
87
+
88
+
89
+ class ApiKeyError(OpenApiException, KeyError):
90
+ def __init__(self, msg, path_to_item=None) -> None:
91
+ """
92
+ Args:
93
+ msg (str): the exception message
94
+
95
+ Keyword Args:
96
+ path_to_item (None/list) the path to the exception in the
97
+ received_data dict
98
+ """
99
+ self.path_to_item = path_to_item
100
+ full_msg = msg
101
+ if path_to_item:
102
+ full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
103
+ super(ApiKeyError, self).__init__(full_msg)
104
+
105
+
106
+ class ApiException(OpenApiException):
107
+
108
+ def __init__(
109
+ self,
110
+ status=None,
111
+ reason=None,
112
+ http_resp=None,
113
+ *,
114
+ body: Optional[str] = None,
115
+ data: Optional[Any] = None,
116
+ ) -> None:
117
+ self.status = status
118
+ self.reason = reason
119
+ self.body = body
120
+ self.data = data
121
+ self.headers = None
122
+
123
+ if http_resp:
124
+ if self.status is None:
125
+ self.status = http_resp.status
126
+ if self.reason is None:
127
+ self.reason = http_resp.reason
128
+ if self.body is None:
129
+ try:
130
+ self.body = http_resp.data.decode("utf-8")
131
+ except Exception: # noqa: S110
132
+ pass
133
+ self.headers = http_resp.getheaders()
134
+
135
+ @classmethod
136
+ def from_response(
137
+ cls,
138
+ *,
139
+ http_resp,
140
+ body: Optional[str],
141
+ data: Optional[Any],
142
+ ) -> Self:
143
+ if http_resp.status == 400:
144
+ raise BadRequestException(http_resp=http_resp, body=body, data=data)
145
+
146
+ if http_resp.status == 401:
147
+ raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
148
+
149
+ if http_resp.status == 403:
150
+ raise ForbiddenException(http_resp=http_resp, body=body, data=data)
151
+
152
+ if http_resp.status == 404:
153
+ raise NotFoundException(http_resp=http_resp, body=body, data=data)
154
+
155
+ if 500 <= http_resp.status <= 599:
156
+ raise ServiceException(http_resp=http_resp, body=body, data=data)
157
+ raise ApiException(http_resp=http_resp, body=body, data=data)
158
+
159
+ def __str__(self):
160
+ """Custom error messages for exception"""
161
+ error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason)
162
+ if self.headers:
163
+ error_message += "HTTP response headers: {0}\n".format(self.headers)
164
+
165
+ if self.data or self.body:
166
+ error_message += "HTTP response body: {0}\n".format(self.data or self.body)
167
+
168
+ return error_message
169
+
170
+
171
+ class BadRequestException(ApiException):
172
+ pass
173
+
174
+
175
+ class NotFoundException(ApiException):
176
+ pass
177
+
178
+
179
+ class UnauthorizedException(ApiException):
180
+ pass
181
+
182
+
183
+ class ForbiddenException(ApiException):
184
+ pass
185
+
186
+
187
+ class ServiceException(ApiException):
188
+ pass
189
+
190
+
191
+ def render_path(path_to_item):
192
+ """Returns a string representation of a path"""
193
+ result = ""
194
+ for pth in path_to_item:
195
+ if isinstance(pth, int):
196
+ result += "[{0}]".format(pth)
197
+ else:
198
+ result += "['{0}']".format(pth)
199
+ return result
@@ -0,0 +1,65 @@
1
+ # coding: utf-8
2
+
3
+ # flake8: noqa
4
+ """
5
+ STACKIT Marketplace API
6
+
7
+ API to manage STACKIT Marketplace.
8
+
9
+ The version of the OpenAPI document: 1
10
+ Contact: marketplace@stackit.de
11
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
12
+
13
+ Do not edit the class manually.
14
+ """ # noqa: E501 docstring might be too long
15
+
16
+
17
+ # import models into model package
18
+ from stackit.stackitmarketplace.models.catalog_pricing_option_highlight import (
19
+ CatalogPricingOptionHighlight,
20
+ )
21
+ from stackit.stackitmarketplace.models.catalog_product_detail import (
22
+ CatalogProductDetail,
23
+ )
24
+ from stackit.stackitmarketplace.models.catalog_product_details_vendor import (
25
+ CatalogProductDetailsVendor,
26
+ )
27
+ from stackit.stackitmarketplace.models.catalog_product_highlight import (
28
+ CatalogProductHighlight,
29
+ )
30
+ from stackit.stackitmarketplace.models.catalog_product_overview import (
31
+ CatalogProductOverview,
32
+ )
33
+ from stackit.stackitmarketplace.models.catalog_product_overview_vendor import (
34
+ CatalogProductOverviewVendor,
35
+ )
36
+ from stackit.stackitmarketplace.models.catalog_product_pricing_option import (
37
+ CatalogProductPricingOption,
38
+ )
39
+ from stackit.stackitmarketplace.models.catalog_product_support_resource import (
40
+ CatalogProductSupportResource,
41
+ )
42
+ from stackit.stackitmarketplace.models.catalog_product_vendor_terms import (
43
+ CatalogProductVendorTerms,
44
+ )
45
+ from stackit.stackitmarketplace.models.current_subscription_state_response import (
46
+ CurrentSubscriptionStateResponse,
47
+ )
48
+ from stackit.stackitmarketplace.models.error_response import ErrorResponse
49
+ from stackit.stackitmarketplace.models.list_catalog_products_response import (
50
+ ListCatalogProductsResponse,
51
+ )
52
+ from stackit.stackitmarketplace.models.list_vendor_subscriptions_response import (
53
+ ListVendorSubscriptionsResponse,
54
+ )
55
+ from stackit.stackitmarketplace.models.requested_subscription_state_response import (
56
+ RequestedSubscriptionStateResponse,
57
+ )
58
+ from stackit.stackitmarketplace.models.resolve_customer_payload import (
59
+ ResolveCustomerPayload,
60
+ )
61
+ from stackit.stackitmarketplace.models.subscription_cancel_response import (
62
+ SubscriptionCancelResponse,
63
+ )
64
+ from stackit.stackitmarketplace.models.subscription_product import SubscriptionProduct
65
+ from stackit.stackitmarketplace.models.vendor_subscription import VendorSubscription
@@ -0,0 +1,84 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Marketplace API
5
+
6
+ API to manage STACKIT Marketplace.
7
+
8
+ The version of the OpenAPI document: 1
9
+ Contact: marketplace@stackit.de
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501 docstring might be too long
14
+
15
+ from __future__ import annotations
16
+
17
+ import json
18
+ import pprint
19
+ from typing import Any, ClassVar, Dict, List, Optional, Set
20
+
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr
22
+ from typing_extensions import Self
23
+
24
+
25
+ class CatalogPricingOptionHighlight(BaseModel):
26
+ """
27
+ CatalogPricingOptionHighlight
28
+ """
29
+
30
+ highlight_content: Optional[StrictStr] = Field(
31
+ default=None, description="The highlight content.", alias="highlightContent"
32
+ )
33
+ __properties: ClassVar[List[str]] = ["highlightContent"]
34
+
35
+ model_config = ConfigDict(
36
+ populate_by_name=True,
37
+ validate_assignment=True,
38
+ protected_namespaces=(),
39
+ )
40
+
41
+ def to_str(self) -> str:
42
+ """Returns the string representation of the model using alias"""
43
+ return pprint.pformat(self.model_dump(by_alias=True))
44
+
45
+ def to_json(self) -> str:
46
+ """Returns the JSON representation of the model using alias"""
47
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48
+ return json.dumps(self.to_dict())
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of CatalogPricingOptionHighlight from a JSON string"""
53
+ return cls.from_dict(json.loads(json_str))
54
+
55
+ def to_dict(self) -> Dict[str, Any]:
56
+ """Return the dictionary representation of the model using alias.
57
+
58
+ This has the following differences from calling pydantic's
59
+ `self.model_dump(by_alias=True)`:
60
+
61
+ * `None` is only added to the output dict for nullable fields that
62
+ were set at model initialization. Other fields with value `None`
63
+ are ignored.
64
+ """
65
+ excluded_fields: Set[str] = set([])
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 CatalogPricingOptionHighlight 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({"highlightContent": obj.get("highlightContent")})
84
+ return _obj