Skip to content

Commit

Permalink
Merge pull request #10 from speakeasy-sdks/speakeasy-sdk-regen-169958…
Browse files Browse the repository at this point in the history
…1153

chore: 🐝 Update SDK - Generate
  • Loading branch information
2ynn authored Nov 10, 2023
2 parents b8723f9 + 95eb6fe commit 4af851b
Show file tree
Hide file tree
Showing 90 changed files with 1,101 additions and 480 deletions.
Empty file modified .gitattributes
100755 → 100644
Empty file.
348 changes: 340 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,82 @@ pip install git+https://github.com/speakeasy-sdks/template-sdk.git

## SDK Example Usage
<!-- Start SDK Example Usage -->
### Sign in

First you need to send an authentication request to the API by providing your username and password.
In the request body, you should specify the type of token you would like to receive: API key or JSON Web Token.
If your credentials are valid, you will receive a token in the response object: `res.object.token: str`.

```python
import speakeasybar
from speakeasybar.models import operations

s = speakeasybar.Speakeasybar()

req = operations.LoginRequestBody(
type=operations.Type.API_KEY,
)

res = s.authentication.login(req, operations.LoginSecurity(
password="<PASSWORD>",
username="<USERNAME>",
))

if res.object is not None:
# handle response
pass
```

### Browse available drinks

Once you are authenticated, you can use the token you received for all other authenticated endpoints.
For example, you can filter the list of available drinks by type.

```python
import speakeasybar
from speakeasybar.models import operations, shared

s = speakeasybar.Speakeasybar(
security=shared.Security(
api_key="",
api_key="<YOUR_API_KEY>",
),
)


res = s.drinks.list_drinks(drink_type=shared.DrinkType.SPIRIT)

if res.classes is not None:
# handle response
pass
```

### Create an order

When you submit an order, you can include a callback URL along your request.
This URL will get called whenever the supplier updates the status of your order.

```python
import speakeasybar
from speakeasybar.models import callbacks, operations, shared

s = speakeasybar.Speakeasybar(
security=shared.Security(
api_key="<YOUR_API_KEY>",
),
)

res = s.drinks.list_drinks(drink_type=shared.DrinkType.WINE)

if res.drinks is not None:
res = s.orders.create_order(request_body=[
shared.OrderInput(
product_code='APM-1F2D3',
quantity=26535,
type=shared.OrderType.DRINK,
),
], callback_url='string')

if res.order is not None:
# handle response
pass
```
<!-- End SDK Example Usage -->

Expand All @@ -89,11 +150,7 @@ if res.drinks is not None:

### [authentication](docs/sdks/authentication/README.md)

* [authenticate](docs/sdks/authentication/README.md#authenticate) - Authenticate with the API by providing a username and password.

### [config](docs/sdks/config/README.md)

* [subscribe_to_webhooks](docs/sdks/config/README.md#subscribe_to_webhooks) - Subscribe to webhooks.
* [login](docs/sdks/authentication/README.md#login) - Authenticate with the API by providing a username and password.

### [drinks](docs/sdks/drinks/README.md)

Expand All @@ -107,8 +164,283 @@ if res.drinks is not None:
### [orders](docs/sdks/orders/README.md)

* [create_order](docs/sdks/orders/README.md#create_order) - Create an order.

### [config](docs/sdks/config/README.md)

* [subscribe_to_webhooks](docs/sdks/config/README.md#subscribe_to_webhooks) - Subscribe to webhooks.
<!-- End SDK Available Operations -->



<!-- Start Retries -->
## Retries

Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.

To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
```python
import speakeasybar
from speakeasybar.models import operations, shared

s = speakeasybar.Speakeasybar(
security=shared.Security(
api_key="<YOUR_API_KEY>",
),
)

req = [
operations.RequestBody(),
]

res = s.config.subscribe_to_webhooks(req)

if res.status_code == 200:
# handle response
pass
```

If you'd like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
```python
import speakeasybar
from speakeasybar.models import operations, shared

s = speakeasybar.Speakeasybar(
retry_config=RetryConfig('backoff', BackoffStrategy(1, 50, 1.1, 100), False)
security=shared.Security(
api_key="<YOUR_API_KEY>",
),
)

req = [
operations.RequestBody(),
]

res = s.config.subscribe_to_webhooks(req)

if res.status_code == 200:
# handle response
pass
```
<!-- End Retries -->



<!-- Start Error Handling -->
## Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an error. If Error objects are specified in your OpenAPI Spec, the SDK will raise the appropriate Error type.

| Error Object | Status Code | Content Type |
| ---------------- | ---------------- | ---------------- |
| errors.APIError | 5XX | application/json |
| errors.SDKError | 400-600 | */* |

### Example

```python
import speakeasybar
from speakeasybar.models import operations, shared

s = speakeasybar.Speakeasybar(
security=shared.Security(
api_key="<YOUR_API_KEY>",
),
)

req = [
operations.RequestBody(),
]

res = None
try:
res = s.config.subscribe_to_webhooks(req)

except (errors.APIError) as e:
print(e) # handle exception
except (errors.SDKError) as e:
print(e) # handle exception


if res.status_code == 200:
# handle response
pass
```

<!-- End Error Handling -->



<!-- Start Server Selection -->
## Server Selection

### Select Server by Name

You can override the default server globally by passing a server name to the `server: str` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:

| Name | Server | Variables |
| ----- | ------ | --------- |
| `prod` | `https://speakeasy.bar` | None |
| `staging` | `https://staging.speakeasy.bar` | None |
| `customer` | `https://{organization}.{environment}.speakeasy.bar` | `environment` (default is `prod`), `organization` (default is `api`) |
#### Example

```python
import speakeasybar
from speakeasybar.models import operations

s = speakeasybar.Speakeasybar(
server="customer",
)

req = operations.LoginRequestBody(
type=operations.Type.API_KEY,
)

res = s.authentication.login(req, operations.LoginSecurity(
password="<PASSWORD>",
username="<USERNAME>",
))

if res.object is not None:
# handle response
pass
```

#### Variables

Some of the server options above contain variables. If you want to set the values of those variables, the following optional parameters are available when initializing the SDK client instance:
* `environment: models.ServerEnvironment`
* `organization: str`

### Override Server URL Per-Client

The default server can also be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
```python
import speakeasybar
from speakeasybar.models import operations

s = speakeasybar.Speakeasybar(
server_url="https://speakeasy.bar",
)

req = operations.LoginRequestBody(
type=operations.Type.API_KEY,
)

res = s.authentication.login(req, operations.LoginSecurity(
password="<PASSWORD>",
username="<USERNAME>",
))

if res.object is not None:
# handle response
pass
```

### Override Server URL Per-Operation

The server URL can also be overridden on a per-operation basis, provided a server list was specified for the operation. For example:
```python
import speakeasybar
from speakeasybar.models import operations, shared

s = speakeasybar.Speakeasybar(
security=shared.Security(
api_key="<YOUR_API_KEY>",
),
)


res = s.drinks.list_drinks(server_url="https://speakeasy.bar", drink_type=shared.DrinkType.SPIRIT)

if res.classes is not None:
# handle response
pass
```
<!-- End Server Selection -->



<!-- Start Custom HTTP Client -->
## Custom HTTP Client

The Python SDK makes API calls using the (requests)[https://pypi.org/project/requests/] HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with a custom `requests.Session` object.

For example, you could specify a header for every request that this sdk makes as follows:
```python
import speakeasybar
import requests

http_client = requests.Session()
http_client.headers.update({'x-custom-header': 'someValue'})
s = speakeasybar.Speakeasybar(client: http_client)
```
<!-- End Custom HTTP Client -->



<!-- Start Authentication -->

## Authentication

### Per-Client Security Schemes

This SDK supports the following security schemes globally:

| Name | Type | Scheme |
| ------------- | ------------- | ------------- |
| `api_key` | apiKey | API key |
| `bearer_auth` | http | HTTP Bearer |

You can set the security parameters through the `security` optional parameter when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:
```python
import speakeasybar
from speakeasybar.models import operations, shared

s = speakeasybar.Speakeasybar(
security=shared.Security(
api_key="<YOUR_API_KEY>",
),
)


res = s.ingredients.list_ingredients(ingredients=[
'string',
])

if res.classes is not None:
# handle response
pass
```

### Per-Operation Security Schemes

Some operations in this SDK require the security scheme to be specified at the request level. For example:
```python
import speakeasybar
from speakeasybar.models import operations, shared

s = speakeasybar.Speakeasybar(
security=shared.Security(
api_key="<YOUR_API_KEY>",
),
)


res = s.ingredients.list_ingredients(ingredients=[
'string',
])

if res.classes is not None:
# handle response
pass
```
<!-- End Authentication -->

<!-- Placeholder for Future Speakeasy SDK Sections -->



### Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
Expand Down
10 changes: 9 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,12 @@ Based on:
- OpenAPI Doc 1.0.0
- Speakeasy CLI 1.78.8 (2.96.6) https://github.com/speakeasy-api/speakeasy
### Generated
- [python v1.26.0] .
- [python v1.26.0] .

## 2023-11-10 01:52:30
### Changes
Based on:
- OpenAPI Doc 1.0.0
- Speakeasy CLI 1.118.3 (2.187.7) https://github.com/speakeasy-api/speakeasy
### Generated
- [python v2.0.0] .
Loading

0 comments on commit 4af851b

Please sign in to comment.