Skip to content

Latest commit

 

History

History
214 lines (148 loc) · 7.44 KB

File metadata and controls

214 lines (148 loc) · 7.44 KB

Auth

(auth())

Overview

REST APIs for managing Authentication

Available Operations

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

getAccess

Checks if generation is permitted for a particular run of the CLI

Example Usage

package hello.world;

import dev.speakeasyapi.javaclientsdk.RyanTest;
import dev.speakeasyapi.javaclientsdk.models.operations.GetWorkspaceAccessRequest;
import dev.speakeasyapi.javaclientsdk.models.operations.GetWorkspaceAccessResponse;
import dev.speakeasyapi.javaclientsdk.models.shared.Security;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Exception {

        RyanTest sdk = RyanTest.builder()
                .security(Security.builder()
                    .apiKey("<YOUR_API_KEY_HERE>")
                    .build())
            .build();

        GetWorkspaceAccessRequest req = GetWorkspaceAccessRequest.builder()
                .build();

        GetWorkspaceAccessResponse res = sdk.auth().getAccess()
                .request(req)
                .call();

        if (res.accessDetails().isPresent()) {
            // handle response
        }
    }
}

Parameters

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

Response

GetWorkspaceAccessResponse

Errors

Error Type Status Code Content Type
models/errors/SDKError 4XX, 5XX */*

getAccessToken

Get or refresh an access token for the current workspace.

Example Usage

package hello.world;

import dev.speakeasyapi.javaclientsdk.RyanTest;
import dev.speakeasyapi.javaclientsdk.models.errors.Error;
import dev.speakeasyapi.javaclientsdk.models.operations.GetAccessTokenRequest;
import dev.speakeasyapi.javaclientsdk.models.operations.GetAccessTokenResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Error, Exception {

        RyanTest sdk = RyanTest.builder()
            .build();

        GetAccessTokenRequest req = GetAccessTokenRequest.builder()
                .workspaceId("<value>")
                .build();

        GetAccessTokenResponse res = sdk.auth().getAccessToken()
                .request(req)
                .call();

        if (res.accessToken().isPresent()) {
            // handle response
        }
    }
}

Parameters

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

Response

GetAccessTokenResponse

Errors

Error Type Status Code Content Type
models/errors/Error 4XX application/json
models/errors/SDKError 5XX */*

getUser

Get information about the current user.

Example Usage

package hello.world;

import dev.speakeasyapi.javaclientsdk.RyanTest;
import dev.speakeasyapi.javaclientsdk.models.errors.Error;
import dev.speakeasyapi.javaclientsdk.models.operations.GetUserResponse;
import dev.speakeasyapi.javaclientsdk.models.shared.Security;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Error, Exception {

        RyanTest sdk = RyanTest.builder()
                .security(Security.builder()
                    .apiKey("<YOUR_API_KEY_HERE>")
                    .build())
            .build();

        GetUserResponse res = sdk.auth().getUser()
                .call();

        if (res.user().isPresent()) {
            // handle response
        }
    }
}

Response

GetUserResponse

Errors

Error Type Status Code Content Type
models/errors/Error 4XX application/json
models/errors/SDKError 5XX */*

validateApiKey

Validate the current api key.

Example Usage

package hello.world;

import dev.speakeasyapi.javaclientsdk.RyanTest;
import dev.speakeasyapi.javaclientsdk.models.errors.Error;
import dev.speakeasyapi.javaclientsdk.models.operations.ValidateApiKeyResponse;
import dev.speakeasyapi.javaclientsdk.models.shared.Security;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws Error, Exception {

        RyanTest sdk = RyanTest.builder()
                .security(Security.builder()
                    .apiKey("<YOUR_API_KEY_HERE>")
                    .build())
            .build();

        ValidateApiKeyResponse res = sdk.auth().validateApiKey()
                .call();

        if (res.apiKeyDetails().isPresent()) {
            // handle response
        }
    }
}

Response

ValidateApiKeyResponse

Errors

Error Type Status Code Content Type
models/errors/Error 4XX application/json
models/errors/SDKError 5XX */*