unitycatalog-client 0.2.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.
Files changed (82) hide show
  1. unitycatalog/client/__init__.py +102 -0
  2. unitycatalog/client/api/__init__.py +13 -0
  3. unitycatalog/client/api/catalogs_api.py +1404 -0
  4. unitycatalog/client/api/functions_api.py +1135 -0
  5. unitycatalog/client/api/grants_api.py +630 -0
  6. unitycatalog/client/api/model_versions_api.py +1748 -0
  7. unitycatalog/client/api/registered_models_api.py +1438 -0
  8. unitycatalog/client/api/schemas_api.py +1421 -0
  9. unitycatalog/client/api/tables_api.py +1135 -0
  10. unitycatalog/client/api/temporary_credentials_api.py +1109 -0
  11. unitycatalog/client/api/volumes_api.py +1421 -0
  12. unitycatalog/client/api_client.py +773 -0
  13. unitycatalog/client/api_response.py +21 -0
  14. unitycatalog/client/configuration.py +432 -0
  15. unitycatalog/client/exceptions.py +199 -0
  16. unitycatalog/client/models/__init__.py +77 -0
  17. unitycatalog/client/models/aws_credentials.py +91 -0
  18. unitycatalog/client/models/azure_user_delegation_sas.py +87 -0
  19. unitycatalog/client/models/catalog_info.py +103 -0
  20. unitycatalog/client/models/column_info.py +108 -0
  21. unitycatalog/client/models/column_type_name.py +56 -0
  22. unitycatalog/client/models/create_catalog.py +91 -0
  23. unitycatalog/client/models/create_function.py +163 -0
  24. unitycatalog/client/models/create_function_request.py +91 -0
  25. unitycatalog/client/models/create_model_version.py +97 -0
  26. unitycatalog/client/models/create_registered_model.py +93 -0
  27. unitycatalog/client/models/create_schema.py +93 -0
  28. unitycatalog/client/models/create_table.py +113 -0
  29. unitycatalog/client/models/create_volume_request_content.py +99 -0
  30. unitycatalog/client/models/data_source_format.py +42 -0
  31. unitycatalog/client/models/dependency.py +97 -0
  32. unitycatalog/client/models/dependency_list.py +95 -0
  33. unitycatalog/client/models/finalize_model_version.py +89 -0
  34. unitycatalog/client/models/function_dependency.py +87 -0
  35. unitycatalog/client/models/function_info.py +189 -0
  36. unitycatalog/client/models/function_parameter_info.py +112 -0
  37. unitycatalog/client/models/function_parameter_infos.py +95 -0
  38. unitycatalog/client/models/function_parameter_mode.py +36 -0
  39. unitycatalog/client/models/function_parameter_type.py +37 -0
  40. unitycatalog/client/models/gcp_oauth_token.py +87 -0
  41. unitycatalog/client/models/generate_temporary_model_version_credential.py +96 -0
  42. unitycatalog/client/models/generate_temporary_path_credential.py +90 -0
  43. unitycatalog/client/models/generate_temporary_table_credential.py +90 -0
  44. unitycatalog/client/models/generate_temporary_volume_credential.py +90 -0
  45. unitycatalog/client/models/list_catalogs_response.py +97 -0
  46. unitycatalog/client/models/list_functions_response.py +97 -0
  47. unitycatalog/client/models/list_model_versions_response.py +97 -0
  48. unitycatalog/client/models/list_registered_models_response.py +97 -0
  49. unitycatalog/client/models/list_schemas_response.py +97 -0
  50. unitycatalog/client/models/list_tables_response.py +97 -0
  51. unitycatalog/client/models/list_volumes_response_content.py +97 -0
  52. unitycatalog/client/models/model_version_info.py +114 -0
  53. unitycatalog/client/models/model_version_operation.py +38 -0
  54. unitycatalog/client/models/model_version_status.py +39 -0
  55. unitycatalog/client/models/path_operation.py +39 -0
  56. unitycatalog/client/models/permissions_change.py +92 -0
  57. unitycatalog/client/models/permissions_list.py +95 -0
  58. unitycatalog/client/models/principal_type.py +37 -0
  59. unitycatalog/client/models/privilege.py +47 -0
  60. unitycatalog/client/models/privilege_assignment.py +90 -0
  61. unitycatalog/client/models/registered_model_info.py +109 -0
  62. unitycatalog/client/models/schema_info.py +107 -0
  63. unitycatalog/client/models/securable_type.py +42 -0
  64. unitycatalog/client/models/table_dependency.py +87 -0
  65. unitycatalog/client/models/table_info.py +125 -0
  66. unitycatalog/client/models/table_operation.py +38 -0
  67. unitycatalog/client/models/table_type.py +37 -0
  68. unitycatalog/client/models/temporary_credentials.py +105 -0
  69. unitycatalog/client/models/update_catalog.py +91 -0
  70. unitycatalog/client/models/update_model_version.py +87 -0
  71. unitycatalog/client/models/update_permissions.py +95 -0
  72. unitycatalog/client/models/update_registered_model.py +89 -0
  73. unitycatalog/client/models/update_schema.py +91 -0
  74. unitycatalog/client/models/update_volume_request_content.py +90 -0
  75. unitycatalog/client/models/volume_info.py +113 -0
  76. unitycatalog/client/models/volume_operation.py +38 -0
  77. unitycatalog/client/models/volume_type.py +37 -0
  78. unitycatalog/client/py.typed +0 -0
  79. unitycatalog/client/rest.py +215 -0
  80. unitycatalog_client-0.2.1.dist-info/METADATA +199 -0
  81. unitycatalog_client-0.2.1.dist-info/RECORD +82 -0
  82. unitycatalog_client-0.2.1.dist-info/WHEEL +4 -0
@@ -0,0 +1,91 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Unity Catalog API
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 0.1
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
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing import Optional, Set
23
+ from typing_extensions import Self
24
+
25
+ class UpdateSchema(BaseModel):
26
+ """
27
+ UpdateSchema
28
+ """ # noqa: E501
29
+ comment: Optional[StrictStr] = Field(default=None, description="User-provided free-form text description.")
30
+ properties: Optional[Dict[str, StrictStr]] = Field(default=None, description="A map of key-value properties attached to the securable.")
31
+ new_name: Optional[StrictStr] = Field(default=None, description="New name for the schema.")
32
+ __properties: ClassVar[List[str]] = ["comment", "properties", "new_name"]
33
+
34
+ model_config = ConfigDict(
35
+ populate_by_name=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
38
+ )
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 UpdateSchema 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
+
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 UpdateSchema 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
+ "comment": obj.get("comment"),
86
+ "properties": obj.get("properties"),
87
+ "new_name": obj.get("new_name")
88
+ })
89
+ return _obj
90
+
91
+
@@ -0,0 +1,90 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Unity Catalog API
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 0.1
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
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing_extensions import Annotated
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class UpdateVolumeRequestContent(BaseModel):
27
+ """
28
+ UpdateVolumeRequestContent
29
+ """ # noqa: E501
30
+ comment: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=65536)]] = Field(default=None, description="The comment attached to the volume")
31
+ new_name: Optional[StrictStr] = Field(default=None, description="New name for the volume.")
32
+ __properties: ClassVar[List[str]] = ["comment", "new_name"]
33
+
34
+ model_config = ConfigDict(
35
+ populate_by_name=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
38
+ )
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 UpdateVolumeRequestContent 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
+
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 UpdateVolumeRequestContent 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
+ "comment": obj.get("comment"),
86
+ "new_name": obj.get("new_name")
87
+ })
88
+ return _obj
89
+
90
+
@@ -0,0 +1,113 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Unity Catalog API
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 0.1
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
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from typing_extensions import Annotated
23
+ from unitycatalog.client.models.volume_type import VolumeType
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class VolumeInfo(BaseModel):
28
+ """
29
+ VolumeInfo
30
+ """ # noqa: E501
31
+ catalog_name: Optional[StrictStr] = Field(default=None, description="The name of the catalog where the schema and the volume are")
32
+ schema_name: Optional[StrictStr] = Field(default=None, description="The name of the schema where the volume is")
33
+ name: Optional[StrictStr] = Field(default=None, description="The name of the volume")
34
+ comment: Optional[Annotated[str, Field(min_length=1, strict=True, max_length=65536)]] = Field(default=None, description="The comment attached to the volume")
35
+ owner: Optional[StrictStr] = Field(default=None, description="The identifier of the user who owns the volume")
36
+ created_at: Optional[StrictInt] = Field(default=None, description="Time at which this volume was created, in epoch milliseconds.")
37
+ created_by: Optional[StrictStr] = Field(default=None, description="TThe identifier of the user who created the volume")
38
+ updated_at: Optional[StrictInt] = Field(default=None, description="Time at which this volume was last modified, in epoch milliseconds.")
39
+ updated_by: Optional[StrictStr] = Field(default=None, description="The identifier of the user who updated the volume last time")
40
+ volume_id: Optional[StrictStr] = Field(default=None, description="Unique identifier of the volume")
41
+ volume_type: Optional[VolumeType] = None
42
+ storage_location: Optional[StrictStr] = Field(default=None, description="The storage location of the volume")
43
+ full_name: Optional[StrictStr] = Field(default=None, description="Full name of volume, in form of __catalog_name__.__schema_name__.__volume_name__.")
44
+ __properties: ClassVar[List[str]] = ["catalog_name", "schema_name", "name", "comment", "owner", "created_at", "created_by", "updated_at", "updated_by", "volume_id", "volume_type", "storage_location", "full_name"]
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 VolumeInfo 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
+ """
77
+ excluded_fields: Set[str] = set([
78
+ ])
79
+
80
+ _dict = self.model_dump(
81
+ by_alias=True,
82
+ exclude=excluded_fields,
83
+ exclude_none=True,
84
+ )
85
+ return _dict
86
+
87
+ @classmethod
88
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
89
+ """Create an instance of VolumeInfo from a dict"""
90
+ if obj is None:
91
+ return None
92
+
93
+ if not isinstance(obj, dict):
94
+ return cls.model_validate(obj)
95
+
96
+ _obj = cls.model_validate({
97
+ "catalog_name": obj.get("catalog_name"),
98
+ "schema_name": obj.get("schema_name"),
99
+ "name": obj.get("name"),
100
+ "comment": obj.get("comment"),
101
+ "owner": obj.get("owner"),
102
+ "created_at": obj.get("created_at"),
103
+ "created_by": obj.get("created_by"),
104
+ "updated_at": obj.get("updated_at"),
105
+ "updated_by": obj.get("updated_by"),
106
+ "volume_id": obj.get("volume_id"),
107
+ "volume_type": obj.get("volume_type"),
108
+ "storage_location": obj.get("storage_location"),
109
+ "full_name": obj.get("full_name")
110
+ })
111
+ return _obj
112
+
113
+
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Unity Catalog API
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 0.1
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
+ import json
17
+ from enum import Enum
18
+ from typing_extensions import Self
19
+
20
+
21
+ class VolumeOperation(str, Enum):
22
+ """
23
+ VolumeOperation
24
+ """
25
+
26
+ """
27
+ allowed enum values
28
+ """
29
+ UNKNOWN_VOLUME_OPERATION = 'UNKNOWN_VOLUME_OPERATION'
30
+ READ_VOLUME = 'READ_VOLUME'
31
+ WRITE_VOLUME = 'WRITE_VOLUME'
32
+
33
+ @classmethod
34
+ def from_json(cls, json_str: str) -> Self:
35
+ """Create an instance of VolumeOperation from a JSON string"""
36
+ return cls(json.loads(json_str))
37
+
38
+
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Unity Catalog API
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 0.1
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
+ import json
17
+ from enum import Enum
18
+ from typing_extensions import Self
19
+
20
+
21
+ class VolumeType(str, Enum):
22
+ """
23
+ The type of the volume
24
+ """
25
+
26
+ """
27
+ allowed enum values
28
+ """
29
+ MANAGED = 'MANAGED'
30
+ EXTERNAL = 'EXTERNAL'
31
+
32
+ @classmethod
33
+ def from_json(cls, json_str: str) -> Self:
34
+ """Create an instance of VolumeType from a JSON string"""
35
+ return cls(json.loads(json_str))
36
+
37
+
File without changes
@@ -0,0 +1,215 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Unity Catalog API
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 0.1
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ import io
16
+ import json
17
+ import re
18
+ import ssl
19
+ from typing import Optional, Union
20
+
21
+ import aiohttp
22
+ import aiohttp_retry
23
+
24
+ from unitycatalog.client.exceptions import ApiException, ApiValueError
25
+
26
+ RESTResponseType = aiohttp.ClientResponse
27
+
28
+ ALLOW_RETRY_METHODS = frozenset({'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PUT', 'TRACE'})
29
+
30
+ class RESTResponse(io.IOBase):
31
+
32
+ def __init__(self, resp) -> None:
33
+ self.response = resp
34
+ self.status = resp.status
35
+ self.reason = resp.reason
36
+ self.data = None
37
+
38
+ async def read(self):
39
+ if self.data is None:
40
+ self.data = await self.response.read()
41
+ return self.data
42
+
43
+ def getheaders(self):
44
+ """Returns a CIMultiDictProxy of the response headers."""
45
+ return self.response.headers
46
+
47
+ def getheader(self, name, default=None):
48
+ """Returns a given response header."""
49
+ return self.response.headers.get(name, default)
50
+
51
+
52
+ class RESTClientObject:
53
+
54
+ def __init__(self, configuration) -> None:
55
+
56
+ # maxsize is number of requests to host that are allowed in parallel
57
+ maxsize = configuration.connection_pool_maxsize
58
+
59
+ ssl_context = ssl.create_default_context(
60
+ cafile=configuration.ssl_ca_cert
61
+ )
62
+ if configuration.cert_file:
63
+ ssl_context.load_cert_chain(
64
+ configuration.cert_file, keyfile=configuration.key_file
65
+ )
66
+
67
+ if not configuration.verify_ssl:
68
+ ssl_context.check_hostname = False
69
+ ssl_context.verify_mode = ssl.CERT_NONE
70
+
71
+ connector = aiohttp.TCPConnector(
72
+ limit=maxsize,
73
+ ssl=ssl_context
74
+ )
75
+
76
+ self.proxy = configuration.proxy
77
+ self.proxy_headers = configuration.proxy_headers
78
+
79
+ # https pool manager
80
+ self.pool_manager = aiohttp.ClientSession(
81
+ connector=connector,
82
+ trust_env=True
83
+ )
84
+
85
+ retries = configuration.retries
86
+ self.retry_client: Optional[aiohttp_retry.RetryClient]
87
+ if retries is not None:
88
+ self.retry_client = aiohttp_retry.RetryClient(
89
+ client_session=self.pool_manager,
90
+ retry_options=aiohttp_retry.ExponentialRetry(
91
+ attempts=retries,
92
+ factor=0.0,
93
+ start_timeout=0.0,
94
+ max_timeout=120.0
95
+ )
96
+ )
97
+ else:
98
+ self.retry_client = None
99
+
100
+ async def close(self):
101
+ await self.pool_manager.close()
102
+ if self.retry_client is not None:
103
+ await self.retry_client.close()
104
+
105
+ async def request(
106
+ self,
107
+ method,
108
+ url,
109
+ headers=None,
110
+ body=None,
111
+ post_params=None,
112
+ _request_timeout=None
113
+ ):
114
+ """Execute request
115
+
116
+ :param method: http request method
117
+ :param url: http request url
118
+ :param headers: http request headers
119
+ :param body: request json body, for `application/json`
120
+ :param post_params: request post parameters,
121
+ `application/x-www-form-urlencoded`
122
+ and `multipart/form-data`
123
+ :param _request_timeout: timeout setting for this request. If one
124
+ number provided, it will be total request
125
+ timeout. It can also be a pair (tuple) of
126
+ (connection, read) timeouts.
127
+ """
128
+ method = method.upper()
129
+ assert method in [
130
+ 'GET',
131
+ 'HEAD',
132
+ 'DELETE',
133
+ 'POST',
134
+ 'PUT',
135
+ 'PATCH',
136
+ 'OPTIONS'
137
+ ]
138
+
139
+ if post_params and body:
140
+ raise ApiValueError(
141
+ "body parameter cannot be used with post_params parameter."
142
+ )
143
+
144
+ post_params = post_params or {}
145
+ headers = headers or {}
146
+ # url already contains the URL query string
147
+ timeout = _request_timeout or 5 * 60
148
+
149
+ if 'Content-Type' not in headers:
150
+ headers['Content-Type'] = 'application/json'
151
+
152
+ args = {
153
+ "method": method,
154
+ "url": url,
155
+ "timeout": timeout,
156
+ "headers": headers
157
+ }
158
+
159
+ if self.proxy:
160
+ args["proxy"] = self.proxy
161
+ if self.proxy_headers:
162
+ args["proxy_headers"] = self.proxy_headers
163
+
164
+ # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
165
+ if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
166
+ if re.search('json', headers['Content-Type'], re.IGNORECASE):
167
+ if body is not None:
168
+ body = json.dumps(body)
169
+ args["data"] = body
170
+ elif headers['Content-Type'] == 'application/x-www-form-urlencoded':
171
+ args["data"] = aiohttp.FormData(post_params)
172
+ elif headers['Content-Type'] == 'multipart/form-data':
173
+ # must del headers['Content-Type'], or the correct
174
+ # Content-Type which generated by aiohttp
175
+ del headers['Content-Type']
176
+ data = aiohttp.FormData()
177
+ for param in post_params:
178
+ k, v = param
179
+ if isinstance(v, tuple) and len(v) == 3:
180
+ data.add_field(
181
+ k,
182
+ value=v[1],
183
+ filename=v[0],
184
+ content_type=v[2]
185
+ )
186
+ else:
187
+ data.add_field(k, v)
188
+ args["data"] = data
189
+
190
+ # Pass a `bytes` parameter directly in the body to support
191
+ # other content types than Json when `body` argument is provided
192
+ # in serialized form
193
+ elif isinstance(body, bytes):
194
+ args["data"] = body
195
+ else:
196
+ # Cannot generate the request from given parameters
197
+ msg = """Cannot prepare a request message for provided
198
+ arguments. Please check that your arguments match
199
+ declared content type."""
200
+ raise ApiException(status=0, reason=msg)
201
+
202
+ pool_manager: Union[aiohttp.ClientSession, aiohttp_retry.RetryClient]
203
+ if self.retry_client is not None and method in ALLOW_RETRY_METHODS:
204
+ pool_manager = self.retry_client
205
+ else:
206
+ pool_manager = self.pool_manager
207
+
208
+ r = await pool_manager.request(**args)
209
+
210
+ return RESTResponse(r)
211
+
212
+
213
+
214
+
215
+