cliV1 1.0.15__tar.gz
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.
- cliv1-1.0.15/LICENSE +28 -0
- cliv1-1.0.15/MANIFEST.in +2 -0
- cliv1-1.0.15/PKG-INFO +100 -0
- cliv1-1.0.15/README.md +84 -0
- cliv1-1.0.15/apimaticcalculator/__init__.py +12 -0
- cliv1-1.0.15/apimaticcalculator/api_helper.py +19 -0
- cliv1-1.0.15/apimaticcalculator/apimaticcalculator_client.py +63 -0
- cliv1-1.0.15/apimaticcalculator/configuration.py +229 -0
- cliv1-1.0.15/apimaticcalculator/controllers/__init__.py +6 -0
- cliv1-1.0.15/apimaticcalculator/controllers/base_controller.py +67 -0
- cliv1-1.0.15/apimaticcalculator/controllers/simple_calculator_controller.py +69 -0
- cliv1-1.0.15/apimaticcalculator/exceptions/__init__.py +5 -0
- cliv1-1.0.15/apimaticcalculator/exceptions/api_exception.py +36 -0
- cliv1-1.0.15/apimaticcalculator/http/__init__.py +10 -0
- cliv1-1.0.15/apimaticcalculator/http/http_call_back.py +20 -0
- cliv1-1.0.15/apimaticcalculator/http/http_client_provider.py +23 -0
- cliv1-1.0.15/apimaticcalculator/http/http_method_enum.py +25 -0
- cliv1-1.0.15/apimaticcalculator/http/http_request.py +55 -0
- cliv1-1.0.15/apimaticcalculator/http/http_response.py +45 -0
- cliv1-1.0.15/apimaticcalculator/http/proxy_settings.py +50 -0
- cliv1-1.0.15/apimaticcalculator/models/__init__.py +5 -0
- cliv1-1.0.15/apimaticcalculator/models/operation_type_enum.py +51 -0
- cliv1-1.0.15/apimaticcalculator/utilities/__init__.py +6 -0
- cliv1-1.0.15/apimaticcalculator/utilities/file_wrapper.py +45 -0
- cliv1-1.0.15/cliV1.egg-info/PKG-INFO +100 -0
- cliv1-1.0.15/cliV1.egg-info/SOURCES.txt +30 -0
- cliv1-1.0.15/cliV1.egg-info/dependency_links.txt +1 -0
- cliv1-1.0.15/cliV1.egg-info/requires.txt +7 -0
- cliv1-1.0.15/cliV1.egg-info/top_level.txt +3 -0
- cliv1-1.0.15/pyproject.toml +24 -0
- cliv1-1.0.15/setup.cfg +8 -0
cliv1-1.0.15/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
License:
|
|
2
|
+
========
|
|
3
|
+
The MIT License (MIT)
|
|
4
|
+
http://opensource.org/licenses/MIT
|
|
5
|
+
|
|
6
|
+
Copyright (c) 2014 - 2026 APIMATIC Limited
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in
|
|
16
|
+
all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
24
|
+
THE SOFTWARE.
|
|
25
|
+
|
|
26
|
+
Trade Mark:
|
|
27
|
+
==========
|
|
28
|
+
APIMATIC is a trade mark for APIMATIC Limited
|
cliv1-1.0.15/MANIFEST.in
ADDED
cliv1-1.0.15/PKG-INFO
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cliV1
|
|
3
|
+
Version: 1.0.15
|
|
4
|
+
Summary: Simple calculator API hosted on APIMATIC
|
|
5
|
+
Author-email: CLI devs <support@cli.org>
|
|
6
|
+
Requires-Python: >=3.7
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: apimatic-core>=0.2.24,~=0.2.0
|
|
10
|
+
Requires-Dist: apimatic-core-interfaces>=0.1.8,~=0.1.0
|
|
11
|
+
Requires-Dist: apimatic-requests-client-adapter>=0.1.10,~=0.1.0
|
|
12
|
+
Requires-Dist: python-dotenv<2.0,>=0.21
|
|
13
|
+
Provides-Extra: testutils
|
|
14
|
+
Requires-Dist: pytest>=7.2.2; extra == "testutils"
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# Getting Started with APIMATIC Calculator
|
|
19
|
+
|
|
20
|
+
## Introduction
|
|
21
|
+
|
|
22
|
+
Simple calculator API hosted on APIMATIC
|
|
23
|
+
|
|
24
|
+
## Install the Package
|
|
25
|
+
|
|
26
|
+
The package is compatible with Python versions `3.7+`.
|
|
27
|
+
Install the package from PyPi using the following pip command:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install cliV1==1.0.15
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
You can also view the package at:
|
|
34
|
+
https://pypi.python.org/pypi/cliV1/1.0.15
|
|
35
|
+
|
|
36
|
+
## Initialize the API Client
|
|
37
|
+
|
|
38
|
+
**_Note:_** Documentation for the client can be found [here.](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/client.md)
|
|
39
|
+
|
|
40
|
+
The following parameters are configurable for the API Client:
|
|
41
|
+
|
|
42
|
+
| Parameter | Type | Description |
|
|
43
|
+
| --- | --- | --- |
|
|
44
|
+
| http_client_instance | `Union[Session, HttpClientProvider]` | The Http Client passed from the sdk user for making requests |
|
|
45
|
+
| override_http_client_configuration | `bool` | The value which determines to override properties of the passed Http Client from the sdk user |
|
|
46
|
+
| http_call_back | `HttpCallBack` | The callback value that is invoked before and after an HTTP call is made to an endpoint |
|
|
47
|
+
| timeout | `float` | The value to use for connection timeout. <br> **Default: 60** |
|
|
48
|
+
| max_retries | `int` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
|
|
49
|
+
| backoff_factor | `float` | A backoff factor to apply between attempts after the second try. <br> **Default: 2** |
|
|
50
|
+
| retry_statuses | `Array of int` | The http statuses on which retry is to be done. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
|
|
51
|
+
| retry_methods | `Array of string` | The http methods on which retry is to be done. <br> **Default: ["GET", "PUT"]** |
|
|
52
|
+
| proxy_settings | [`ProxySettings`](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/proxy-settings.md) | Optional proxy configuration to route HTTP requests through a proxy server. |
|
|
53
|
+
|
|
54
|
+
The API client can be initialized as follows:
|
|
55
|
+
|
|
56
|
+
### Code-Based Client Initialization
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from apimaticcalculator.apimaticcalculator_client import ApimaticcalculatorClient
|
|
60
|
+
from apimaticcalculator.configuration import Environment
|
|
61
|
+
|
|
62
|
+
client = ApimaticcalculatorClient(
|
|
63
|
+
environment=Environment.PRODUCTION
|
|
64
|
+
)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Environment-Based Client Initialization
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from apimaticcalculator.apimaticcalculator_client import ApimaticcalculatorClient
|
|
71
|
+
|
|
72
|
+
# Specify the path to your .env file if it’s located outside the project’s root directory.
|
|
73
|
+
client = ApimaticcalculatorClient.from_environment(dotenv_path='/path/to/.env')
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
See the [Environment-Based Client Initialization](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/environment-based-client-initialization.md) section for details.
|
|
77
|
+
|
|
78
|
+
## List of APIs
|
|
79
|
+
|
|
80
|
+
* [Simple Calculator](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/controllers/simple-calculator.md)
|
|
81
|
+
|
|
82
|
+
## SDK Infrastructure
|
|
83
|
+
|
|
84
|
+
### Configuration
|
|
85
|
+
|
|
86
|
+
* [ProxySettings](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/proxy-settings.md)
|
|
87
|
+
* [Environment-Based Client Initialization](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/environment-based-client-initialization.md)
|
|
88
|
+
|
|
89
|
+
### HTTP
|
|
90
|
+
|
|
91
|
+
* [HttpResponse](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/http-response.md)
|
|
92
|
+
* [HttpRequest](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/http-request.md)
|
|
93
|
+
|
|
94
|
+
### Utilities
|
|
95
|
+
|
|
96
|
+
* [ApiHelper](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/api-helper.md)
|
|
97
|
+
* [HttpDateTime](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/http-date-time.md)
|
|
98
|
+
* [RFC3339DateTime](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/rfc3339-date-time.md)
|
|
99
|
+
* [UnixDateTime](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/unix-date-time.md)
|
|
100
|
+
|
cliv1-1.0.15/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
|
|
2
|
+
# Getting Started with APIMATIC Calculator
|
|
3
|
+
|
|
4
|
+
## Introduction
|
|
5
|
+
|
|
6
|
+
Simple calculator API hosted on APIMATIC
|
|
7
|
+
|
|
8
|
+
## Install the Package
|
|
9
|
+
|
|
10
|
+
The package is compatible with Python versions `3.7+`.
|
|
11
|
+
Install the package from PyPi using the following pip command:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install cliV1==1.0.15
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
You can also view the package at:
|
|
18
|
+
https://pypi.python.org/pypi/cliV1/1.0.15
|
|
19
|
+
|
|
20
|
+
## Initialize the API Client
|
|
21
|
+
|
|
22
|
+
**_Note:_** Documentation for the client can be found [here.](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/client.md)
|
|
23
|
+
|
|
24
|
+
The following parameters are configurable for the API Client:
|
|
25
|
+
|
|
26
|
+
| Parameter | Type | Description |
|
|
27
|
+
| --- | --- | --- |
|
|
28
|
+
| http_client_instance | `Union[Session, HttpClientProvider]` | The Http Client passed from the sdk user for making requests |
|
|
29
|
+
| override_http_client_configuration | `bool` | The value which determines to override properties of the passed Http Client from the sdk user |
|
|
30
|
+
| http_call_back | `HttpCallBack` | The callback value that is invoked before and after an HTTP call is made to an endpoint |
|
|
31
|
+
| timeout | `float` | The value to use for connection timeout. <br> **Default: 60** |
|
|
32
|
+
| max_retries | `int` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
|
|
33
|
+
| backoff_factor | `float` | A backoff factor to apply between attempts after the second try. <br> **Default: 2** |
|
|
34
|
+
| retry_statuses | `Array of int` | The http statuses on which retry is to be done. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
|
|
35
|
+
| retry_methods | `Array of string` | The http methods on which retry is to be done. <br> **Default: ["GET", "PUT"]** |
|
|
36
|
+
| proxy_settings | [`ProxySettings`](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/proxy-settings.md) | Optional proxy configuration to route HTTP requests through a proxy server. |
|
|
37
|
+
|
|
38
|
+
The API client can be initialized as follows:
|
|
39
|
+
|
|
40
|
+
### Code-Based Client Initialization
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from apimaticcalculator.apimaticcalculator_client import ApimaticcalculatorClient
|
|
44
|
+
from apimaticcalculator.configuration import Environment
|
|
45
|
+
|
|
46
|
+
client = ApimaticcalculatorClient(
|
|
47
|
+
environment=Environment.PRODUCTION
|
|
48
|
+
)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Environment-Based Client Initialization
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from apimaticcalculator.apimaticcalculator_client import ApimaticcalculatorClient
|
|
55
|
+
|
|
56
|
+
# Specify the path to your .env file if it’s located outside the project’s root directory.
|
|
57
|
+
client = ApimaticcalculatorClient.from_environment(dotenv_path='/path/to/.env')
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
See the [Environment-Based Client Initialization](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/environment-based-client-initialization.md) section for details.
|
|
61
|
+
|
|
62
|
+
## List of APIs
|
|
63
|
+
|
|
64
|
+
* [Simple Calculator](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/controllers/simple-calculator.md)
|
|
65
|
+
|
|
66
|
+
## SDK Infrastructure
|
|
67
|
+
|
|
68
|
+
### Configuration
|
|
69
|
+
|
|
70
|
+
* [ProxySettings](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/proxy-settings.md)
|
|
71
|
+
* [Environment-Based Client Initialization](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/environment-based-client-initialization.md)
|
|
72
|
+
|
|
73
|
+
### HTTP
|
|
74
|
+
|
|
75
|
+
* [HttpResponse](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/http-response.md)
|
|
76
|
+
* [HttpRequest](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/http-request.md)
|
|
77
|
+
|
|
78
|
+
### Utilities
|
|
79
|
+
|
|
80
|
+
* [ApiHelper](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/api-helper.md)
|
|
81
|
+
* [HttpDateTime](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/http-date-time.md)
|
|
82
|
+
* [RFC3339DateTime](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/rfc3339-date-time.md)
|
|
83
|
+
* [UnixDateTime](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/unix-date-time.md)
|
|
84
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# ruff: noqa: D104 | Missing docstring in public package
|
|
2
|
+
# ruff: noqa: RUF022 | `__all__` is not sorted
|
|
3
|
+
__all__ = [
|
|
4
|
+
"api_helper",
|
|
5
|
+
"apimaticcalculator_client",
|
|
6
|
+
"configuration",
|
|
7
|
+
"controllers",
|
|
8
|
+
"exceptions",
|
|
9
|
+
"http",
|
|
10
|
+
"models",
|
|
11
|
+
"utilities",
|
|
12
|
+
]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""
|
|
2
|
+
apimaticcalculator
|
|
3
|
+
|
|
4
|
+
This file was automatically generated by APIMATIC v3.0 (
|
|
5
|
+
https://www.apimatic.io ).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from apimatic_core.utilities.api_helper import ApiHelper as CoreApiHelper
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class APIHelper(CoreApiHelper):
|
|
12
|
+
"""
|
|
13
|
+
A Helper Class for various functions associated with API Calls.
|
|
14
|
+
|
|
15
|
+
This class contains static methods for operations that need to be
|
|
16
|
+
performed during API requests. All of the methods inside this class are
|
|
17
|
+
static methods, there is no need to ever initialise an instance of this
|
|
18
|
+
class.
|
|
19
|
+
"""
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""apimaticcalculator.
|
|
2
|
+
|
|
3
|
+
This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
# ruff: noqa: E501
|
|
7
|
+
from apimatic_core.configurations.global_configuration import (
|
|
8
|
+
GlobalConfiguration,
|
|
9
|
+
)
|
|
10
|
+
from apimatic_core.decorators.lazy_property import (
|
|
11
|
+
LazyProperty,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
from apimaticcalculator.configuration import (
|
|
15
|
+
Configuration,
|
|
16
|
+
Environment,
|
|
17
|
+
)
|
|
18
|
+
from apimaticcalculator.controllers.base_controller import (
|
|
19
|
+
BaseController,
|
|
20
|
+
)
|
|
21
|
+
from apimaticcalculator.controllers.simple_calculator_controller import (
|
|
22
|
+
SimpleCalculatorController,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class ApimaticcalculatorClient(object):
|
|
27
|
+
"""Client that provide access to the ApimaticcalculatorClient APIs."""
|
|
28
|
+
|
|
29
|
+
@LazyProperty
|
|
30
|
+
def simple_calculator(self):
|
|
31
|
+
"""Provide access to the SimpleCalculatorController endpoints."""
|
|
32
|
+
return SimpleCalculatorController(self.global_configuration)
|
|
33
|
+
|
|
34
|
+
def __init__(self, http_client_instance=None,
|
|
35
|
+
override_http_client_configuration=False, http_call_back=None,
|
|
36
|
+
timeout=60, max_retries=0, backoff_factor=2,
|
|
37
|
+
retry_statuses=None, retry_methods=None, proxy_settings=None,
|
|
38
|
+
environment=Environment.PRODUCTION, config=None):
|
|
39
|
+
"""Initialize a new instance of ApimaticcalculatorClient."""
|
|
40
|
+
self.config = config or Configuration(
|
|
41
|
+
http_client_instance=http_client_instance,
|
|
42
|
+
override_http_client_configuration=override_http_client_configuration,
|
|
43
|
+
http_call_back=http_call_back, timeout=timeout,
|
|
44
|
+
max_retries=max_retries, backoff_factor=backoff_factor,
|
|
45
|
+
retry_statuses=retry_statuses, retry_methods=retry_methods,
|
|
46
|
+
proxy_settings=proxy_settings, environment=environment)
|
|
47
|
+
|
|
48
|
+
self.global_configuration = GlobalConfiguration(self.config)\
|
|
49
|
+
.global_errors(BaseController.global_errors())\
|
|
50
|
+
.base_uri_executor(self.config.get_base_uri)\
|
|
51
|
+
.user_agent(BaseController.user_agent(),
|
|
52
|
+
BaseController.user_agent_parameters())
|
|
53
|
+
|
|
54
|
+
@classmethod
|
|
55
|
+
def from_environment(cls, dotenv_path=None, **overrides):
|
|
56
|
+
"""Create a client instance using environment variables.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
ApimaticcalculatorClient instance.
|
|
60
|
+
|
|
61
|
+
"""
|
|
62
|
+
return cls(config=Configuration
|
|
63
|
+
.from_environment(dotenv_path=dotenv_path, **overrides))
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"""apimaticcalculator.
|
|
2
|
+
|
|
3
|
+
This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
# ruff: noqa: E501
|
|
7
|
+
import os
|
|
8
|
+
from enum import Enum
|
|
9
|
+
|
|
10
|
+
from apimatic_core.http.configurations.http_client_configuration import (
|
|
11
|
+
HttpClientConfiguration,
|
|
12
|
+
)
|
|
13
|
+
from apimatic_requests_client_adapter.requests_client import (
|
|
14
|
+
RequestsClient,
|
|
15
|
+
)
|
|
16
|
+
from dotenv import load_dotenv
|
|
17
|
+
|
|
18
|
+
from apimaticcalculator.http.proxy_settings import (
|
|
19
|
+
ProxySettings,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class Environment(Enum):
|
|
24
|
+
"""An enum for SDK environments."""
|
|
25
|
+
|
|
26
|
+
# This environment connect to the LIVE calculator API
|
|
27
|
+
PRODUCTION = 0
|
|
28
|
+
|
|
29
|
+
@classmethod
|
|
30
|
+
def from_value(cls, value, default=None):
|
|
31
|
+
"""Convert a value (string or int) to an Environment enum member.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
value (Union[str, int]): The value to convert.
|
|
35
|
+
default (Environment): The fallback enum member if conversion fails.
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
Environment: Matching enum member or fallback if invalid.
|
|
39
|
+
|
|
40
|
+
"""
|
|
41
|
+
if value is None:
|
|
42
|
+
return default
|
|
43
|
+
|
|
44
|
+
# Try to match directly by enum member
|
|
45
|
+
if isinstance(value, cls):
|
|
46
|
+
return value
|
|
47
|
+
|
|
48
|
+
# Handle integer or string conversion
|
|
49
|
+
for member in cls:
|
|
50
|
+
if (str(member.value).lower() == str(value).lower()
|
|
51
|
+
or member.name.lower() == str(value).lower()):
|
|
52
|
+
return member
|
|
53
|
+
|
|
54
|
+
# Fallback to provided default
|
|
55
|
+
return default
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class Server(Enum):
|
|
59
|
+
"""An enum for API servers."""
|
|
60
|
+
|
|
61
|
+
DEFAULT = 0
|
|
62
|
+
|
|
63
|
+
@classmethod
|
|
64
|
+
def from_value(cls, value, default=None):
|
|
65
|
+
"""Convert a value (string or int) to a Server enum member.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
value (Union[str, int]): The value to convert.
|
|
69
|
+
default (Server): The fallback enum member if conversion fails.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
Server: Matching enum member or fallback if invalid.
|
|
73
|
+
|
|
74
|
+
"""
|
|
75
|
+
if value is None:
|
|
76
|
+
return default
|
|
77
|
+
|
|
78
|
+
# Try to match directly by enum member
|
|
79
|
+
if isinstance(value, cls):
|
|
80
|
+
return value
|
|
81
|
+
|
|
82
|
+
# Handle integer or string conversion
|
|
83
|
+
for member in cls:
|
|
84
|
+
if (str(member.value).lower() == str(value).lower()
|
|
85
|
+
or member.name.lower() == str(value).lower()):
|
|
86
|
+
return member
|
|
87
|
+
|
|
88
|
+
# Fallback to provided default
|
|
89
|
+
return default
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class Configuration(HttpClientConfiguration):
|
|
93
|
+
"""A class used for configuring the SDK by a user."""
|
|
94
|
+
|
|
95
|
+
@property
|
|
96
|
+
def environment(self):
|
|
97
|
+
"""Return current environment."""
|
|
98
|
+
return self._environment
|
|
99
|
+
|
|
100
|
+
def __init__(self, http_client_instance=None,
|
|
101
|
+
override_http_client_configuration=False, http_call_back=None,
|
|
102
|
+
timeout=60, max_retries=0, backoff_factor=2, retry_statuses=None,
|
|
103
|
+
retry_methods=None, proxy_settings=None,
|
|
104
|
+
environment=Environment.PRODUCTION):
|
|
105
|
+
"""Initialize Configuration object."""
|
|
106
|
+
if retry_methods is None:
|
|
107
|
+
retry_methods = ["GET", "PUT"]
|
|
108
|
+
|
|
109
|
+
if retry_statuses is None:
|
|
110
|
+
retry_statuses = [408, 413, 429, 500, 502, 503, 504, 521,
|
|
111
|
+
522, 524]
|
|
112
|
+
|
|
113
|
+
super().__init__(
|
|
114
|
+
http_client_instance=http_client_instance,
|
|
115
|
+
override_http_client_configuration=override_http_client_configuration,
|
|
116
|
+
http_call_back=http_call_back, timeout=timeout,
|
|
117
|
+
max_retries=max_retries, backoff_factor=backoff_factor,
|
|
118
|
+
retry_statuses=retry_statuses, retry_methods=retry_methods,
|
|
119
|
+
proxy_settings=proxy_settings,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
# Current API environment
|
|
123
|
+
self._environment = environment
|
|
124
|
+
|
|
125
|
+
# The Http Client to use for making requests.
|
|
126
|
+
self.set_http_client(self.create_http_client())
|
|
127
|
+
|
|
128
|
+
def clone_with(self, http_client_instance=None,
|
|
129
|
+
override_http_client_configuration=None, http_call_back=None,
|
|
130
|
+
timeout=None, max_retries=None, backoff_factor=None,
|
|
131
|
+
retry_statuses=None, retry_methods=None, proxy_settings=None,
|
|
132
|
+
environment=None):
|
|
133
|
+
"""Clone configuration with overrides."""
|
|
134
|
+
http_client_instance = http_client_instance or self.http_client_instance
|
|
135
|
+
override_http_client_configuration =\
|
|
136
|
+
(override_http_client_configuration
|
|
137
|
+
or self.override_http_client_configuration)
|
|
138
|
+
http_call_back = http_call_back or self.http_callback
|
|
139
|
+
timeout = timeout or self.timeout
|
|
140
|
+
max_retries = max_retries or self.max_retries
|
|
141
|
+
backoff_factor = backoff_factor or self.backoff_factor
|
|
142
|
+
retry_statuses = retry_statuses or self.retry_statuses
|
|
143
|
+
retry_methods = retry_methods or self.retry_methods
|
|
144
|
+
proxy_settings = proxy_settings or self.proxy_settings
|
|
145
|
+
environment = environment or self.environment
|
|
146
|
+
return Configuration(
|
|
147
|
+
http_client_instance=http_client_instance,
|
|
148
|
+
override_http_client_configuration=override_http_client_configuration,
|
|
149
|
+
http_call_back=http_call_back, timeout=timeout, max_retries=max_retries,
|
|
150
|
+
backoff_factor=backoff_factor, retry_statuses=retry_statuses,
|
|
151
|
+
retry_methods=retry_methods, proxy_settings=proxy_settings,
|
|
152
|
+
environment=environment,
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
def create_http_client(self):
|
|
156
|
+
"""Create the HTTP client instance."""
|
|
157
|
+
return RequestsClient(
|
|
158
|
+
timeout=self.timeout, max_retries=self.max_retries,
|
|
159
|
+
backoff_factor=self.backoff_factor, retry_statuses=self.retry_statuses,
|
|
160
|
+
retry_methods=self.retry_methods,
|
|
161
|
+
http_client_instance=self.http_client_instance,
|
|
162
|
+
override_http_client_configuration=self.override_http_client_configuration,
|
|
163
|
+
response_factory=self.http_response_factory,
|
|
164
|
+
proxies=self.proxy_settings.to_proxies() if self.proxy_settings else None,
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
# All the environments the SDK can run in
|
|
168
|
+
environments = {
|
|
169
|
+
Environment.PRODUCTION: {
|
|
170
|
+
Server.DEFAULT: "https://examples.apimatic.io/apps/calculator",
|
|
171
|
+
},
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
def get_base_uri(self, server=Server.DEFAULT):
|
|
175
|
+
"""Generate the appropriate base URI for the environment and the server.
|
|
176
|
+
|
|
177
|
+
Args:
|
|
178
|
+
server (Configuration.Server): The server enum for which the base
|
|
179
|
+
URI is required.
|
|
180
|
+
|
|
181
|
+
Returns:
|
|
182
|
+
String: The base URI.
|
|
183
|
+
|
|
184
|
+
"""
|
|
185
|
+
return self.environments[self.environment][server]
|
|
186
|
+
|
|
187
|
+
@classmethod
|
|
188
|
+
def from_environment(cls, dotenv_path=None, **overrides):
|
|
189
|
+
"""Create Configuration object from .env and environment variables.
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
dotenv_path (str, optional): Path to the .env file to load.
|
|
193
|
+
If None, the default .env file is used.
|
|
194
|
+
**overrides: Optional values overriding setting from environment variables.
|
|
195
|
+
|
|
196
|
+
Returns:
|
|
197
|
+
Configuration: A configuration object populated with the resolved values.
|
|
198
|
+
|
|
199
|
+
"""
|
|
200
|
+
# load .env automatically
|
|
201
|
+
load_dotenv(dotenv_path or None, override=True)
|
|
202
|
+
|
|
203
|
+
override_http_client_configuration = os.getenv(
|
|
204
|
+
"OVERRIDE_HTTP_CLIENT_CONFIGURATION", "false").lower() == "true"
|
|
205
|
+
timeout = int(os.getenv("TIMEOUT", "60"))
|
|
206
|
+
max_retries = int(os.getenv("MAX_RETRIES", "0"))
|
|
207
|
+
backoff_factor = float(os.getenv("BACKOFF_FACTOR", "2"))
|
|
208
|
+
statuses = os.getenv("RETRY_STATUSES", None)
|
|
209
|
+
retry_statuses = [int(v.strip()) for v in statuses.split(",")
|
|
210
|
+
if v.strip().isdigit()] if statuses else None
|
|
211
|
+
methods = os.getenv("RETRY_METHODS", None)
|
|
212
|
+
retry_methods = [v.strip() for v in methods.split(",") if v.strip()]\
|
|
213
|
+
if methods else None
|
|
214
|
+
environment = Environment.from_value(
|
|
215
|
+
os.getenv("ENVIRONMENT"), Environment.PRODUCTION)
|
|
216
|
+
|
|
217
|
+
# Preparing default configuration
|
|
218
|
+
default_config = cls(
|
|
219
|
+
override_http_client_configuration=override_http_client_configuration,
|
|
220
|
+
timeout=timeout,
|
|
221
|
+
max_retries=max_retries,
|
|
222
|
+
backoff_factor=backoff_factor,
|
|
223
|
+
retry_statuses=retry_statuses,
|
|
224
|
+
retry_methods=retry_methods,
|
|
225
|
+
environment=environment,
|
|
226
|
+
proxy_settings=ProxySettings.from_environment(),
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
return default_config.clone_with(**overrides)
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""apimaticcalculator.
|
|
2
|
+
|
|
3
|
+
This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from apimatic_core.api_call import ApiCall
|
|
7
|
+
from apimatic_core.types.error_case import ErrorCase
|
|
8
|
+
|
|
9
|
+
from apimaticcalculator.exceptions.api_exception import (
|
|
10
|
+
APIException,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class BaseController(object):
|
|
15
|
+
"""All controllers inherit from this base class.
|
|
16
|
+
|
|
17
|
+
Attributes:
|
|
18
|
+
config (Configuration): The HttpClient which a specific controller
|
|
19
|
+
instance will use. By default all the controller objects share
|
|
20
|
+
the same HttpClient. A user can use his own custom HttpClient
|
|
21
|
+
as well.
|
|
22
|
+
http_call_back (HttpCallBack): An object which holds call back
|
|
23
|
+
methods to be called before and after the execution of an HttpRequest.
|
|
24
|
+
new_api_call_builder (APICall): Returns the API Call builder instance.
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
@staticmethod
|
|
29
|
+
def user_agent():
|
|
30
|
+
"""Return UserAgent value."""
|
|
31
|
+
return "APIMATIC 3.0"
|
|
32
|
+
|
|
33
|
+
@staticmethod
|
|
34
|
+
def user_agent_parameters():
|
|
35
|
+
"""Return UserAgentParameters value."""
|
|
36
|
+
return {
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@staticmethod
|
|
40
|
+
def global_errors():
|
|
41
|
+
"""Return GlobalErrors value."""
|
|
42
|
+
return {
|
|
43
|
+
"default": ErrorCase()
|
|
44
|
+
.error_message("HTTP response not OK.")
|
|
45
|
+
.exception_type(APIException),
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
def __init__(self, config):
|
|
49
|
+
"""Initialize BaseController object."""
|
|
50
|
+
self._config = config.get_http_client_configuration()
|
|
51
|
+
self._http_call_back = self.config.http_callback
|
|
52
|
+
self.api_call = ApiCall(config)
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def config(self):
|
|
56
|
+
"""Return Configuration object."""
|
|
57
|
+
return self._config
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def http_call_back(self):
|
|
61
|
+
"""Return HttpCallBack object."""
|
|
62
|
+
return self._http_call_back
|
|
63
|
+
|
|
64
|
+
@property
|
|
65
|
+
def new_api_call_builder(self):
|
|
66
|
+
"""Return New ApiCallBuilder object."""
|
|
67
|
+
return self.api_call.new_builder
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""apimaticcalculator.
|
|
2
|
+
|
|
3
|
+
This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
# ruff: noqa: D410, E501, E101, D206
|
|
7
|
+
from apimatic_core.request_builder import RequestBuilder
|
|
8
|
+
from apimatic_core.response_handler import ResponseHandler
|
|
9
|
+
from apimatic_core.types.parameter import Parameter
|
|
10
|
+
|
|
11
|
+
from apimaticcalculator.api_helper import APIHelper
|
|
12
|
+
from apimaticcalculator.configuration import (
|
|
13
|
+
Server,
|
|
14
|
+
)
|
|
15
|
+
from apimaticcalculator.controllers.base_controller import (
|
|
16
|
+
BaseController,
|
|
17
|
+
)
|
|
18
|
+
from apimaticcalculator.http.http_method_enum import (
|
|
19
|
+
HttpMethodEnum,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class SimpleCalculatorController(BaseController):
|
|
24
|
+
"""A Controller to access Endpoints in the apimaticcalculator API."""
|
|
25
|
+
|
|
26
|
+
def __init__(self, config):
|
|
27
|
+
"""Initialize SimpleCalculatorController object."""
|
|
28
|
+
super(SimpleCalculatorController, self).__init__(config)
|
|
29
|
+
|
|
30
|
+
def calculate(self,
|
|
31
|
+
operation,
|
|
32
|
+
x,
|
|
33
|
+
y):
|
|
34
|
+
"""Perform a GET request to /{operation}.
|
|
35
|
+
|
|
36
|
+
Calculates the expression using the specified operation.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
operation (OperationTypeEnum): The operator to apply on the variables
|
|
40
|
+
x (float): The LHS value
|
|
41
|
+
y (float): The RHS value
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
float: Response from the API.
|
|
45
|
+
|
|
46
|
+
Raises:
|
|
47
|
+
APIException: When an error occurs while fetching the data from the
|
|
48
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
49
|
+
message, and the HTTP body that was received in the request.
|
|
50
|
+
|
|
51
|
+
"""
|
|
52
|
+
return super().new_api_call_builder.request(
|
|
53
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
54
|
+
.path("/{operation}")
|
|
55
|
+
.http_method(HttpMethodEnum.GET)
|
|
56
|
+
.template_param(Parameter()
|
|
57
|
+
.key("operation")
|
|
58
|
+
.value(operation)
|
|
59
|
+
.should_encode(True))
|
|
60
|
+
.query_param(Parameter()
|
|
61
|
+
.key("x")
|
|
62
|
+
.value(x))
|
|
63
|
+
.query_param(Parameter()
|
|
64
|
+
.key("y")
|
|
65
|
+
.value(y)),
|
|
66
|
+
).response(
|
|
67
|
+
ResponseHandler()
|
|
68
|
+
.deserializer(APIHelper.json_deserialize),
|
|
69
|
+
).execute()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""apimaticcalculator.
|
|
2
|
+
|
|
3
|
+
This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class APIException(Exception):
|
|
8
|
+
"""Class that handles HTTP Exceptions when fetching API Endpoints.
|
|
9
|
+
|
|
10
|
+
Attributes:
|
|
11
|
+
response_code (int): The status code of the response.
|
|
12
|
+
response (HttpResponse): The HttpResponse of the API call.
|
|
13
|
+
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
def __init__(self,
|
|
17
|
+
reason,
|
|
18
|
+
response):
|
|
19
|
+
"""Initialize APIException object.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
reason (string): The reason (or error message) for the Exception
|
|
23
|
+
to be raised.
|
|
24
|
+
response (HttpResponse): The HttpResponse of the API call.
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
super(APIException, self).__init__(reason)
|
|
28
|
+
self.reason = reason
|
|
29
|
+
self.response = response
|
|
30
|
+
self.response_code = response.status_code
|
|
31
|
+
|
|
32
|
+
def __str__(self):
|
|
33
|
+
"""Return a human-readable string representation."""
|
|
34
|
+
return (f"{self.__class__.__name__}("
|
|
35
|
+
f"status_code={self.response_code!s}, "
|
|
36
|
+
f"message={self.reason!s})")
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
"""
|
|
3
|
+
apimaticcalculator
|
|
4
|
+
|
|
5
|
+
This file was automatically generated by APIMATIC v3.0 (
|
|
6
|
+
https://www.apimatic.io ).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from apimatic_core.http.http_callback import HttpCallBack as CoreHttpCallback
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class HttpCallBack(CoreHttpCallback):
|
|
13
|
+
"""
|
|
14
|
+
An interface for the callback to be called before and after the
|
|
15
|
+
HTTP call for an endpoint is made.
|
|
16
|
+
|
|
17
|
+
This class should not be instantiated but should be used as a base class
|
|
18
|
+
for HttpCallBack classes.
|
|
19
|
+
|
|
20
|
+
"""
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""
|
|
2
|
+
apimaticcalculator
|
|
3
|
+
|
|
4
|
+
This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
5
|
+
"""
|
|
6
|
+
from abc import ABC
|
|
7
|
+
|
|
8
|
+
from apimatic_core_interfaces.client.http_client_provider import (
|
|
9
|
+
HttpClientProvider as CoreHttpClientProvider,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class HttpClientProvider(CoreHttpClientProvider, ABC):
|
|
14
|
+
"""
|
|
15
|
+
Defines a contract for providing HTTP client configuration.
|
|
16
|
+
|
|
17
|
+
Classes implementing this interface are expected to supply a configured
|
|
18
|
+
HTTP session and timeout value that will be used by the SDK's internal
|
|
19
|
+
HTTP layer when making network requests.
|
|
20
|
+
|
|
21
|
+
This allows developers to inject their own custom HTTP clients while
|
|
22
|
+
maintaining compatibility with the SDK's request/response handling.
|
|
23
|
+
"""
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
"""
|
|
3
|
+
apimaticcalculator
|
|
4
|
+
|
|
5
|
+
This file was automatically generated by APIMATIC v3.0 (
|
|
6
|
+
https://www.apimatic.io ).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from apimatic_core_interfaces.types.http_method_enum import (
|
|
10
|
+
HttpMethodEnum as CoreHttpMethodEnum,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class HttpMethodEnum(CoreHttpMethodEnum):
|
|
15
|
+
"""
|
|
16
|
+
Enumeration of an HTTP Method
|
|
17
|
+
|
|
18
|
+
Attributes:
|
|
19
|
+
GET: A GET Request
|
|
20
|
+
POST: A POST Request
|
|
21
|
+
PUT: A PUT Request
|
|
22
|
+
PATCH: A PATCH Request
|
|
23
|
+
DELETE: A DELETE Request
|
|
24
|
+
|
|
25
|
+
"""
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
|
|
2
|
+
"""
|
|
3
|
+
apimaticcalculator
|
|
4
|
+
|
|
5
|
+
This file was automatically generated by APIMATIC v3.0 (
|
|
6
|
+
https://www.apimatic.io ).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from apimatic_core.http.request.http_request import HttpRequest as CoreHttpRequest
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class HttpRequest(CoreHttpRequest):
|
|
13
|
+
"""
|
|
14
|
+
Represent an HTTP request to be sent to the server.
|
|
15
|
+
|
|
16
|
+
Encapsulates request details such as the HTTP method, target URL, headers,
|
|
17
|
+
query parameters, body parameters, and any files included with the request.
|
|
18
|
+
|
|
19
|
+
Attributes:
|
|
20
|
+
http_method: The HTTP method to use for the request.
|
|
21
|
+
query_url (str): The URL to which the request will be sent.
|
|
22
|
+
headers (dict[str, str] | None): Headers to include with the request.
|
|
23
|
+
query_parameters (dict[str, str] | None): Query parameters appended
|
|
24
|
+
to the request URL.
|
|
25
|
+
parameters (dict[str, str] | None): Form or body parameters sent
|
|
26
|
+
with the request.
|
|
27
|
+
files (dict | None): Files to be sent with the request.
|
|
28
|
+
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def __init__(self,
|
|
32
|
+
http_method,
|
|
33
|
+
query_url,
|
|
34
|
+
headers=None,
|
|
35
|
+
query_parameters=None,
|
|
36
|
+
parameters=None,
|
|
37
|
+
files=None):
|
|
38
|
+
"""
|
|
39
|
+
Initialize an HttpRequest instance.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
http_method: The HTTP method to use for the request.
|
|
43
|
+
query_url: The URL to which the request will be sent.
|
|
44
|
+
headers: Headers to include with the request.
|
|
45
|
+
query_parameters: Query parameters appended to the request URL.
|
|
46
|
+
parameters: Form or body parameters sent with the request.
|
|
47
|
+
files: Files to be sent with the request.
|
|
48
|
+
|
|
49
|
+
"""
|
|
50
|
+
super().__init__(http_method,
|
|
51
|
+
query_url,
|
|
52
|
+
headers,
|
|
53
|
+
query_parameters,
|
|
54
|
+
parameters,
|
|
55
|
+
files)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
"""
|
|
3
|
+
apimaticcalculator
|
|
4
|
+
|
|
5
|
+
This file was automatically generated by APIMATIC v3.0 (
|
|
6
|
+
https://www.apimatic.io ).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from apimatic_core.http.response.http_response import HttpResponse as CoreHttpResponse
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class HttpResponse(CoreHttpResponse):
|
|
13
|
+
"""
|
|
14
|
+
Represent an HTTP response returned by the server.
|
|
15
|
+
|
|
16
|
+
Stores response metadata such as status code, reason phrase, headers, and
|
|
17
|
+
the raw response body, along with the originating request.
|
|
18
|
+
|
|
19
|
+
Attributes:
|
|
20
|
+
status_code (int): The HTTP status code returned by the server.
|
|
21
|
+
reason_phrase (str): The reason phrase associated with the status code.
|
|
22
|
+
headers (dict[str, str]): Response headers as key-value pairs.
|
|
23
|
+
text (str): The raw response body as a string.
|
|
24
|
+
request: The request object that resulted in this response.
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(self,
|
|
29
|
+
status_code,
|
|
30
|
+
reason_phrase,
|
|
31
|
+
headers,
|
|
32
|
+
text,
|
|
33
|
+
request):
|
|
34
|
+
"""
|
|
35
|
+
Initialize an HttpResponse instance.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
status_code: The HTTP status code returned by the server.
|
|
39
|
+
reason_phrase: The reason phrase associated with the status code.
|
|
40
|
+
headers: Response headers as key-value pairs.
|
|
41
|
+
text: The raw response body as a string.
|
|
42
|
+
request: The request object that resulted in this response.
|
|
43
|
+
|
|
44
|
+
"""
|
|
45
|
+
super().__init__(status_code, reason_phrase, headers, text, request)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""
|
|
2
|
+
apimaticcalculator
|
|
3
|
+
|
|
4
|
+
This file was automatically generated by APIMATIC v3.0 (
|
|
5
|
+
https://www.apimatic.io ).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
from typing import Optional
|
|
10
|
+
|
|
11
|
+
from apimatic_core.http.configurations.proxy_settings import (
|
|
12
|
+
ProxySettings as CoreProxySettings,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class ProxySettings(CoreProxySettings):
|
|
17
|
+
"""A simple data model for configuring HTTP(S) proxy settings."""
|
|
18
|
+
|
|
19
|
+
@classmethod
|
|
20
|
+
def from_environment(cls) -> Optional["ProxySettings"]:
|
|
21
|
+
"""
|
|
22
|
+
Create an instance of this class using environment-based configuration.
|
|
23
|
+
|
|
24
|
+
This method attempts to construct and return an instance using relevant
|
|
25
|
+
environment variables, if available. If the required configuration is
|
|
26
|
+
not present, it may return `None` to indicate that no valid instance
|
|
27
|
+
could be created.
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
Optional[cls]: A configured instance of this class, or `None` if
|
|
31
|
+
configuration data is missing or invalid.
|
|
32
|
+
|
|
33
|
+
"""
|
|
34
|
+
address = os.getenv("PROXY_ADDRESS", None)
|
|
35
|
+
if not address:
|
|
36
|
+
return None
|
|
37
|
+
|
|
38
|
+
port = os.getenv("PROXY_PORT", None)
|
|
39
|
+
if port is not None:
|
|
40
|
+
try:
|
|
41
|
+
port = int(port)
|
|
42
|
+
except (TypeError, ValueError):
|
|
43
|
+
port = None
|
|
44
|
+
|
|
45
|
+
return cls(
|
|
46
|
+
address=address,
|
|
47
|
+
port=port,
|
|
48
|
+
username=os.getenv("PROXY_USERNAME", None),
|
|
49
|
+
password=os.getenv("PROXY_PASSWORD", None),
|
|
50
|
+
)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""apimaticcalculator.
|
|
2
|
+
|
|
3
|
+
This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
# ruff: noqa: E501
|
|
7
|
+
|
|
8
|
+
class OperationTypeEnum(object):
|
|
9
|
+
"""Implementation of the 'OperationType' enum.
|
|
10
|
+
|
|
11
|
+
Possible operators are sum, subtract, multiply, divide
|
|
12
|
+
|
|
13
|
+
Attributes:
|
|
14
|
+
SUM: The enum member of type str.
|
|
15
|
+
SUBTRACT: The enum member of type str.
|
|
16
|
+
MULTIPLY: The enum member of type str.
|
|
17
|
+
DIVIDE: The enum member of type str.
|
|
18
|
+
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
SUM = "SUM"
|
|
22
|
+
|
|
23
|
+
SUBTRACT = "SUBTRACT"
|
|
24
|
+
|
|
25
|
+
MULTIPLY = "MULTIPLY"
|
|
26
|
+
|
|
27
|
+
DIVIDE = "DIVIDE"
|
|
28
|
+
|
|
29
|
+
@classmethod
|
|
30
|
+
def from_value(cls, value, default=None):
|
|
31
|
+
"""Return the matching enum value for the given input."""
|
|
32
|
+
if value is None:
|
|
33
|
+
return default
|
|
34
|
+
|
|
35
|
+
# If numeric and matches directly
|
|
36
|
+
if isinstance(value, int):
|
|
37
|
+
for name, val in cls.__dict__.items():
|
|
38
|
+
if not name.startswith("_") and val == value:
|
|
39
|
+
return val
|
|
40
|
+
|
|
41
|
+
# If string, perform case-insensitive match
|
|
42
|
+
if isinstance(value, str):
|
|
43
|
+
value_lower = value.lower()
|
|
44
|
+
for name, val in cls.__dict__.items():
|
|
45
|
+
if not name.startswith("_") and (
|
|
46
|
+
name.lower() == value_lower or str(val).lower() == value_lower
|
|
47
|
+
):
|
|
48
|
+
return val
|
|
49
|
+
|
|
50
|
+
# Fallback to default
|
|
51
|
+
return default
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""
|
|
2
|
+
apimaticcalculator
|
|
3
|
+
|
|
4
|
+
This file was automatically generated by APIMATIC v3.0 (
|
|
5
|
+
https://www.apimatic.io ).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from apimatic_core.types.file_wrapper import FileWrapper as CoreFileWrapper
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class FileWrapper(CoreFileWrapper):
|
|
12
|
+
"""A wrapper to allow passing in content type for file uploads."""
|
|
13
|
+
|
|
14
|
+
def __init__(self, file, content_type: str="application/octet-stream") -> None:
|
|
15
|
+
"""Initialize a new `FileWrapper` instance.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
file: A readable file-like object or byte stream to wrap.
|
|
19
|
+
content_type (str, optional): The MIME type to associate with the
|
|
20
|
+
file. Defaults to `"application/octet-stream"`.
|
|
21
|
+
|
|
22
|
+
"""
|
|
23
|
+
super().__init__(file, content_type)
|
|
24
|
+
|
|
25
|
+
def __repr__(self) -> str:
|
|
26
|
+
"""Return a detailed string representation of the instance.
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
str: A detailed, unambiguous representation of the wrapper.
|
|
30
|
+
|
|
31
|
+
"""
|
|
32
|
+
return (f"{self.__class__.__name__}("
|
|
33
|
+
f"file={self._file_stream!r}, "
|
|
34
|
+
f"content_type={self.content_type!r})")
|
|
35
|
+
|
|
36
|
+
def __str__(self) -> str:
|
|
37
|
+
"""Return a user-friendly string representation of the instance.
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
str: A concise, readable representation of the wrapper.
|
|
41
|
+
|
|
42
|
+
"""
|
|
43
|
+
return (f"{self.__class__.__name__}("
|
|
44
|
+
f"file={self._file_stream!s}, "
|
|
45
|
+
f"content_type={self.content_type!s})")
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cliV1
|
|
3
|
+
Version: 1.0.15
|
|
4
|
+
Summary: Simple calculator API hosted on APIMATIC
|
|
5
|
+
Author-email: CLI devs <support@cli.org>
|
|
6
|
+
Requires-Python: >=3.7
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Dist: apimatic-core>=0.2.24,~=0.2.0
|
|
10
|
+
Requires-Dist: apimatic-core-interfaces>=0.1.8,~=0.1.0
|
|
11
|
+
Requires-Dist: apimatic-requests-client-adapter>=0.1.10,~=0.1.0
|
|
12
|
+
Requires-Dist: python-dotenv<2.0,>=0.21
|
|
13
|
+
Provides-Extra: testutils
|
|
14
|
+
Requires-Dist: pytest>=7.2.2; extra == "testutils"
|
|
15
|
+
Dynamic: license-file
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# Getting Started with APIMATIC Calculator
|
|
19
|
+
|
|
20
|
+
## Introduction
|
|
21
|
+
|
|
22
|
+
Simple calculator API hosted on APIMATIC
|
|
23
|
+
|
|
24
|
+
## Install the Package
|
|
25
|
+
|
|
26
|
+
The package is compatible with Python versions `3.7+`.
|
|
27
|
+
Install the package from PyPi using the following pip command:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install cliV1==1.0.15
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
You can also view the package at:
|
|
34
|
+
https://pypi.python.org/pypi/cliV1/1.0.15
|
|
35
|
+
|
|
36
|
+
## Initialize the API Client
|
|
37
|
+
|
|
38
|
+
**_Note:_** Documentation for the client can be found [here.](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/client.md)
|
|
39
|
+
|
|
40
|
+
The following parameters are configurable for the API Client:
|
|
41
|
+
|
|
42
|
+
| Parameter | Type | Description |
|
|
43
|
+
| --- | --- | --- |
|
|
44
|
+
| http_client_instance | `Union[Session, HttpClientProvider]` | The Http Client passed from the sdk user for making requests |
|
|
45
|
+
| override_http_client_configuration | `bool` | The value which determines to override properties of the passed Http Client from the sdk user |
|
|
46
|
+
| http_call_back | `HttpCallBack` | The callback value that is invoked before and after an HTTP call is made to an endpoint |
|
|
47
|
+
| timeout | `float` | The value to use for connection timeout. <br> **Default: 60** |
|
|
48
|
+
| max_retries | `int` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
|
|
49
|
+
| backoff_factor | `float` | A backoff factor to apply between attempts after the second try. <br> **Default: 2** |
|
|
50
|
+
| retry_statuses | `Array of int` | The http statuses on which retry is to be done. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
|
|
51
|
+
| retry_methods | `Array of string` | The http methods on which retry is to be done. <br> **Default: ["GET", "PUT"]** |
|
|
52
|
+
| proxy_settings | [`ProxySettings`](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/proxy-settings.md) | Optional proxy configuration to route HTTP requests through a proxy server. |
|
|
53
|
+
|
|
54
|
+
The API client can be initialized as follows:
|
|
55
|
+
|
|
56
|
+
### Code-Based Client Initialization
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from apimaticcalculator.apimaticcalculator_client import ApimaticcalculatorClient
|
|
60
|
+
from apimaticcalculator.configuration import Environment
|
|
61
|
+
|
|
62
|
+
client = ApimaticcalculatorClient(
|
|
63
|
+
environment=Environment.PRODUCTION
|
|
64
|
+
)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Environment-Based Client Initialization
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from apimaticcalculator.apimaticcalculator_client import ApimaticcalculatorClient
|
|
71
|
+
|
|
72
|
+
# Specify the path to your .env file if it’s located outside the project’s root directory.
|
|
73
|
+
client = ApimaticcalculatorClient.from_environment(dotenv_path='/path/to/.env')
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
See the [Environment-Based Client Initialization](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/environment-based-client-initialization.md) section for details.
|
|
77
|
+
|
|
78
|
+
## List of APIs
|
|
79
|
+
|
|
80
|
+
* [Simple Calculator](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/controllers/simple-calculator.md)
|
|
81
|
+
|
|
82
|
+
## SDK Infrastructure
|
|
83
|
+
|
|
84
|
+
### Configuration
|
|
85
|
+
|
|
86
|
+
* [ProxySettings](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/proxy-settings.md)
|
|
87
|
+
* [Environment-Based Client Initialization](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/environment-based-client-initialization.md)
|
|
88
|
+
|
|
89
|
+
### HTTP
|
|
90
|
+
|
|
91
|
+
* [HttpResponse](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/http-response.md)
|
|
92
|
+
* [HttpRequest](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/http-request.md)
|
|
93
|
+
|
|
94
|
+
### Utilities
|
|
95
|
+
|
|
96
|
+
* [ApiHelper](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/api-helper.md)
|
|
97
|
+
* [HttpDateTime](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/http-date-time.md)
|
|
98
|
+
* [RFC3339DateTime](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/rfc3339-date-time.md)
|
|
99
|
+
* [UnixDateTime](https://www.github.com/WasifMatic/acme-python-sdk/tree/1.0.15/doc/unix-date-time.md)
|
|
100
|
+
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
setup.cfg
|
|
6
|
+
apimaticcalculator/__init__.py
|
|
7
|
+
apimaticcalculator/api_helper.py
|
|
8
|
+
apimaticcalculator/apimaticcalculator_client.py
|
|
9
|
+
apimaticcalculator/configuration.py
|
|
10
|
+
apimaticcalculator/controllers/__init__.py
|
|
11
|
+
apimaticcalculator/controllers/base_controller.py
|
|
12
|
+
apimaticcalculator/controllers/simple_calculator_controller.py
|
|
13
|
+
apimaticcalculator/exceptions/__init__.py
|
|
14
|
+
apimaticcalculator/exceptions/api_exception.py
|
|
15
|
+
apimaticcalculator/http/__init__.py
|
|
16
|
+
apimaticcalculator/http/http_call_back.py
|
|
17
|
+
apimaticcalculator/http/http_client_provider.py
|
|
18
|
+
apimaticcalculator/http/http_method_enum.py
|
|
19
|
+
apimaticcalculator/http/http_request.py
|
|
20
|
+
apimaticcalculator/http/http_response.py
|
|
21
|
+
apimaticcalculator/http/proxy_settings.py
|
|
22
|
+
apimaticcalculator/models/__init__.py
|
|
23
|
+
apimaticcalculator/models/operation_type_enum.py
|
|
24
|
+
apimaticcalculator/utilities/__init__.py
|
|
25
|
+
apimaticcalculator/utilities/file_wrapper.py
|
|
26
|
+
cliV1.egg-info/PKG-INFO
|
|
27
|
+
cliV1.egg-info/SOURCES.txt
|
|
28
|
+
cliV1.egg-info/dependency_links.txt
|
|
29
|
+
cliV1.egg-info/requires.txt
|
|
30
|
+
cliV1.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
[project]
|
|
5
|
+
name = "cliV1"
|
|
6
|
+
description = "Simple calculator API hosted on APIMATIC"
|
|
7
|
+
version = "1.0.15"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
keywords = []
|
|
10
|
+
dependencies = ["apimatic-core~=0.2.0, >= 0.2.24", "apimatic-core-interfaces~=0.1.0, >= 0.1.8", "apimatic-requests-client-adapter~=0.1.0, >= 0.1.10", "python-dotenv>=0.21, <2.0"]
|
|
11
|
+
classifiers = []
|
|
12
|
+
requires-python = ">=3.7"
|
|
13
|
+
[[project.authors]]
|
|
14
|
+
name = "CLI devs"
|
|
15
|
+
email = "support@cli.org"
|
|
16
|
+
|
|
17
|
+
[project.urls]
|
|
18
|
+
[project.optional-dependencies]
|
|
19
|
+
testutils = ["pytest>=7.2.2"]
|
|
20
|
+
[tool]
|
|
21
|
+
[tool.setuptools]
|
|
22
|
+
[tool.setuptools.packages]
|
|
23
|
+
[tool.setuptools.packages.find]
|
|
24
|
+
exclude = ["tests", "tests.*"]
|