|
| 1 | +# SpeakeasySDK |
| 2 | + |
| 3 | +<div align="left"> |
| 4 | + <a href="https://speakeasyapi.dev/"><img src="https://custom-icon-badges.demolab.com/badge/-Built%20By%20Speakeasy-212015?style=for-the-badge&logoColor=FBE331&logo=speakeasy&labelColor=545454" /></a> |
| 5 | + <a href="https://opensource.org/licenses/MIT"> |
| 6 | + <img src="https://img.shields.io/badge/License-MIT-blue.svg" style="width: 100px; height: 28px;" /> |
| 7 | + </a> |
| 8 | +</div> |
| 9 | + |
| 10 | + |
| 11 | +<!-- Start Installation [installation] --> |
| 12 | +## Installation |
| 13 | + |
| 14 | +```bash |
| 15 | +dotnet add package SpeakeasySDK |
| 16 | +``` |
| 17 | +<!-- End Installation [installation] --> |
| 18 | + |
| 19 | +<!-- Start SDK Example Usage [usage] --> |
| 20 | +## SDK Example Usage |
| 21 | + |
| 22 | +### Example |
| 23 | + |
| 24 | +```csharp |
| 25 | +using SpeakeasySDK; |
| 26 | +using SpeakeasySDK.Models.Shared; |
| 27 | +using SpeakeasySDK.Models.Operations; |
| 28 | +using System.Collections.Generic; |
| 29 | + |
| 30 | +var sdk = new SDK(security: new Security() { |
| 31 | + APIKey = "<YOUR_API_KEY_HERE>", |
| 32 | + }); |
| 33 | + |
| 34 | +GetApisRequest req = new GetApisRequest() {}; |
| 35 | + |
| 36 | +var res = await sdk.Apis.GetApisAsync(req); |
| 37 | + |
| 38 | +// handle response |
| 39 | +``` |
| 40 | +<!-- End SDK Example Usage [usage] --> |
| 41 | + |
| 42 | +<!-- Start Available Resources and Operations [operations] --> |
| 43 | +## Available Resources and Operations |
| 44 | + |
| 45 | +- [SDK](https:/github.com/speakeasy-api/speakeasy-client-sdk-csharp/blob/main/github/workspace/repo/docs/sdks/sdk/README.md#available-operations) |
| 46 | +- [Apis](https:/github.com/speakeasy-api/speakeasy-client-sdk-csharp/blob/main/github/workspace/repo/docs/sdks/apis/README.md#available-operations) |
| 47 | +- [ApiEndpoints](https:/github.com/speakeasy-api/speakeasy-client-sdk-csharp/blob/main/github/workspace/repo/docs/sdks/apiendpoints/README.md#available-operations) |
| 48 | +- [Metadata](https:/github.com/speakeasy-api/speakeasy-client-sdk-csharp/blob/main/github/workspace/repo/docs/sdks/metadata/README.md#available-operations) |
| 49 | +- [Schemas](https:/github.com/speakeasy-api/speakeasy-client-sdk-csharp/blob/main/github/workspace/repo/docs/sdks/schemas/README.md#available-operations) |
| 50 | +- [Artifacts](https:/github.com/speakeasy-api/speakeasy-client-sdk-csharp/blob/main/github/workspace/repo/docs/sdks/artifacts/README.md#available-operations) |
| 51 | +- [Auth](https:/github.com/speakeasy-api/speakeasy-client-sdk-csharp/blob/main/github/workspace/repo/docs/sdks/auth/README.md#available-operations) |
| 52 | +- [Requests](https:/github.com/speakeasy-api/speakeasy-client-sdk-csharp/blob/main/github/workspace/repo/docs/sdks/requests/README.md#available-operations) |
| 53 | +- [Github](https:/github.com/speakeasy-api/speakeasy-client-sdk-csharp/blob/main/github/workspace/repo/docs/sdks/github/README.md#available-operations) |
| 54 | +- [Organizations](https:/github.com/speakeasy-api/speakeasy-client-sdk-csharp/blob/main/github/workspace/repo/docs/sdks/organizations/README.md#available-operations) |
| 55 | +- [Reports](https:/github.com/speakeasy-api/speakeasy-client-sdk-csharp/blob/main/github/workspace/repo/docs/sdks/reports/README.md#available-operations) |
| 56 | +- [Suggest](https:/github.com/speakeasy-api/speakeasy-client-sdk-csharp/blob/main/github/workspace/repo/docs/sdks/suggest/README.md#available-operations) |
| 57 | +- [Embeds](https:/github.com/speakeasy-api/speakeasy-client-sdk-csharp/blob/main/github/workspace/repo/docs/sdks/embeds/README.md#available-operations) |
| 58 | +- [Events](https:/github.com/speakeasy-api/speakeasy-client-sdk-csharp/blob/main/github/workspace/repo/docs/sdks/events/README.md#available-operations) |
| 59 | +<!-- End Available Resources and Operations [operations] --> |
| 60 | + |
| 61 | +<!-- Start Global Parameters [global-parameters] --> |
| 62 | +## Global Parameters |
| 63 | + |
| 64 | +## Global Parameters |
| 65 | + |
| 66 | +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. |
| 67 | + |
| 68 | +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. |
| 69 | + |
| 70 | + |
| 71 | +### Available Globals |
| 72 | + |
| 73 | +The following global parameter is available. |
| 74 | + |
| 75 | +| Name | Type | Required | Description | |
| 76 | +| ---- | ---- |:--------:| ----------- | |
| 77 | +| workspaceID | string | | The WorkspaceID parameter. | |
| 78 | + |
| 79 | + |
| 80 | +### Example |
| 81 | + |
| 82 | +```csharp |
| 83 | +using SpeakeasySDK; |
| 84 | +using SpeakeasySDK.Models.Shared; |
| 85 | +using SpeakeasySDK.Models.Operations; |
| 86 | + |
| 87 | +var sdk = new SDK(security: new Security() { |
| 88 | + APIKey = "<YOUR_API_KEY_HERE>", |
| 89 | + }); |
| 90 | + |
| 91 | +GetWorkspaceEventsByTargetRequest req = new GetWorkspaceEventsByTargetRequest() { |
| 92 | + TargetID = "<value>", |
| 93 | +}; |
| 94 | + |
| 95 | +var res = await sdk.Events.GetWorkspaceEventsByTargetAsync(req); |
| 96 | + |
| 97 | +// handle response |
| 98 | +``` |
| 99 | +<!-- End Global Parameters [global-parameters] --> |
| 100 | + |
| 101 | +<!-- Start Retries [retries] --> |
| 102 | +## Retries |
| 103 | + |
| 104 | +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. |
| 105 | + |
| 106 | +To change the default retry strategy for a single API call, simply pass a `RetryConfig` to the call: |
| 107 | +```csharp |
| 108 | +using SpeakeasySDK; |
| 109 | +using SpeakeasySDK.Models.Shared; |
| 110 | +using SpeakeasySDK.Models.Operations; |
| 111 | + |
| 112 | +var sdk = new SDK(security: new Security() { |
| 113 | + APIKey = "<YOUR_API_KEY_HERE>", |
| 114 | + }); |
| 115 | + |
| 116 | +GetWorkspaceAccessRequest req = new GetWorkspaceAccessRequest() {}; |
| 117 | + |
| 118 | +var res = await sdk.Auth.GetWorkspaceAccessAsync(req, |
| 119 | + retryConfig: new RetryConfig( |
| 120 | + strategy: RetryConfig.RetryStrategy.BACKOFF, |
| 121 | + backoff: new BackoffStrategy( |
| 122 | + initialIntervalMs: 1L, |
| 123 | + maxIntervalMs: 50L, |
| 124 | + maxElapsedTimeMs: 100L, |
| 125 | + exponent: 1.1 |
| 126 | + ), |
| 127 | + retryConnectionErrors: false |
| 128 | +)); |
| 129 | + |
| 130 | +// handle response |
| 131 | +``` |
| 132 | + |
| 133 | +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: |
| 134 | +```csharp |
| 135 | +using SpeakeasySDK; |
| 136 | +using SpeakeasySDK.Models.Shared; |
| 137 | +using SpeakeasySDK.Models.Operations; |
| 138 | + |
| 139 | +var sdk = new SDK( |
| 140 | + retryConfig: new RetryConfig( |
| 141 | + strategy: RetryConfig.RetryStrategy.BACKOFF, |
| 142 | + backoff: new BackoffStrategy( |
| 143 | + initialIntervalMs: 1L, |
| 144 | + maxIntervalMs: 50L, |
| 145 | + maxElapsedTimeMs: 100L, |
| 146 | + exponent: 1.1 |
| 147 | + ), |
| 148 | + retryConnectionErrors: false |
| 149 | +), |
| 150 | + security: new Security() { |
| 151 | + APIKey = "<YOUR_API_KEY_HERE>", |
| 152 | + }); |
| 153 | + |
| 154 | +GetWorkspaceAccessRequest req = new GetWorkspaceAccessRequest() {}; |
| 155 | + |
| 156 | +var res = await sdk.Auth.GetWorkspaceAccessAsync(req); |
| 157 | + |
| 158 | +// handle response |
| 159 | +``` |
| 160 | +<!-- End Retries [retries] --> |
| 161 | + |
| 162 | +<!-- Start Error Handling [errors] --> |
| 163 | +## Error Handling |
| 164 | + |
| 165 | +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. |
| 166 | + |
| 167 | +| Error Object | Status Code | Content Type | |
| 168 | +| --------------------------------------- | --------------------------------------- | --------------------------------------- | |
| 169 | +| SpeakeasySDK.Models.Errors.Error | 5XX | application/json | |
| 170 | +| SpeakeasySDK.Models.Errors.SDKException | 4xx-5xx | */* | |
| 171 | + |
| 172 | +### Example |
| 173 | + |
| 174 | +```csharp |
| 175 | +using SpeakeasySDK; |
| 176 | +using SpeakeasySDK.Models.Shared; |
| 177 | +using System; |
| 178 | +using SpeakeasySDK.Models.Errors; |
| 179 | +using SpeakeasySDK.Models.Operations; |
| 180 | + |
| 181 | +var sdk = new SDK(security: new Security() { |
| 182 | + APIKey = "<YOUR_API_KEY_HERE>", |
| 183 | + }); |
| 184 | + |
| 185 | +GetWorkspaceEventsByTargetRequest req = new GetWorkspaceEventsByTargetRequest() { |
| 186 | + TargetID = "<value>", |
| 187 | +}; |
| 188 | + |
| 189 | +try |
| 190 | +{ |
| 191 | + var res = await sdk.Events.GetWorkspaceEventsByTargetAsync(req); |
| 192 | + // handle response |
| 193 | +} |
| 194 | +catch (Exception ex) |
| 195 | +{ |
| 196 | + if (ex is Error) |
| 197 | + { |
| 198 | + // handle exception |
| 199 | + } |
| 200 | + else if (ex is SpeakeasySDK.Models.Errors.SDKException) |
| 201 | + { |
| 202 | + // handle exception |
| 203 | + } |
| 204 | +} |
| 205 | + |
| 206 | +``` |
| 207 | +<!-- End Error Handling [errors] --> |
| 208 | + |
| 209 | +<!-- Start Server Selection [server] --> |
| 210 | +## Server Selection |
| 211 | + |
| 212 | +### Select Server by Name |
| 213 | + |
| 214 | +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: |
| 215 | + |
| 216 | +| Name | Server | Variables | |
| 217 | +| ----- | ------ | --------- | |
| 218 | +| `prod` | `https://api.prod.speakeasyapi.dev` | None | |
| 219 | + |
| 220 | + |
| 221 | + |
| 222 | +### Override Server URL Per-Client |
| 223 | + |
| 224 | +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: |
| 225 | +<!-- End Server Selection [server] --> |
| 226 | + |
| 227 | +<!-- Start Authentication [security] --> |
| 228 | +## Authentication |
| 229 | + |
| 230 | +### Per-Client Security Schemes |
| 231 | + |
| 232 | +This SDK supports the following security schemes globally: |
| 233 | + |
| 234 | +| Name | Type | Scheme | |
| 235 | +| ----------- | ----------- | ----------- | |
| 236 | +| `APIKey` | apiKey | API key | |
| 237 | +| `Bearer` | http | HTTP Bearer | |
| 238 | + |
| 239 | +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: |
| 240 | +```csharp |
| 241 | +using SpeakeasySDK; |
| 242 | +using SpeakeasySDK.Models.Shared; |
| 243 | +using SpeakeasySDK.Models.Operations; |
| 244 | + |
| 245 | +var sdk = new SDK(security: new Security() { |
| 246 | + APIKey = "<YOUR_API_KEY_HERE>", |
| 247 | + }); |
| 248 | + |
| 249 | +DeleteApiRequest req = new DeleteApiRequest() { |
| 250 | + ApiID = "<value>", |
| 251 | + VersionID = "<value>", |
| 252 | +}; |
| 253 | + |
| 254 | +var res = await sdk.Apis.DeleteApiAsync(req); |
| 255 | + |
| 256 | +// handle response |
| 257 | +``` |
| 258 | +<!-- End Authentication [security] --> |
| 259 | + |
| 260 | +<!-- Placeholder for Future Speakeasy SDK Sections --> |
0 commit comments