(CodeSamples)
REST APIs for retrieving Code Samples
- 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.
- Get - Retrieve usage snippets from document stored in the registry
- GetCodeSamplePreviewAsync - Poll for the result of an asynchronous Code Sample preview generation.
This endpoint generates Code Sample previews from a file and configuration parameters.
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.CodeSamples.GenerateCodeSamplePreviewAsync(req);
// handle response
Parameter | Type | Required | Description |
---|---|---|---|
request |
CodeSampleSchemaInput | ✔️ | The request object to use for the request. |
GenerateCodeSamplePreviewResponse
Error Type | Status Code | Content Type |
---|---|---|
SpeakeasySDK.Models.Errors.Error | 4XX, 5XX | application/json |
This endpoint generates Code Sample previews from a file and configuration parameters, receiving an async JobID response for polling.
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("0xED5CDd177E"),
FileName = "example.file",
},
};
var res = await sdk.CodeSamples.GenerateCodeSamplePreviewAsyncAsync(req);
// handle response
Parameter | Type | Required | Description |
---|---|---|---|
request |
CodeSampleSchemaInput | ✔️ | The request object to use for the request. |
GenerateCodeSamplePreviewAsyncResponse
Error Type | Status Code | Content Type |
---|---|---|
SpeakeasySDK.Models.Errors.Error | 4XX, 5XX | application/json |
Retrieve usage snippets from document stored in the registry. Supports filtering by language and operation ID.
using SpeakeasySDK;
using SpeakeasySDK.Models.Operations;
using SpeakeasySDK.Models.Shared;
var sdk = new SDK(security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
});
GetCodeSamplesRequest req = new GetCodeSamplesRequest() {
RegistryUrl = "https://normal-making.name",
};
var res = await sdk.CodeSamples.GetAsync(req);
// handle response
Parameter | Type | Required | Description |
---|---|---|---|
request |
GetCodeSamplesRequest | ✔️ | The request object to use for the request. |
Error Type | Status Code | Content Type |
---|---|---|
SpeakeasySDK.Models.Errors.Error | 4XX | application/json |
SpeakeasySDK.Models.Errors.SDKException | 5XX | */* |
Poll for the result of an asynchronous Code Sample preview generation.
using SpeakeasySDK;
using SpeakeasySDK.Models.Operations;
using SpeakeasySDK.Models.Shared;
var sdk = new SDK(security: new Security() {
APIKey = "<YOUR_API_KEY_HERE>",
});
GetCodeSamplePreviewAsyncRequest req = new GetCodeSamplePreviewAsyncRequest() {
JobID = "<id>",
};
var res = await sdk.CodeSamples.GetCodeSamplePreviewAsyncAsync(req);
// handle response
Parameter | Type | Required | Description |
---|---|---|---|
request |
GetCodeSamplePreviewAsyncRequest | ✔️ | The request object to use for the request. |
GetCodeSamplePreviewAsyncResponse
Error Type | Status Code | Content Type |
---|---|---|
SpeakeasySDK.Models.Errors.Error | 4XX, 5XX | application/json |