stackit-redis 0.0.1a0__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 (40) hide show
  1. stackit/redis/__init__.py +68 -0
  2. stackit/redis/api/__init__.py +4 -0
  3. stackit/redis/api/default_api.py +4812 -0
  4. stackit/redis/api_client.py +626 -0
  5. stackit/redis/api_response.py +23 -0
  6. stackit/redis/configuration.py +111 -0
  7. stackit/redis/exceptions.py +198 -0
  8. stackit/redis/models/__init__.py +49 -0
  9. stackit/redis/models/backup.py +95 -0
  10. stackit/redis/models/create_backup_response_item.py +82 -0
  11. stackit/redis/models/create_instance_payload.py +96 -0
  12. stackit/redis/models/create_instance_response.py +81 -0
  13. stackit/redis/models/credentials.py +97 -0
  14. stackit/redis/models/credentials_list_item.py +81 -0
  15. stackit/redis/models/credentials_response.py +94 -0
  16. stackit/redis/models/error.py +82 -0
  17. stackit/redis/models/get_metrics_response.py +153 -0
  18. stackit/redis/models/instance.py +147 -0
  19. stackit/redis/models/instance_last_operation.py +99 -0
  20. stackit/redis/models/instance_parameters.py +242 -0
  21. stackit/redis/models/instance_schema.py +95 -0
  22. stackit/redis/models/list_backups_response.py +98 -0
  23. stackit/redis/models/list_credentials_response.py +98 -0
  24. stackit/redis/models/list_instances_response.py +98 -0
  25. stackit/redis/models/list_offerings_response.py +98 -0
  26. stackit/redis/models/list_restores_response.py +98 -0
  27. stackit/redis/models/model_schema.py +81 -0
  28. stackit/redis/models/offering.py +127 -0
  29. stackit/redis/models/partial_update_instance_payload.py +96 -0
  30. stackit/redis/models/plan.py +93 -0
  31. stackit/redis/models/raw_credentials.py +88 -0
  32. stackit/redis/models/restore.py +93 -0
  33. stackit/redis/models/trigger_restore_response.py +81 -0
  34. stackit/redis/models/update_backups_config_payload.py +81 -0
  35. stackit/redis/models/update_backups_config_response.py +81 -0
  36. stackit/redis/py.typed +0 -0
  37. stackit/redis/rest.py +148 -0
  38. stackit_redis-0.0.1a0.dist-info/METADATA +45 -0
  39. stackit_redis-0.0.1a0.dist-info/RECORD +40 -0
  40. stackit_redis-0.0.1a0.dist-info/WHEEL +4 -0
@@ -0,0 +1,93 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Redis API
5
+
6
+ The STACKIT Redis API provides endpoints to list service offerings, manage service instances and service credentials within STACKIT portal projects.
7
+
8
+ The version of the OpenAPI document: 1.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501 docstring might be too long
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ from typing import Any, ClassVar, Dict, List, Optional, Set
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
21
+ from typing_extensions import Self
22
+
23
+
24
+ class Plan(BaseModel):
25
+ """
26
+ Plan
27
+ """
28
+
29
+ description: StrictStr
30
+ free: StrictBool
31
+ id: StrictStr
32
+ name: StrictStr
33
+ sku_name: StrictStr = Field(alias="skuName")
34
+ __properties: ClassVar[List[str]] = ["description", "free", "id", "name", "skuName"]
35
+
36
+ model_config = ConfigDict(
37
+ populate_by_name=True,
38
+ validate_assignment=True,
39
+ protected_namespaces=(),
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 Plan 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
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ return _dict
74
+
75
+ @classmethod
76
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
77
+ """Create an instance of Plan from a dict"""
78
+ if obj is None:
79
+ return None
80
+
81
+ if not isinstance(obj, dict):
82
+ return cls.model_validate(obj)
83
+
84
+ _obj = cls.model_validate(
85
+ {
86
+ "description": obj.get("description"),
87
+ "free": obj.get("free"),
88
+ "id": obj.get("id"),
89
+ "name": obj.get("name"),
90
+ "skuName": obj.get("skuName"),
91
+ }
92
+ )
93
+ return _obj
@@ -0,0 +1,88 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Redis API
5
+
6
+ The STACKIT Redis API provides endpoints to list service offerings, manage service instances and service credentials within STACKIT portal projects.
7
+
8
+ The version of the OpenAPI document: 1.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501 docstring might be too long
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ from typing import Any, ClassVar, Dict, List, Optional, Set
19
+
20
+ from pydantic import BaseModel, ConfigDict
21
+ from typing_extensions import Self
22
+
23
+ from stackit.redis.models.credentials import Credentials
24
+
25
+
26
+ class RawCredentials(BaseModel):
27
+ """
28
+ RawCredentials
29
+ """
30
+
31
+ credentials: Credentials
32
+ __properties: ClassVar[List[str]] = ["credentials"]
33
+
34
+ model_config = ConfigDict(
35
+ populate_by_name=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
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 RawCredentials 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
+ _dict = self.model_dump(
67
+ by_alias=True,
68
+ exclude=excluded_fields,
69
+ exclude_none=True,
70
+ )
71
+ # override the default output from pydantic by calling `to_dict()` of credentials
72
+ if self.credentials:
73
+ _dict["credentials"] = self.credentials.to_dict()
74
+ return _dict
75
+
76
+ @classmethod
77
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
78
+ """Create an instance of RawCredentials 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
+ {"credentials": Credentials.from_dict(obj["credentials"]) if obj.get("credentials") is not None else None}
87
+ )
88
+ return _obj
@@ -0,0 +1,93 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Redis API
5
+
6
+ The STACKIT Redis API provides endpoints to list service offerings, manage service instances and service credentials within STACKIT portal projects.
7
+
8
+ The version of the OpenAPI document: 1.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501 docstring might be too long
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ from typing import Any, ClassVar, Dict, List, Optional, Set
19
+
20
+ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
21
+ from typing_extensions import Self
22
+
23
+
24
+ class Restore(BaseModel):
25
+ """
26
+ Restore
27
+ """
28
+
29
+ backup_id: StrictInt
30
+ finished_at: StrictStr
31
+ id: StrictInt
32
+ status: StrictStr
33
+ triggered_at: Optional[StrictStr] = None
34
+ __properties: ClassVar[List[str]] = ["backup_id", "finished_at", "id", "status", "triggered_at"]
35
+
36
+ model_config = ConfigDict(
37
+ populate_by_name=True,
38
+ validate_assignment=True,
39
+ protected_namespaces=(),
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 Restore 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
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ return _dict
74
+
75
+ @classmethod
76
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
77
+ """Create an instance of Restore from a dict"""
78
+ if obj is None:
79
+ return None
80
+
81
+ if not isinstance(obj, dict):
82
+ return cls.model_validate(obj)
83
+
84
+ _obj = cls.model_validate(
85
+ {
86
+ "backup_id": obj.get("backup_id"),
87
+ "finished_at": obj.get("finished_at"),
88
+ "id": obj.get("id"),
89
+ "status": obj.get("status"),
90
+ "triggered_at": obj.get("triggered_at"),
91
+ }
92
+ )
93
+ return _obj
@@ -0,0 +1,81 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Redis API
5
+
6
+ The STACKIT Redis API provides endpoints to list service offerings, manage service instances and service credentials within STACKIT portal projects.
7
+
8
+ The version of the OpenAPI document: 1.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501 docstring might be too long
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ from typing import Any, ClassVar, Dict, List, Optional, Set
19
+
20
+ from pydantic import BaseModel, ConfigDict, StrictInt
21
+ from typing_extensions import Self
22
+
23
+
24
+ class TriggerRestoreResponse(BaseModel):
25
+ """
26
+ TriggerRestoreResponse
27
+ """
28
+
29
+ id: StrictInt
30
+ __properties: ClassVar[List[str]] = ["id"]
31
+
32
+ model_config = ConfigDict(
33
+ populate_by_name=True,
34
+ validate_assignment=True,
35
+ protected_namespaces=(),
36
+ )
37
+
38
+ def to_str(self) -> str:
39
+ """Returns the string representation of the model using alias"""
40
+ return pprint.pformat(self.model_dump(by_alias=True))
41
+
42
+ def to_json(self) -> str:
43
+ """Returns the JSON representation of the model using alias"""
44
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
45
+ return json.dumps(self.to_dict())
46
+
47
+ @classmethod
48
+ def from_json(cls, json_str: str) -> Optional[Self]:
49
+ """Create an instance of TriggerRestoreResponse from a JSON string"""
50
+ return cls.from_dict(json.loads(json_str))
51
+
52
+ def to_dict(self) -> Dict[str, Any]:
53
+ """Return the dictionary representation of the model using alias.
54
+
55
+ This has the following differences from calling pydantic's
56
+ `self.model_dump(by_alias=True)`:
57
+
58
+ * `None` is only added to the output dict for nullable fields that
59
+ were set at model initialization. Other fields with value `None`
60
+ are ignored.
61
+ """
62
+ excluded_fields: Set[str] = set([])
63
+
64
+ _dict = self.model_dump(
65
+ by_alias=True,
66
+ exclude=excluded_fields,
67
+ exclude_none=True,
68
+ )
69
+ return _dict
70
+
71
+ @classmethod
72
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
73
+ """Create an instance of TriggerRestoreResponse from a dict"""
74
+ if obj is None:
75
+ return None
76
+
77
+ if not isinstance(obj, dict):
78
+ return cls.model_validate(obj)
79
+
80
+ _obj = cls.model_validate({"id": obj.get("id")})
81
+ return _obj
@@ -0,0 +1,81 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Redis API
5
+
6
+ The STACKIT Redis API provides endpoints to list service offerings, manage service instances and service credentials within STACKIT portal projects.
7
+
8
+ The version of the OpenAPI document: 1.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501 docstring might be too long
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ from typing import Any, ClassVar, Dict, List, Optional, Set
19
+
20
+ from pydantic import BaseModel, ConfigDict, StrictStr
21
+ from typing_extensions import Self
22
+
23
+
24
+ class UpdateBackupsConfigPayload(BaseModel):
25
+ """
26
+ UpdateBackupsConfigPayload
27
+ """
28
+
29
+ encryption_key: Optional[StrictStr] = None
30
+ __properties: ClassVar[List[str]] = ["encryption_key"]
31
+
32
+ model_config = ConfigDict(
33
+ populate_by_name=True,
34
+ validate_assignment=True,
35
+ protected_namespaces=(),
36
+ )
37
+
38
+ def to_str(self) -> str:
39
+ """Returns the string representation of the model using alias"""
40
+ return pprint.pformat(self.model_dump(by_alias=True))
41
+
42
+ def to_json(self) -> str:
43
+ """Returns the JSON representation of the model using alias"""
44
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
45
+ return json.dumps(self.to_dict())
46
+
47
+ @classmethod
48
+ def from_json(cls, json_str: str) -> Optional[Self]:
49
+ """Create an instance of UpdateBackupsConfigPayload from a JSON string"""
50
+ return cls.from_dict(json.loads(json_str))
51
+
52
+ def to_dict(self) -> Dict[str, Any]:
53
+ """Return the dictionary representation of the model using alias.
54
+
55
+ This has the following differences from calling pydantic's
56
+ `self.model_dump(by_alias=True)`:
57
+
58
+ * `None` is only added to the output dict for nullable fields that
59
+ were set at model initialization. Other fields with value `None`
60
+ are ignored.
61
+ """
62
+ excluded_fields: Set[str] = set([])
63
+
64
+ _dict = self.model_dump(
65
+ by_alias=True,
66
+ exclude=excluded_fields,
67
+ exclude_none=True,
68
+ )
69
+ return _dict
70
+
71
+ @classmethod
72
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
73
+ """Create an instance of UpdateBackupsConfigPayload from a dict"""
74
+ if obj is None:
75
+ return None
76
+
77
+ if not isinstance(obj, dict):
78
+ return cls.model_validate(obj)
79
+
80
+ _obj = cls.model_validate({"encryption_key": obj.get("encryption_key")})
81
+ return _obj
@@ -0,0 +1,81 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Redis API
5
+
6
+ The STACKIT Redis API provides endpoints to list service offerings, manage service instances and service credentials within STACKIT portal projects.
7
+
8
+ The version of the OpenAPI document: 1.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501 docstring might be too long
13
+
14
+ from __future__ import annotations
15
+
16
+ import json
17
+ import pprint
18
+ from typing import Any, ClassVar, Dict, List, Optional, Set
19
+
20
+ from pydantic import BaseModel, ConfigDict, StrictStr
21
+ from typing_extensions import Self
22
+
23
+
24
+ class UpdateBackupsConfigResponse(BaseModel):
25
+ """
26
+ UpdateBackupsConfigResponse
27
+ """
28
+
29
+ message: StrictStr
30
+ __properties: ClassVar[List[str]] = ["message"]
31
+
32
+ model_config = ConfigDict(
33
+ populate_by_name=True,
34
+ validate_assignment=True,
35
+ protected_namespaces=(),
36
+ )
37
+
38
+ def to_str(self) -> str:
39
+ """Returns the string representation of the model using alias"""
40
+ return pprint.pformat(self.model_dump(by_alias=True))
41
+
42
+ def to_json(self) -> str:
43
+ """Returns the JSON representation of the model using alias"""
44
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
45
+ return json.dumps(self.to_dict())
46
+
47
+ @classmethod
48
+ def from_json(cls, json_str: str) -> Optional[Self]:
49
+ """Create an instance of UpdateBackupsConfigResponse from a JSON string"""
50
+ return cls.from_dict(json.loads(json_str))
51
+
52
+ def to_dict(self) -> Dict[str, Any]:
53
+ """Return the dictionary representation of the model using alias.
54
+
55
+ This has the following differences from calling pydantic's
56
+ `self.model_dump(by_alias=True)`:
57
+
58
+ * `None` is only added to the output dict for nullable fields that
59
+ were set at model initialization. Other fields with value `None`
60
+ are ignored.
61
+ """
62
+ excluded_fields: Set[str] = set([])
63
+
64
+ _dict = self.model_dump(
65
+ by_alias=True,
66
+ exclude=excluded_fields,
67
+ exclude_none=True,
68
+ )
69
+ return _dict
70
+
71
+ @classmethod
72
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
73
+ """Create an instance of UpdateBackupsConfigResponse from a dict"""
74
+ if obj is None:
75
+ return None
76
+
77
+ if not isinstance(obj, dict):
78
+ return cls.model_validate(obj)
79
+
80
+ _obj = cls.model_validate({"message": obj.get("message")})
81
+ return _obj
stackit/redis/py.typed ADDED
File without changes
stackit/redis/rest.py ADDED
@@ -0,0 +1,148 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ STACKIT Redis API
5
+
6
+ The STACKIT Redis API provides endpoints to list service offerings, manage service instances and service credentials within STACKIT portal projects.
7
+
8
+ The version of the OpenAPI document: 1.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501 docstring might be too long
13
+
14
+ import io
15
+ import json
16
+ import re
17
+
18
+ import requests
19
+ from stackit.core.authorization import Authorization
20
+ from stackit.core.configuration import Configuration
21
+
22
+ from stackit.redis.exceptions import ApiException, ApiValueError
23
+
24
+
25
+ RESTResponseType = requests.Response
26
+
27
+
28
+ class RESTResponse(io.IOBase):
29
+
30
+ def __init__(self, resp) -> None:
31
+ self.response = resp
32
+ self.status = resp.status_code
33
+ self.reason = resp.reason
34
+ self.data = None
35
+
36
+ def read(self):
37
+ if self.data is None:
38
+ self.data = self.response.content
39
+ return self.data
40
+
41
+ def getheaders(self):
42
+ """Returns a dictionary of the response headers."""
43
+ return self.response.headers
44
+
45
+ def getheader(self, name, default=None):
46
+ """Returns a given response header."""
47
+ return self.response.headers.get(name, default)
48
+
49
+
50
+ class RESTClientObject:
51
+ def __init__(self, config: Configuration) -> None:
52
+ self.session = config.custom_http_session if config.custom_http_session else requests.Session()
53
+ authorization = Authorization(config)
54
+ self.session.auth = authorization.auth_method
55
+
56
+ def request(self, method, url, headers=None, body=None, post_params=None, _request_timeout=None):
57
+ """Perform requests.
58
+
59
+ :param method: http request method
60
+ :param url: http request url
61
+ :param headers: http request headers
62
+ :param body: request json body, for `application/json`
63
+ :param post_params: request post parameters,
64
+ `application/x-www-form-urlencoded`
65
+ and `multipart/form-data`
66
+ :param _request_timeout: timeout setting for this request. If one
67
+ number provided, it will be total request
68
+ timeout. It can also be a pair (tuple) of
69
+ (connection, read) timeouts.
70
+ """
71
+ method = method.upper()
72
+ if method not in ["GET", "HEAD", "DELETE", "POST", "PUT", "PATCH", "OPTIONS"]:
73
+ raise ValueError("Method %s not allowed", method)
74
+
75
+ if post_params and body:
76
+ raise ApiValueError("body parameter cannot be used with post_params parameter.")
77
+
78
+ post_params = post_params or {}
79
+ headers = headers or {}
80
+
81
+ try:
82
+ # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
83
+ if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]:
84
+
85
+ # no content type provided or payload is json
86
+ content_type = headers.get("Content-Type")
87
+ if not content_type or re.search("json", content_type, re.IGNORECASE):
88
+ request_body = None
89
+ if body is not None:
90
+ request_body = json.dumps(body)
91
+ r = self.session.request(
92
+ method,
93
+ url,
94
+ data=request_body,
95
+ headers=headers,
96
+ )
97
+ elif content_type == "application/x-www-form-urlencoded":
98
+ r = self.session.request(
99
+ method,
100
+ url,
101
+ params=post_params,
102
+ headers=headers,
103
+ )
104
+ elif content_type == "multipart/form-data":
105
+ # must del headers['Content-Type'], or the correct
106
+ # Content-Type which generated by urllib3 will be
107
+ # overwritten.
108
+ del headers["Content-Type"]
109
+ # Ensures that dict objects are serialized
110
+ post_params = [(a, json.dumps(b)) if isinstance(b, dict) else (a, b) for a, b in post_params]
111
+ r = self.session.request(
112
+ method,
113
+ url,
114
+ files=post_params,
115
+ headers=headers,
116
+ )
117
+ # Pass a `string` parameter directly in the body to support
118
+ # other content types than JSON when `body` argument is
119
+ # provided in serialized form.
120
+ elif isinstance(body, str) or isinstance(body, bytes):
121
+ r = self.session.request(
122
+ method,
123
+ url,
124
+ data=body,
125
+ headers=headers,
126
+ )
127
+ elif headers["Content-Type"] == "text/plain" and isinstance(body, bool):
128
+ request_body = "true" if body else "false"
129
+ r = self.session.request(method, url, data=request_body, headers=headers)
130
+ else:
131
+ # Cannot generate the request from given parameters
132
+ msg = """Cannot prepare a request message for provided
133
+ arguments. Please check that your arguments match
134
+ declared content type."""
135
+ raise ApiException(status=0, reason=msg)
136
+ # For `GET`, `HEAD`
137
+ else:
138
+ r = self.session.request(
139
+ method,
140
+ url,
141
+ params={},
142
+ headers=headers,
143
+ )
144
+ except requests.exceptions.SSLError as e:
145
+ msg = "\n".join([type(e).__name__, str(e)])
146
+ raise ApiException(status=0, reason=msg)
147
+
148
+ return RESTResponse(r)