Skip to content

Latest commit

 

History

History
474 lines (314 loc) · 27 KB

File metadata and controls

474 lines (314 loc) · 27 KB

Machines

Overview

Available Operations

list

This request returns the list of machines for an instance. The machines are ordered by descending creation date (i.e. most recent machines will be returned first)

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Clerk\Backend;

$sdk = Backend\ClerkBackend::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();



$response = $sdk->machines->list(
    limit: 10,
    offset: 0,
    orderBy: '-created_at'

);

if ($response->machineList !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
limit ?int Applies a limit to the number of results returned.
Can be used for paginating the results together with offset.
offset ?int Skip the first offset results when paginating.
Needs to be an integer greater or equal to zero.
To be used in conjunction with limit.
query ?string Returns machines with ID or name that match the given query. Uses exact match for machine ID and partial match for name.
orderBy ?string Allows to return machines in a particular order.
You can order the returned machines by their name or created_at.
To specify the direction, use the + or - symbols prepended to the property to order by.
For example, to return machines in descending order by created_at, use -created_at.
If you don't use + or -, then + is implied.
Defaults to -created_at.

Response

?Operations\ListMachinesResponse

Errors

Error Type Status Code Content Type
Errors\ClerkErrors 400, 401, 403, 422 application/json
Errors\SDKException 4XX, 5XX */*

create

Creates a new machine.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Clerk\Backend;

$sdk = Backend\ClerkBackend::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();



$response = $sdk->machines->create(
    request: $request
);

if ($response->machineCreated !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
$request Operations\CreateMachineRequestBody ✔️ The request object to use for the request.

Response

?Operations\CreateMachineResponse

Errors

Error Type Status Code Content Type
Errors\ClerkErrors 400, 401, 403, 422 application/json
Errors\SDKException 4XX, 5XX */*

get

Returns the details of a machine.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Clerk\Backend;

$sdk = Backend\ClerkBackend::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();



$response = $sdk->machines->get(
    machineId: '<id>'
);

if ($response->machine !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
machineId string ✔️ The ID of the machine to retrieve

Response

?Operations\GetMachineResponse

Errors

Error Type Status Code Content Type
Errors\ClerkErrors 400, 401, 403, 404, 422 application/json
Errors\SDKException 4XX, 5XX */*

update

Updates an existing machine. Only the provided fields will be updated.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Clerk\Backend;

$sdk = Backend\ClerkBackend::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();



$response = $sdk->machines->update(
    machineId: '<id>',
    requestBody: $requestBody

);

if ($response->machine !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
machineId string ✔️ The ID of the machine to update
requestBody ?Operations\UpdateMachineRequestBody N/A

Response

?Operations\UpdateMachineResponse

Errors

Error Type Status Code Content Type
Errors\ClerkErrors 400, 401, 403, 404, 422 application/json
Errors\SDKException 4XX, 5XX */*

delete

Deletes a machine.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Clerk\Backend;

$sdk = Backend\ClerkBackend::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();



$response = $sdk->machines->delete(
    machineId: '<id>'
);

if ($response->machineDeleted !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
machineId string ✔️ The ID of the machine to delete

Response

?Operations\DeleteMachineResponse

Errors

Error Type Status Code Content Type
Errors\ClerkErrors 400, 401, 403, 404, 422 application/json
Errors\SDKException 4XX, 5XX */*

getSecretKey

Returns the secret key for a machine.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Clerk\Backend;

$sdk = Backend\ClerkBackend::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();



$response = $sdk->machines->getSecretKey(
    machineId: '<id>'
);

if ($response->machineSecretKey !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
machineId string ✔️ The ID of the machine to retrieve the secret key for

Response

?Operations\GetMachineSecretKeyResponse

Errors

Error Type Status Code Content Type
Errors\ClerkErrors 400, 401, 403, 404 application/json
Errors\SDKException 4XX, 5XX */*

rotateSecretKey

Rotates the machine's secret key. When the secret key is rotated, make sure to update it in your machine/application. The previous secret key will remain valid for the duration specified by the previous_token_ttl parameter.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Clerk\Backend;
use Clerk\Backend\Models\Operations;

$sdk = Backend\ClerkBackend::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();

$requestBody = new Operations\RotateMachineSecretKeyRequestBody(
    previousTokenTtl: 632625,
);

$response = $sdk->machines->rotateSecretKey(
    machineId: '<id>',
    requestBody: $requestBody

);

if ($response->machineSecretKey !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
machineId string ✔️ The ID of the machine to rotate the secret key for
requestBody Operations\RotateMachineSecretKeyRequestBody ✔️ N/A

Response

?Operations\RotateMachineSecretKeyResponse

Errors

Error Type Status Code Content Type
Errors\ClerkErrors 400, 401, 403, 404, 422 application/json
Errors\SDKException 4XX, 5XX */*

createScope

Creates a new machine scope, allowing the specified machine to access another machine. Maximum of 150 scopes per machine.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Clerk\Backend;

$sdk = Backend\ClerkBackend::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();



$response = $sdk->machines->createScope(
    machineId: '<id>',
    requestBody: $requestBody

);

if ($response->machineScope !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
machineId string ✔️ The ID of the machine that will have access to another machine
requestBody ?Operations\CreateMachineScopeRequestBody N/A

Response

?Operations\CreateMachineScopeResponse

Errors

Error Type Status Code Content Type
Errors\ClerkErrors 400, 401, 403, 404, 409, 422 application/json
Errors\SDKException 4XX, 5XX */*

deleteScope

Deletes a machine scope, removing access from one machine to another.

Example Usage

declare(strict_types=1);

require 'vendor/autoload.php';

use Clerk\Backend;

$sdk = Backend\ClerkBackend::builder()
    ->setSecurity(
        '<YOUR_BEARER_TOKEN_HERE>'
    )
    ->build();



$response = $sdk->machines->deleteScope(
    machineId: '<id>',
    otherMachineId: '<id>'

);

if ($response->machineScopeDeleted !== null) {
    // handle response
}

Parameters

Parameter Type Required Description
machineId string ✔️ The ID of the machine that has access to another machine
otherMachineId string ✔️ The ID of the machine that is being accessed

Response

?Operations\DeleteMachineScopeResponse

Errors

Error Type Status Code Content Type
Errors\ClerkErrors 400, 401, 403, 404, 422 application/json
Errors\SDKException 4XX, 5XX */*