Rest Adapter
Internal Functions
These functions are meant for use in other parts of the module. You probably shouldn't be calling these manually.
If there's an endpoint method missing from the main FloweryAPI class, you should open an issue (or a pull request).
This module contains the RestAdapter class, which is used to make requests to the Flowery API.
Classes:
Name | Description |
---|---|
RestAdapter |
Underlying class for making HTTP requests. |
Result |
Result returned from low-level RestAdapter. |
Functions:
Name | Description |
---|---|
sanitize_mapping |
Sanitize a mapping by converting all values to strings. |
RestAdapter
Underlying class for making HTTP requests.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config
|
FloweryAPIConfig
|
Configuration object for the FloweryAPI class. |
required |
Methods:
Name | Description |
---|---|
get |
Make a GET request to the Flowery API. You should almost never have to use this directly. |
Source code in pyflowery/rest_adapter.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
get(endpoint, headers=None, params=None, timeout=60)
async
Make a GET request to the Flowery API. You should almost never have to use this directly.
If you need to use this method because an endpoint is missing, please open an issue on the CoastalCommits repository.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint
|
str
|
The endpoint to make the request to. |
required |
headers
|
Mapping[str, str | float | int | bool] | None
|
Headers to send with the request. Note that |
None
|
params
|
Mapping[str, str | float | int | bool] | None
|
Query parameters to send with the request. |
None
|
timeout
|
float
|
Number of seconds to wait for the request to complete. |
60
|
Raises:
Type | Description |
---|---|
TooManyRequests
|
Raised when the Flowery API returns a 429 status code |
ClientError
|
Raised when the Flowery API returns a 4xx status code |
InternalServerError
|
Raised when the Flowery API returns a 5xx status code |
RetryLimitExceeded
|
Raised when the retry limit defined in the |
Returns:
Type | Description |
---|---|
Result | None
|
An object containing the status code, message, and data from the request. |
Source code in pyflowery/rest_adapter.py
Result
Bases: BaseModel
Result returned from low-level RestAdapter.
Attributes:
Name | Type | Description |
---|---|---|
data |
list[dict[str, Any]] | dict[str, Any] | bytes
|
The data returned by the request. |
message |
str
|
Human readable result message from the request. |
raw_response |
ClientResponse | None
|
The raw response object from the request. |
status_code |
int
|
The HTTP status code returned by the request. |
success |
bool
|
Whether or not the request was successful. |
Source code in pyflowery/rest_adapter.py
data = {}
class-attribute
instance-attribute
The data returned by the request.
message = ''
class-attribute
instance-attribute
Human readable result message from the request.
raw_response = None
class-attribute
instance-attribute
The raw response object from the request.
status_code
instance-attribute
The HTTP status code returned by the request.
success
instance-attribute
Whether or not the request was successful.
sanitize_mapping(mapping)
Sanitize a mapping by converting all values to strings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mapping
|
Mapping[str, str | float | int | bool]
|
The mapping to sanitize. |
required |
Returns:
Type | Description |
---|---|
dict[str, str]
|
The sanitized dictionary. |