Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
.DS_Store
**/.speakeasy/temp/
**/.speakeasy/logs/
.env
.env.local
obj/
bin/
debug/
.idea/
.idea/
1,278 changes: 484 additions & 794 deletions .speakeasy/gen.lock

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
speakeasyVersion: 1.468.2
speakeasyVersion: 1.635.1
sources:
speakeasy:
sourceNamespace: speakeasy
sourceRevisionDigest: sha256:8af7ebde12785185cdbd700c1b3b6b8848b43d34f1fe8c06fff5ae4af471faf2
sourceBlobDigest: sha256:952a58da1511e3191ea8e470c7f01a4e3785d11d9152f490a3e5a7173c8542e7
sourceRevisionDigest: sha256:9128c3df436950ca04fec9dfc74e769e8b492d434b115b197d68da656ae17d23
sourceBlobDigest: sha256:6eb8a6e215c36d3e11d86fc67d5ce7af499bdb934e0f7fbad17efcdde9bffd73
tags:
- latest
- speakeasy-sdk-regen-1735949986
- speakeasy-sdk-regen-1758759731
- 0.4.0
targets:
speakeasy-client-sdk-csharp:
source: speakeasy
sourceNamespace: speakeasy
sourceRevisionDigest: sha256:8af7ebde12785185cdbd700c1b3b6b8848b43d34f1fe8c06fff5ae4af471faf2
sourceBlobDigest: sha256:952a58da1511e3191ea8e470c7f01a4e3785d11d9152f490a3e5a7173c8542e7
sourceRevisionDigest: sha256:9128c3df436950ca04fec9dfc74e769e8b492d434b115b197d68da656ae17d23
sourceBlobDigest: sha256:6eb8a6e215c36d3e11d86fc67d5ce7af499bdb934e0f7fbad17efcdde9bffd73
codeSamplesNamespace: code-samples-csharp-speakeasy-client-sdk-csharp
codeSamplesRevisionDigest: sha256:aacf508e82244f7628670bda7c73bdda3a36059c4143c3566f2b4d4935251ec8
codeSamplesRevisionDigest: sha256:73a1bd33625310d6f545cf922b4c33b1c22d12d614dc0346b9446b6ceac30c8e
workflow:
workflowVersion: 1.0.0
speakeasyVersion: latest
Expand Down
26 changes: 26 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Contributing to This Repository

Thank you for your interest in contributing to this repository. Please note that this repository contains generated code. As such, we do not accept direct changes or pull requests. Instead, we encourage you to follow the guidelines below to report issues and suggest improvements.

## How to Report Issues

If you encounter any bugs or have suggestions for improvements, please open an issue on GitHub. When reporting an issue, please provide as much detail as possible to help us reproduce the problem. This includes:

- A clear and descriptive title
- Steps to reproduce the issue
- Expected and actual behavior
- Any relevant logs, screenshots, or error messages
- Information about your environment (e.g., operating system, software versions)
- For example can be collected using the `npx envinfo` command from your terminal if you have Node.js installed

## Issue Triage and Upstream Fixes

We will review and triage issues as quickly as possible. Our goal is to address bugs and incorporate improvements in the upstream source code. Fixes will be included in the next generation of the generated code.

## Contact

If you have any questions or need further assistance, please feel free to reach out by opening an issue.

Thank you for your understanding and cooperation!

The Maintainers
144 changes: 61 additions & 83 deletions NUGET.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,12 @@
```csharp
using SpeakeasySDK;
using SpeakeasySDK.Models.Shared;
using System.Collections.Generic;

var sdk = new SDK(security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
});

RemoteSource req = new RemoteSource() {
Inputs = new List<RemoteDocument>() {
new RemoteDocument() {
RegistryUrl = "https://productive-swine.net",
},
},
Output = new RemoteDocument() {
RegistryUrl = "https://spiteful-apricot.info",
},
};
RemoteSource? req = null;

var res = await sdk.Artifacts.CreateRemoteSourceAsync(req);

Expand All @@ -49,22 +39,12 @@ You can set the security parameters through the `security` optional parameter wh
```csharp
using SpeakeasySDK;
using SpeakeasySDK.Models.Shared;
using System.Collections.Generic;

var sdk = new SDK(security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
});

RemoteSource req = new RemoteSource() {
Inputs = new List<RemoteDocument>() {
new RemoteDocument() {
RegistryUrl = "https://productive-swine.net",
},
},
Output = new RemoteDocument() {
RegistryUrl = "https://spiteful-apricot.info",
},
};
RemoteSource? req = null;

var res = await sdk.Artifacts.CreateRemoteSourceAsync(req);

Expand Down Expand Up @@ -94,7 +74,7 @@ The following global parameter is available.
using SpeakeasySDK;
using SpeakeasySDK.Models.Operations;

var sdk = new SDK();
var sdk = new SDK(workspaceId: "<id>");

GetAccessTokenRequest req = new GetAccessTokenRequest() {
WorkspaceId = "<id>",
Expand All @@ -121,7 +101,7 @@ var sdk = new SDK(security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
});

GetWorkspaceAccessRequest req = new GetWorkspaceAccessRequest() {};
GetWorkspaceAccessRequest? req = null;

var res = await sdk.Auth.GetAccessAsync(
retryConfig: new RetryConfig(
Expand Down Expand Up @@ -162,7 +142,7 @@ var sdk = new SDK(
}
);

GetWorkspaceAccessRequest req = new GetWorkspaceAccessRequest() {};
GetWorkspaceAccessRequest? req = null;

var res = await sdk.Auth.GetAccessAsync(req);

Expand All @@ -173,67 +153,85 @@ var res = await sdk.Auth.GetAccessAsync(req);
<!-- Start Error Handling [errors] -->
## Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or throw an exception.

By default, an API error will raise a `SpeakeasySDK.Models.Errors.SDKException` exception, which has the following properties:
[`SDKBaseException`](./src/SpeakeasySDK/Models/Errors/SDKBaseException.cs) is the base exception class for all HTTP error responses. It has the following properties:

| Property | Type | Description |
|---------------|-----------------------|-----------------------|
| `Message` | *string* | The error message |
| `StatusCode` | *int* | The HTTP status code |
| `RawResponse` | *HttpResponseMessage* | The raw HTTP response |
| `Body` | *string* | The response content |
| `Message` | *string* | Error message |
| `StatusCode` | *int* | HTTP status code |
| `Headers` | *HttpResponseHeaders* | HTTP headers |
| `ContentType` | *string?* | HTTP content type |
| `RawResponse` | *HttpResponseMessage* | HTTP response object |
| `Body` | *string* | HTTP response body |

When custom error responses are specified for an operation, the SDK may also throw their associated exceptions. You can refer to respective *Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the `CreateRemoteSourceAsync` method throws the following exceptions:

| Error Type | Status Code | Content Type |
| --------------------------------------- | ----------- | ---------------- |
| SpeakeasySDK.Models.Errors.Error | 4XX | application/json |
| SpeakeasySDK.Models.Errors.SDKException | 5XX | \*/\* |
Some exceptions in this SDK include an additional `Payload` field, which will contain deserialized custom error data when present. Possible exceptions are listed in the [Error Classes](#error-classes) section.

### Example

```csharp
using SpeakeasySDK;
using SpeakeasySDK.Models.Errors;
using SpeakeasySDK.Models.Shared;
using System.Collections.Generic;

var sdk = new SDK(security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
});

try
{
RemoteSource req = new RemoteSource() {
Inputs = new List<RemoteDocument>() {
new RemoteDocument() {
RegistryUrl = "https://productive-swine.net",
},
},
Output = new RemoteDocument() {
RegistryUrl = "https://spiteful-apricot.info",
},
};
RemoteSource? req = null;

var res = await sdk.Artifacts.CreateRemoteSourceAsync(req);

// handle response
}
catch (Exception ex)
catch (SDKBaseException ex) // all SDK exceptions inherit from SDKBaseException
{
if (ex is Error)
// ex.ToString() provides a detailed error message
System.Console.WriteLine(ex);

// Base exception fields
HttpResponseMessage rawResponse = ex.RawResponse;
HttpResponseHeaders headers = ex.Headers;
int statusCode = ex.StatusCode;
string? contentType = ex.ContentType;
var responseBody = ex.Body;

if (ex is Error) // different exceptions may be thrown depending on the method
{
// Handle exception data
throw;
// Check error data fields
ErrorPayload payload = ex.Payload;
string Message = payload.Message;
int StatusCode = payload.StatusCode;
}
else if (ex is SpeakeasySDK.Models.Errors.SDKException)

// An underlying cause may be provided
if (ex.InnerException != null)
{
// Handle default exception
throw;
Exception cause = ex.InnerException;
}
}
catch (System.Net.Http.HttpRequestException ex)
{
// Check ex.InnerException for Network connectivity errors
}
```

### Error Classes

**Primary exceptions:**
* [`SDKBaseException`](./src/SpeakeasySDK/Models/Errors/SDKBaseException.cs): The base class for HTTP error responses.
* [`Error`](./src/SpeakeasySDK/Models/Errors/Error.cs): The `Status` type defines a logical error model. *

<details><summary>Less common exceptions (2)</summary>

* [`System.Net.Http.HttpRequestException`](https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httprequestexception): Network connectivity error. For more details about the underlying cause, inspect the `ex.InnerException`.

* Inheriting from [`SDKBaseException`](./src/SpeakeasySDK/Models/Errors/SDKBaseException.cs):
* [`ResponseValidationError`](./src/SpeakeasySDK/Models/Errors/ResponseValidationError.cs): Thrown when the response data could not be deserialized into the expected type.
</details>

\* Refer to the [relevant documentation](#available-resources-and-operations) to determine whether an exception applies to a specific operation.
<!-- End Error Handling [errors] -->

<!-- Start Server Selection [server] -->
Expand All @@ -243,34 +241,24 @@ catch (Exception ex)

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:

| Name | Server |
| ------ | ----------------------------------- |
| `prod` | `https://api.prod.speakeasyapi.dev` |
| Name | Server | Description |
| ------ | -------------------------------- | ----------- |
| `prod` | `https://api.prod.speakeasy.com` | |

#### Example

```csharp
using SpeakeasySDK;
using SpeakeasySDK.Models.Shared;
using System.Collections.Generic;

var sdk = new SDK(
server: "prod",
server: SDKConfig.Server.Prod,
security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
}
);

RemoteSource req = new RemoteSource() {
Inputs = new List<RemoteDocument>() {
new RemoteDocument() {
RegistryUrl = "https://productive-swine.net",
},
},
Output = new RemoteDocument() {
RegistryUrl = "https://spiteful-apricot.info",
},
};
RemoteSource? req = null;

var res = await sdk.Artifacts.CreateRemoteSourceAsync(req);

Expand All @@ -283,25 +271,15 @@ The default server can also be overridden globally by passing a URL to the `serv
```csharp
using SpeakeasySDK;
using SpeakeasySDK.Models.Shared;
using System.Collections.Generic;

var sdk = new SDK(
serverUrl: "https://api.prod.speakeasyapi.dev",
serverUrl: "https://api.prod.speakeasy.com",
security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
}
);

RemoteSource req = new RemoteSource() {
Inputs = new List<RemoteDocument>() {
new RemoteDocument() {
RegistryUrl = "https://productive-swine.net",
},
},
Output = new RemoteDocument() {
RegistryUrl = "https://spiteful-apricot.info",
},
};
RemoteSource? req = null;

var res = await sdk.Artifacts.CreateRemoteSourceAsync(req);

Expand Down
Loading