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 ¶
- func List(client *eclcloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type GetResult
- type ListOpts
- type ListOptsBuilder
- type Region
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
- type User
- type Workspace
- type WorkspacePage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(client *eclcloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
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 ¶
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.
type DeleteResult ¶
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.
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 ¶
ToWorkspaceListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request
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 ¶
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.
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 ¶
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.