Skip to content

Latest commit

 

History

History
275 lines (195 loc) · 9.2 KB

File metadata and controls

275 lines (195 loc) · 9.2 KB

Organizations

(organizations())

Overview

REST APIs for managing Organizations (speakeasy L1 Tenancy construct)

Available Operations

  • create - Create an organization
  • createFreeTrial - Create a free trial for an organization
  • get - Get organization
  • getAll - Get organizations for a user
  • getUsage - Get billing usage summary for a particular organization

create

Creates an organization

Example Usage

package hello.world;

import dev.speakeasyapi.javaclientsdk.RyanTest;
import dev.speakeasyapi.javaclientsdk.models.errors.Error;
import dev.speakeasyapi.javaclientsdk.models.operations.CreateOrganizationResponse;
import dev.speakeasyapi.javaclientsdk.models.shared.AccountType;
import dev.speakeasyapi.javaclientsdk.models.shared.Organization;
import dev.speakeasyapi.javaclientsdk.models.shared.Security;
import java.lang.Exception;
import java.time.OffsetDateTime;

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();

        Organization req = Organization.builder()
                .accountType(AccountType.SCALE_UP)
                .createdAt(OffsetDateTime.parse("2023-12-01T17:06:07.804Z"))
                .id("<id>")
                .name("<value>")
                .slug("<value>")
                .ssoActivated(true)
                .telemetryDisabled(true)
                .updatedAt(OffsetDateTime.parse("2022-05-28T06:20:22.766Z"))
                .build();

        CreateOrganizationResponse res = sdk.organizations().create()
                .request(req)
                .call();

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

Parameters

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

Response

CreateOrganizationResponse

Errors

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

createFreeTrial

Creates a free trial for an organization

Example Usage

package hello.world;

import dev.speakeasyapi.javaclientsdk.RyanTest;
import dev.speakeasyapi.javaclientsdk.models.errors.Error;
import dev.speakeasyapi.javaclientsdk.models.operations.CreateFreeTrialResponse;
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();

        CreateFreeTrialResponse res = sdk.organizations().createFreeTrial()
                .call();

        // handle response
    }
}

Response

CreateFreeTrialResponse

Errors

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

get

Get information about a particular organization.

Example Usage

package hello.world;

import dev.speakeasyapi.javaclientsdk.RyanTest;
import dev.speakeasyapi.javaclientsdk.models.errors.Error;
import dev.speakeasyapi.javaclientsdk.models.operations.GetOrganizationRequest;
import dev.speakeasyapi.javaclientsdk.models.operations.GetOrganizationResponse;
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();

        GetOrganizationRequest req = GetOrganizationRequest.builder()
                .organizationID("<value>")
                .build();

        GetOrganizationResponse res = sdk.organizations().get()
                .request(req)
                .call();

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

Parameters

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

Response

GetOrganizationResponse

Errors

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

getAll

Returns a list of organizations a user has access too

Example Usage

package hello.world;

import dev.speakeasyapi.javaclientsdk.RyanTest;
import dev.speakeasyapi.javaclientsdk.models.errors.Error;
import dev.speakeasyapi.javaclientsdk.models.operations.GetOrganizationsResponse;
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();

        GetOrganizationsResponse res = sdk.organizations().getAll()
                .call();

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

Response

GetOrganizationsResponse

Errors

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

getUsage

Returns a billing usage summary by target languages for a particular organization

Example Usage

package hello.world;

import dev.speakeasyapi.javaclientsdk.RyanTest;
import dev.speakeasyapi.javaclientsdk.models.errors.Error;
import dev.speakeasyapi.javaclientsdk.models.operations.GetOrganizationUsageResponse;
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();

        GetOrganizationUsageResponse res = sdk.organizations().getUsage()
                .call();

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

Response

GetOrganizationUsageResponse

Errors

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