Skip to content

Latest commit

 

History

History
188 lines (128 loc) · 8.82 KB

File metadata and controls

188 lines (128 loc) · 8.82 KB

CodeSamples

(CodeSamples)

Overview

REST APIs for retrieving Code Samples

Available Operations

  • 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.

GenerateCodeSamplePreview

This endpoint generates Code Sample previews from a file and configuration parameters.

Example Usage

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

Parameters

Parameter Type Required Description
request CodeSampleSchemaInput ✔️ The request object to use for the request.

Response

GenerateCodeSamplePreviewResponse

Errors

Error Type Status Code Content Type
SpeakeasySDK.Models.Errors.Error 4XX, 5XX application/json

GenerateCodeSamplePreviewAsync

This endpoint generates Code Sample previews from a file and configuration parameters, receiving an async JobID response for polling.

Example Usage

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

Parameters

Parameter Type Required Description
request CodeSampleSchemaInput ✔️ The request object to use for the request.

Response

GenerateCodeSamplePreviewAsyncResponse

Errors

Error Type Status Code Content Type
SpeakeasySDK.Models.Errors.Error 4XX, 5XX application/json

Get

Retrieve usage snippets from document stored in the registry. Supports filtering by language and operation ID.

Example Usage

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

Parameters

Parameter Type Required Description
request GetCodeSamplesRequest ✔️ The request object to use for the request.

Response

GetCodeSamplesResponse

Errors

Error Type Status Code Content Type
SpeakeasySDK.Models.Errors.Error 4XX application/json
SpeakeasySDK.Models.Errors.SDKException 5XX */*

GetCodeSamplePreviewAsync

Poll for the result of an asynchronous Code Sample preview generation.

Example Usage

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

Parameters

Parameter Type Required Description
request GetCodeSamplePreviewAsyncRequest ✔️ The request object to use for the request.

Response

GetCodeSamplePreviewAsyncResponse

Errors

Error Type Status Code Content Type
SpeakeasySDK.Models.Errors.Error 4XX, 5XX application/json