Speakeasy API: The Subscriptions API manages subscriptions for CLI and registry events
For more information about the API: The Speakeasy Platform Documentation
To add the NuGet package to a .NET project:
dotnet add package SpeakeasySDK
To add a reference to a local instance of the SDK in a .NET project:
dotnet add reference src/SpeakeasySDK/SpeakeasySDK.csproj
using SpeakeasySDK;
using SpeakeasySDK.Models.Shared;
using System;
using System.Collections.Generic;
var sdk = new SDK(security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
});
CodeSampleSchemaInput req = new CodeSampleSchemaInput() {
Languages = new List<string>() {
"<value>",
},
SchemaFile = new SchemaFile() {
Content = System.Text.Encoding.UTF8.GetBytes("0xc3dD8BfBef"),
FileName = "example.file",
},
};
var res = await sdk.GenerateCodeSamplePreviewAsync(req);
// handle response
Available methods
- CreateRemoteSource - Configure a new remote source
- GetBlob - Get blob for a particular digest
- GetManifest - Get manifest for a particular reference
- GetNamespaces - Each namespace contains many revisions.
- GetRevisions
- GetTags
- ListRemoteSources - Get remote sources attached to a particular namespace
- PostTags - Add tags to an existing revision
- Preflight - Get access token for communicating with OCI distribution endpoints
- SetVisibility - Set visibility of a namespace with an existing metadata entry
- GetAccess - Get access allowances for a particular workspace
- GetAccessToken - Get or refresh an access token for the current workspace.
- GetUser - Get information about the current user.
- ValidateApiKey - Validate the current api key.
- GetEventsByTarget - Load recent events for a particular workspace
- GetTargets - Load targets for a particular workspace
- GetTargetsDeprecated - Load targets for a particular workspace
- Post - Post events for a specific workspace
- Search - Search events for a particular workspace by any field
- CheckAccess
- CheckPublishingPRs
- CheckPublishingSecrets
- ConfigureCodeSamples
- ConfigureMintlifyRepo
- ConfigureTarget
- GetAction
- GetSetup
- LinkGithub
- StorePublishingSecrets
- TriggerAction
- Create - Create an organization
- CreateFreeTrial - Create a free trial for an organization
- Get - Get organization
- GetAll - Get organizations for a user
- GetUsage - Get billing usage summary for a particular organization
- GetChangesReportSignedUrl - Get the signed access url for the change reports for a particular document.
- GetLintingReportSignedUrl - Get the signed access url for the linting reports for a particular document.
- UploadReport - Upload a report.
- GenerateCodeSamplePreview - Generate Code Sample previews from a file and configuration parameters.
- GenerateCodeSamplePreviewAsync - Initiate asynchronous Code Sample preview generation from a file and configuration parameters, receiving an async JobID response for polling.
- GetCodeSamplePreviewAsync - Poll for the result of an asynchronous Code Sample preview generation.
- Create - Shorten a URL.
- ActivateSubscriptionNamespace - Activate an ignored namespace for a subscription
- IgnoreSubscriptionNamespace - Ignored a namespace for a subscription
- Suggest - Generate suggestions for improving an OpenAPI document.
- SuggestItems - Generate generic suggestions for a list of items.
- SuggestOpenAPI - (DEPRECATED) Generate suggestions for improving an OpenAPI document.
- SuggestOpenAPIRegistry - Generate suggestions for improving an OpenAPI document stored in the registry.
- Create - Create a workspace
- CreateToken - Create a token for a particular workspace
- DeleteToken - Delete a token for a particular workspace
- Get - Get workspace by context
- GetAll - Get workspaces for a user
- GetByID - Get workspace
- GetFeatureFlags - Get workspace feature flags
- GetSettings - Get workspace settings
- GetTeam - Get team members for a particular workspace
- GetTokens - Get tokens for a particular workspace
- GrantAccess - Grant a user access to a particular workspace
- RevokeAccess - Revoke a user's access to a particular workspace
- Update - Update workspace details
- UpdateSettings - Update workspace settings
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 |
using SpeakeasySDK;
using SpeakeasySDK.Models.Shared;
using System;
using System.Collections.Generic;
var sdk = new SDK(
server: "prod",
security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
}
);
CodeSampleSchemaInput req = new CodeSampleSchemaInput() {
Languages = new List<string>() {
"<value>",
},
SchemaFile = new SchemaFile() {
Content = System.Text.Encoding.UTF8.GetBytes("0xc3dD8BfBef"),
FileName = "example.file",
},
};
var res = await sdk.GenerateCodeSamplePreviewAsync(req);
// handle response
The default server can also be overridden globally by passing a URL to the serverUrl: string
optional parameter when initializing the SDK client instance. For example:
using SpeakeasySDK;
using SpeakeasySDK.Models.Shared;
using System;
using System.Collections.Generic;
var sdk = new SDK(
serverUrl: "https://api.prod.speakeasyapi.dev",
security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
}
);
CodeSampleSchemaInput req = new CodeSampleSchemaInput() {
Languages = new List<string>() {
"<value>",
},
SchemaFile = new SchemaFile() {
Content = System.Text.Encoding.UTF8.GetBytes("0xc3dD8BfBef"),
FileName = "example.file",
},
};
var res = await sdk.GenerateCodeSamplePreviewAsync(req);
// handle response
This SDK supports the following security schemes globally:
Name | Type | Scheme |
---|---|---|
APIKey |
apiKey | API key |
Bearer |
http | HTTP Bearer |
WorkspaceIdentifier |
apiKey | API key |
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:
using SpeakeasySDK;
using SpeakeasySDK.Models.Shared;
using System;
using System.Collections.Generic;
var sdk = new SDK(security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
});
CodeSampleSchemaInput req = new CodeSampleSchemaInput() {
Languages = new List<string>() {
"<value>",
},
SchemaFile = new SchemaFile() {
Content = System.Text.Encoding.UTF8.GetBytes("0xc3dD8BfBef"),
FileName = "example.file",
},
};
var res = await sdk.GenerateCodeSamplePreviewAsync(req);
// handle response
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.
For example, you can set workspace_id
to "<id>"
at SDK initialization and then you do not have to pass the same value on calls to operations like GetAccessToken
. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.
The following global parameter is available.
Name | Type | Description |
---|---|---|
workspaceId | string | The WorkspaceId parameter. |
using SpeakeasySDK;
using SpeakeasySDK.Models.Operations;
var sdk = new SDK();
GetAccessTokenRequest req = new GetAccessTokenRequest() {
WorkspaceId = "<id>",
};
var res = await sdk.Auth.GetAccessTokenAsync(req);
// handle response
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:
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 |
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 GenerateCodeSamplePreviewAsync
method throws the following exceptions:
Error Type | Status Code | Content Type |
---|---|---|
SpeakeasySDK.Models.Errors.Error | 4XX, 5XX | application/json |
using SpeakeasySDK;
using SpeakeasySDK.Models.Errors;
using SpeakeasySDK.Models.Shared;
using System;
using System.Collections.Generic;
var sdk = new SDK(security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
});
try
{
CodeSampleSchemaInput req = new CodeSampleSchemaInput() {
Languages = new List<string>() {
"<value>",
},
SchemaFile = new SchemaFile() {
Content = System.Text.Encoding.UTF8.GetBytes("0xc3dD8BfBef"),
FileName = "example.file",
},
};
var res = await sdk.GenerateCodeSamplePreviewAsync(req);
// handle response
}
catch (Exception ex)
{
if (ex is Error)
{
// Handle exception data
throw;
}
else if (ex is SpeakeasySDK.Models.Errors.SDKException)
{
// Handle default exception
throw;
}
}
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 pass a RetryConfig
to the call:
using SpeakeasySDK;
using SpeakeasySDK.Models.Operations;
using SpeakeasySDK.Models.Shared;
var sdk = new SDK(security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
});
GetWorkspaceAccessRequest req = new GetWorkspaceAccessRequest() {};
var res = await sdk.Auth.GetAccessAsync(
retryConfig: new RetryConfig(
strategy: RetryConfig.RetryStrategy.BACKOFF,
backoff: new BackoffStrategy(
initialIntervalMs: 1L,
maxIntervalMs: 50L,
maxElapsedTimeMs: 100L,
exponent: 1.1
),
retryConnectionErrors: false
),
request: req
);
// handle response
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:
using SpeakeasySDK;
using SpeakeasySDK.Models.Operations;
using SpeakeasySDK.Models.Shared;
var sdk = new SDK(
retryConfig: new RetryConfig(
strategy: RetryConfig.RetryStrategy.BACKOFF,
backoff: new BackoffStrategy(
initialIntervalMs: 1L,
maxIntervalMs: 50L,
maxElapsedTimeMs: 100L,
exponent: 1.1
),
retryConnectionErrors: false
),
security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
}
);
GetWorkspaceAccessRequest req = new GetWorkspaceAccessRequest() {};
var res = await sdk.Auth.GetAccessAsync(req);
// handle response
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
While we value open-source contributions to this SDK, this library is generated programmatically. 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!