|
| 1 | +# Speakeasy |
| 2 | + |
| 3 | +<!-- Start SDK Installation [installation] --> |
| 4 | +## SDK Installation |
| 5 | + |
| 6 | +### Nuget |
| 7 | + |
| 8 | +```bash |
| 9 | +dotnet add package Speakeasy.Client.SDK |
| 10 | +``` |
| 11 | +<!-- End SDK Installation [installation] --> |
| 12 | + |
| 13 | +<!-- Start SDK Example Usage [usage] --> |
| 14 | +## SDK Example Usage |
| 15 | + |
| 16 | +### Example |
| 17 | + |
| 18 | +```csharp |
| 19 | +using Speakeasy.Client.SDK; |
| 20 | +using Speakeasy.Client.SDK.Models.Shared; |
| 21 | +using Speakeasy.Client.SDK.Models.Operations; |
| 22 | +using System.Collections.Generic; |
| 23 | + |
| 24 | +var sdk = new SpeakeasySDK(security: new Security() { |
| 25 | + APIKey = "<YOUR_API_KEY_HERE>", |
| 26 | + }); |
| 27 | + |
| 28 | +GetApisRequest req = new GetApisRequest() {}; |
| 29 | + |
| 30 | +var res = await sdk.Apis.GetApisAsync(req); |
| 31 | + |
| 32 | +// handle response |
| 33 | +``` |
| 34 | +<!-- End SDK Example Usage [usage] --> |
| 35 | + |
| 36 | +<!-- Start Server Selection [server] --> |
| 37 | +## Server Selection |
| 38 | + |
| 39 | +### Select Server by Name |
| 40 | + |
| 41 | +You can override the default server globally by passing a server name to the `server: string` 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: |
| 42 | + |
| 43 | +| Name | Server | Variables | |
| 44 | +| ----- | ------ | --------- | |
| 45 | +| `prod` | `https://api.prod.speakeasyapi.dev` | None | |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +### Override Server URL Per-Client |
| 50 | + |
| 51 | +The default server can also be overridden globally by passing a URL to the `serverUrl: str` optional parameter when initializing the SDK client instance. For example: |
| 52 | +<!-- End Server Selection [server] --> |
| 53 | + |
| 54 | +<!-- Start Authentication [security] --> |
| 55 | +## Authentication |
| 56 | + |
| 57 | +### Per-Client Security Schemes |
| 58 | + |
| 59 | +This SDK supports the following security schemes globally: |
| 60 | + |
| 61 | +| Name | Type | Scheme | |
| 62 | +| ----------- | ----------- | ----------- | |
| 63 | +| `APIKey` | apiKey | API key | |
| 64 | +| `Bearer` | http | HTTP Bearer | |
| 65 | + |
| 66 | +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: |
| 67 | +```csharp |
| 68 | +using Speakeasy.Client.SDK; |
| 69 | +using Speakeasy.Client.SDK.Models.Shared; |
| 70 | +using Speakeasy.Client.SDK.Models.Operations; |
| 71 | + |
| 72 | +var sdk = new SpeakeasySDK(security: new Security() { |
| 73 | + APIKey = "<YOUR_API_KEY_HERE>", |
| 74 | + }); |
| 75 | + |
| 76 | +DeleteApiRequest req = new DeleteApiRequest() { |
| 77 | + ApiID = "<value>", |
| 78 | + VersionID = "<value>", |
| 79 | +}; |
| 80 | + |
| 81 | +var res = await sdk.Apis.DeleteApiAsync(req); |
| 82 | + |
| 83 | +// handle response |
| 84 | +``` |
| 85 | +<!-- End Authentication [security] --> |
| 86 | + |
| 87 | +<!-- Start Global Parameters [global-parameters] --> |
| 88 | +## Global Parameters |
| 89 | + |
| 90 | +## Global Parameters |
| 91 | + |
| 92 | +A parameter is configured globally. This parameter may be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, This global value will be used as the default on the operations that use it. When such operations are called, there is a place in each to override the global value, if needed. |
| 93 | + |
| 94 | +For example, you can set `workspaceID` to `"<value>"` at SDK initialization and then you do not have to pass the same value on calls to operations like `GetWorkspaceEventsByTarget`. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration. |
| 95 | + |
| 96 | + |
| 97 | +### Available Globals |
| 98 | + |
| 99 | +The following global parameter is available. |
| 100 | + |
| 101 | +| Name | Type | Required | Description | |
| 102 | +| ---- | ---- |:--------:| ----------- | |
| 103 | +| workspaceID | string | | The WorkspaceID parameter. | |
| 104 | + |
| 105 | + |
| 106 | +### Example |
| 107 | + |
| 108 | +```csharp |
| 109 | +using Speakeasy.Client.SDK; |
| 110 | +using Speakeasy.Client.SDK.Models.Shared; |
| 111 | +using Speakeasy.Client.SDK.Models.Operations; |
| 112 | + |
| 113 | +var sdk = new SpeakeasySDK(security: new Security() { |
| 114 | + APIKey = "<YOUR_API_KEY_HERE>", |
| 115 | + }); |
| 116 | + |
| 117 | +GetWorkspaceEventsByTargetRequest req = new GetWorkspaceEventsByTargetRequest() { |
| 118 | + TargetID = "<value>", |
| 119 | +}; |
| 120 | + |
| 121 | +var res = await sdk.Events.GetWorkspaceEventsByTargetAsync(req); |
| 122 | + |
| 123 | +// handle response |
| 124 | +``` |
| 125 | +<!-- End Global Parameters [global-parameters] --> |
| 126 | + |
| 127 | +<!-- Start Error Handling [errors] --> |
| 128 | +## Error Handling |
| 129 | + |
| 130 | +Handling errors in this SDK should largely match your expectations. All operations return a response object or thow an exception. If Error objects are specified in your OpenAPI Spec, the SDK will raise the appropriate type. |
| 131 | + |
| 132 | +| Error Object | Status Code | Content Type | |
| 133 | +| ----------------------------------------------- | ----------------------------------------------- | ----------------------------------------------- | |
| 134 | +| Speakeasy.Client.SDK.Models.Errors.Error | 5XX | application/json | |
| 135 | +| Speakeasy.Client.SDK.Models.Errors.SDKException | 4xx-5xx | */* | |
| 136 | + |
| 137 | +### Example |
| 138 | + |
| 139 | +```csharp |
| 140 | +using Speakeasy.Client.SDK; |
| 141 | +using Speakeasy.Client.SDK.Models.Shared; |
| 142 | +using System; |
| 143 | +using Speakeasy.Client.SDK.Models.Errors; |
| 144 | +using Speakeasy.Client.SDK.Models.Operations; |
| 145 | + |
| 146 | +var sdk = new SpeakeasySDK(security: new Security() { |
| 147 | + APIKey = "<YOUR_API_KEY_HERE>", |
| 148 | + }); |
| 149 | + |
| 150 | +GetWorkspaceEventsByTargetRequest req = new GetWorkspaceEventsByTargetRequest() { |
| 151 | + TargetID = "<value>", |
| 152 | +}; |
| 153 | + |
| 154 | +try |
| 155 | +{ |
| 156 | + var res = await sdk.Events.GetWorkspaceEventsByTargetAsync(req); |
| 157 | + // handle response |
| 158 | +} |
| 159 | +catch (Exception ex) |
| 160 | +{ |
| 161 | + if (ex is Error) |
| 162 | + { |
| 163 | + // handle exception |
| 164 | + } |
| 165 | + else if (ex is Speakeasy.Client.SDK.Models.Errors.SDKException) |
| 166 | + { |
| 167 | + // handle exception |
| 168 | + } |
| 169 | +} |
| 170 | + |
| 171 | +``` |
| 172 | +<!-- End Error Handling [errors] --> |
| 173 | + |
| 174 | +<!-- Start Retries [retries] --> |
| 175 | +## Retries |
| 176 | + |
| 177 | +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. |
| 178 | + |
| 179 | +To change the default retry strategy for a single API call, simply pass a `RetryConfig` to the call: |
| 180 | +```csharp |
| 181 | +using Speakeasy.Client.SDK; |
| 182 | +using Speakeasy.Client.SDK.Models.Shared; |
| 183 | +using Speakeasy.Client.SDK.Models.Operations; |
| 184 | + |
| 185 | +var sdk = new SpeakeasySDK(security: new Security() { |
| 186 | + APIKey = "<YOUR_API_KEY_HERE>", |
| 187 | + }); |
| 188 | + |
| 189 | +GetWorkspaceAccessRequest req = new GetWorkspaceAccessRequest() {}; |
| 190 | + |
| 191 | +var res = await sdk.Auth.GetWorkspaceAccessAsync(req, |
| 192 | + retryConfig: new RetryConfig( |
| 193 | + strategy: RetryConfig.RetryStrategy.BACKOFF, |
| 194 | + backoff: new BackoffStrategy( |
| 195 | + initialIntervalMs: 1L, |
| 196 | + maxIntervalMs: 50L, |
| 197 | + maxElapsedTimeMs: 100L, |
| 198 | + exponent: 1.1 |
| 199 | + ), |
| 200 | + retryConnectionErrors: false |
| 201 | +)); |
| 202 | + |
| 203 | +// handle response |
| 204 | +``` |
| 205 | + |
| 206 | +If you'd like to override the default retry strategy for all operations that support retries, you can use the `RetryConfig` optional parameter when intitializing the SDK: |
| 207 | +```csharp |
| 208 | +using Speakeasy.Client.SDK; |
| 209 | +using Speakeasy.Client.SDK.Models.Shared; |
| 210 | +using Speakeasy.Client.SDK.Models.Operations; |
| 211 | + |
| 212 | +var sdk = new SpeakeasySDK( |
| 213 | + retryConfig: new RetryConfig( |
| 214 | + strategy: RetryConfig.RetryStrategy.BACKOFF, |
| 215 | + backoff: new BackoffStrategy( |
| 216 | + initialIntervalMs: 1L, |
| 217 | + maxIntervalMs: 50L, |
| 218 | + maxElapsedTimeMs: 100L, |
| 219 | + exponent: 1.1 |
| 220 | + ), |
| 221 | + retryConnectionErrors: false |
| 222 | +), |
| 223 | + security: new Security() { |
| 224 | + APIKey = "<YOUR_API_KEY_HERE>", |
| 225 | + }); |
| 226 | + |
| 227 | +GetWorkspaceAccessRequest req = new GetWorkspaceAccessRequest() {}; |
| 228 | + |
| 229 | +var res = await sdk.Auth.GetWorkspaceAccessAsync(req); |
| 230 | + |
| 231 | +// handle response |
| 232 | +``` |
| 233 | +<!-- End Retries [retries] --> |
| 234 | + |
| 235 | +<!-- Placeholder for Future Speakeasy SDK Sections --> |
| 236 | + |
| 237 | + |
| 238 | + |
| 239 | +### Maturity |
| 240 | + |
| 241 | +This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage |
| 242 | +to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally |
| 243 | +looking for the latest version. |
| 244 | + |
| 245 | +### Contributions |
| 246 | + |
| 247 | +While we value open-source contributions to this SDK, this library is generated programmatically. |
| 248 | +Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release! |
| 249 | + |
| 250 | +### SDK Created by [Speakeasy](https://docs.speakeasyapi.dev/docs/using-speakeasy/client-sdks) |
0 commit comments