(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.
- getCodeSamplePreviewAsync - Poll for the result of an asynchronous Code Sample preview generation.
This endpoint generates Code Sample previews from a file and configuration parameters.
declare(strict_types=1);
require 'vendor/autoload.php';
use Speakeasy\SpeakeasyClientSDK;
use Speakeasy\SpeakeasyClientSDK\Models\Shared;
$sdk = SpeakeasyClientSDK\SDK::builder()
->setSecurity(
new Shared\Security(
apiKey: '<YOUR_API_KEY_HERE>',
)
)
->build();
$request = new Shared\CodeSampleSchemaInput(
languages: [
'<value>',
],
schemaFile: new Shared\SchemaFile(
content: '0xc3dD8BfBef',
fileName: 'example.file',
),
);
$response = $sdk->codeSamples->generateCodeSamplePreview(
request: $request
);
if ($response->twoHundredApplicationJsonBytes !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
$request |
Shared\CodeSampleSchemaInput | ✔️ | The request object to use for the request. |
?Operations\GenerateCodeSamplePreviewResponse
Error Type | Status Code | Content Type |
---|---|---|
Errorors\Error | 4XX | application/json |
Errorors\Error | 5XX | application/json |
This endpoint generates Code Sample previews from a file and configuration parameters, receiving an async JobID response for polling.
declare(strict_types=1);
require 'vendor/autoload.php';
use Speakeasy\SpeakeasyClientSDK;
use Speakeasy\SpeakeasyClientSDK\Models\Shared;
$sdk = SpeakeasyClientSDK\SDK::builder()
->setSecurity(
new Shared\Security(
apiKey: '<YOUR_API_KEY_HERE>',
)
)
->build();
$request = new Shared\CodeSampleSchemaInput(
languages: [
'<value>',
],
schemaFile: new Shared\SchemaFile(
content: '0xED5CDd177E',
fileName: 'example.file',
),
);
$response = $sdk->codeSamples->generateCodeSamplePreviewAsync(
request: $request
);
if ($response->object !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
$request |
Shared\CodeSampleSchemaInput | ✔️ | The request object to use for the request. |
?Operations\GenerateCodeSamplePreviewAsyncResponse
Error Type | Status Code | Content Type |
---|---|---|
Errorors\Error | 4XX | application/json |
Errorors\Error | 5XX | application/json |
Poll for the result of an asynchronous Code Sample preview generation.
declare(strict_types=1);
require 'vendor/autoload.php';
use Speakeasy\SpeakeasyClientSDK;
use Speakeasy\SpeakeasyClientSDK\Models\Operations;
use Speakeasy\SpeakeasyClientSDK\Models\Shared;
$sdk = SpeakeasyClientSDK\SDK::builder()
->setSecurity(
new Shared\Security(
apiKey: '<YOUR_API_KEY_HERE>',
)
)
->build();
$request = new Operations\GetCodeSamplePreviewAsyncRequest(
jobID: '<id>',
);
$response = $sdk->codeSamples->getCodeSamplePreviewAsync(
request: $request
);
if ($response->twoHundredApplicationJsonBytes !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
$request |
Operations\GetCodeSamplePreviewAsyncRequest | ✔️ | The request object to use for the request. |
?Operations\GetCodeSamplePreviewAsyncResponse
Error Type | Status Code | Content Type |
---|---|---|
Errorors\Error | 4XX | application/json |
Errorors\Error | 5XX | application/json |