workspaces

package
v4.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package workspaces contains workspace management functionality on SSS.

Example to List workspaces

listOpts := workspaces.ListOpts{ContractID: "econ0000000001"}

allPages, err := workspaces.List(client, listOpts).AllPages()
if err != nil {
	panic(err)
}

allWorkspaces, err := workspaces.ExtractWorkspaces(allPages)
if err != nil {
	panic(err)
}

for _, workspace := range allWorkspaces {
	fmt.Printf("%+v\n", workspace)
}

Example to Get a workspace

id := "ws0000000001"
workspace, err := workspaces.Get(client, id).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", workspace)

Example to Create a workspace

createOpts := workspaces.CreateOpts{
	WorkspaceName: "Example-Workspace",
	Description:   "Example Workspace",
	ContractID:    "econ0000000001",
}

workspace, err := workspaces.Create(client, createOpts).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%+v\n", workspace)

Example to Update a workspace

workspaceID := "ws0000000001"
description := "update description"
updateOpts := workspaces.UpdateOpts{Description: &description}

result := workspaces.Update(client, workspaceID, updateOpts)
if result.Err != nil {
	panic(result.Err)
}

Example to Delete a workspace

workspaceID := "ws0000000001"
res := workspaces.Delete(client, workspaceID)
if res.Err != nil {
	panic(res.Err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

List enumerates the Workspaces to which the current token has access.

Types

type CreateOpts

type CreateOpts struct {
	// Workspace Name.
	WorkspaceName string `json:"workspace_name" required:"true"`
	// Workspace description.
	Description string `json:"description,omitempty"`
	// ContractID to be associated with the workspace.
	ContractID string `json:"contract_id,omitempty"`
}

CreateOpts represents parameters used to create a workspace.

func (CreateOpts) ToWorkspaceCreateMap

func (opts CreateOpts) ToWorkspaceCreateMap() (map[string]interface{}, error)

ToWorkspaceCreateMap formats a CreateOpts into a create request.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToWorkspaceCreateMap() (map[string]interface{}, error)
}

CreateOptsBuilder allows extensions to add additional parameters to the Create request.

type CreateResult

type CreateResult struct {
	// contains filtered or unexported fields
}

CreateResult is the result of a Create request. Call its Extract method to interpret it as a Workspace.

func Create

func Create(client *eclcloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)

Create creates a new workspace.

func (CreateResult) Extract

func (r CreateResult) Extract() (*Workspace, error)

Extract interprets any projectResults as a Workspace.

type DeleteResult

type DeleteResult struct {
	eclcloud.ErrResult
}

DeleteResult is the result of a Delete request. Call its ExtractErr method to determine if the request succeeded or failed.

func Delete

func Delete(client *eclcloud.ServiceClient, workspaceID string) (r DeleteResult)

Delete deletes a workspace.

type GetResult

type GetResult struct {
	// contains filtered or unexported fields
}

GetResult is the result of a Get request. Call its Extract method to interpret it as a Workspace.

func Get

func Get(client *eclcloud.ServiceClient, id string) (r GetResult)

Get retrieves details on a single workspace, by ID.

func (GetResult) Extract

func (r GetResult) Extract() (*Workspace, error)

Extract interprets any projectResults as a Workspace.

type ListOpts

type ListOpts struct {
	ContractID string `q:"contract_id"`
}

ListOpts enables filtering of a list request. Currently SSS Workspace API does not support any of query parameters.

func (ListOpts) ToWorkspaceListQuery

func (opts ListOpts) ToWorkspaceListQuery() (string, error)

ToWorkspaceListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToWorkspaceListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request

type Region

type Region struct {
	RegionName string `json:"region_name"`
	TenantID   string `json:"tenant_id"`
}

type UpdateOpts

type UpdateOpts struct {
	// Workspace description.
	Description *string `json:"description" required:"true"`
}

UpdateOpts represents parameters to update a workspace.

func (UpdateOpts) ToWorkspaceUpdateMap

func (opts UpdateOpts) ToWorkspaceUpdateMap() (map[string]interface{}, error)

ToWorkspaceUpdateMap formats a UpdateOpts into an update request.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToWorkspaceUpdateMap() (map[string]interface{}, error)
}

UpdateOptsBuilder allows extensions to add additional parameters to the Update request.

type UpdateResult

type UpdateResult struct {
	// contains filtered or unexported fields
}

UpdateResult is the result of an Update request. Call its Extract method to interpret it as a Workspace.

func Update

func Update(client *eclcloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)

Update modifies the attributes of a workspace. SSS Workspace PUT API does not have response body, so set JSONResponse option as nil.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Workspace, error)

Extract interprets any projectResults as a Workspace.

type User

type User struct {
	UserID        string `json:"user_id"`
	ContractID    string `json:"contract_id"`
	ContractOwner bool   `json:"contract_owner"`
}

type Workspace

type Workspace struct {
	ContractID    string    `json:"contract_id"`
	WorkspaceID   string    `json:"workspace_id"`
	WorkspaceName string    `json:"workspace_name"`
	Description   string    `json:"description"`
	StartTime     time.Time `json:"-"`
	Regions       []Region  `json:"regions"`
	Users         []User    `json:"users"`
}

func ExtractWorkspaces

func ExtractWorkspaces(r pagination.Page) ([]Workspace, error)

ExtractWorkspaces returns a slice of Workspace contained in a single page of results.

func (*Workspace) UnmarshalJSON

func (r *Workspace) UnmarshalJSON(b []byte) error

UnmarshalJSON creates JSON format of workspace

type WorkspacePage

type WorkspacePage struct {
	pagination.LinkedPageBase
}

WorkspacePage is a single page of Workspace results.

func (WorkspacePage) IsEmpty

func (r WorkspacePage) IsEmpty() (bool, error)

IsEmpty determines whether or not a page of Workspace contains any results.

func (WorkspacePage) NextPageURL

func (r WorkspacePage) NextPageURL() (string, error)

NextPageURL extracts the "next" link from the links section of the result.

Directories

Path Synopsis
sss workspace unit tests
sss workspace unit tests

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL