autonomisdk

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MPL-2.0 Imports: 15 Imported by: 1

README

Autonomi SDK

Autonomi allows to deploy automatically and asynchronously cloud resources.

Getting started

Prerequisites

Go 1.22 or higher

Install Autonomi Go SDK
  1. Use go get to install the latest version of the Autonomi Go SDK and dependencies:

    go get -u https://github.com/intercloud/autonomi-sdk
    
  2. Include the Autonomi Go SDK in your application:

import autonomisdk "github.com/intercloud/autonomi-sdk"

//...other snippet ...
client, err := autonomisdk.NewClient(
    terms_and_conditions,
    autonomisdk.WithHTTPClient(&http.Client{}),
    autonomisdk.WithHostURL(hostURL),
    autonomisdk.WithPersonalAccessToken(personal_access_token),
)
if err != nil {
    // handle error
}
defer client.Close()

workspace, err := client.CreateWorkspace(ctx, payload)
if err != nil {
    // handle error
}
Resources

Autonomi SDK allows to :

  • Create, Read, Update and Delete a Workspace
  • Create, Read, Update and Delete a Node
  • Create, Read, Update and Delete a Transport
  • Create, Read and Delete an Attachment
  • Create, Read and Delete a Physical Port
  • Create, Read and Delete an Account

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTermsAndConditionsRequired  = errors.New("terms and conditions must be accepted")
	ErrHostURLRequired             = errors.New("host url must be set, please use the option WithHostURL()")
	ErrPersonalAccessTokenRequired = errors.New("personal acess token must be set, please use the option WithPersonalAccessToken()")
)

Functions

func WaitUntilFinishedTask added in v0.0.11

func WaitUntilFinishedTask[T Element](ctx context.Context, client *Client, workspaceID, elementID string, waiterOptions models.AdministrativeState, getElement func(context.Context, *Client, string, string, models.AdministrativeState) (T, bool)) (T, bool)

Types

type Client

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

func NewClient

func NewClient(termsAndConditions bool, opts ...OptionClient) (*Client, error)

NewClient - Init and return an http client

func (*Client) CreateAccount added in v1.2.0

func (c *Client) CreateAccount(ctx context.Context, payload models.Account) (*models.Account, error)

func (*Client) CreateAttachment added in v0.0.7

func (c *Client) CreateAttachment(ctx context.Context, payload models.CreateAttachment, workspaceID string, options ...OptionElement) (*models.Attachment, error)

CreateAttachment creates asynchronously an attachment. The attachment returned will depend of the passed option. If none is passed the attachment will be returned once created in database with administrative state creation_pending. If the option WithWaitUntilElementDeployed() is passed, the attachment will be returned when its state reach deployed or creation_error. If the option WithWaitUntilElementUndeployed() is passed, it will not be considered hence the attachment returned will be in state creation_pending

func (*Client) CreateNode

func (c *Client) CreateNode(ctx context.Context, payload models.CreateNode, workspaceID string, options ...OptionElement) (*models.Node, error)

CreateNode creates asynchronously a cloud node. The node returned will depend of the passed option. If none is passed the node will be returned once created in database with administrative state creation_pending. If the option WithWaitUntilElementDeployed() is passed, the node will be returned when its state reach deployed or creation_error. If the option WithWaitUntilElementUndeployed() is passed, it will not be considered hence the node returned will be in state creation_pending

func (*Client) CreatePhysicalPort added in v0.0.14

func (c *Client) CreatePhysicalPort(ctx context.Context, payload models.CreatePhysicalPort) (*models.PhysicalPort, error)

CreatePhysicalPort creates a physical port in Autonomi platform.

func (*Client) CreateTransport added in v0.0.4

func (c *Client) CreateTransport(ctx context.Context, payload models.CreateTransport, workspaceID string, options ...OptionElement) (*models.Transport, error)

CreateTransport creates asynchronously a transport. The transport returned will depend of the passed option. If none is passed the transport will be returned once created in database with administrative state creation_pending. If the option WithWaitUntilElementDeployed() is passed, the transport will be returned when its state reach deployed or creation_error. If the option WithWaitUntilElementUndeployed() is passed, it will not be considered hence the transport returned will be in state creation_pending

func (*Client) CreateUser added in v1.3.0

func (c *Client) CreateUser(ctx context.Context, payload models.CreateUser) (*models.User, error)

func (*Client) CreateWorkspace

func (c *Client) CreateWorkspace(ctx context.Context, payload models.CreateWorkspace) (*models.Workspace, error)

func (*Client) DeleteAccount added in v1.2.0

func (c *Client) DeleteAccount(ctx context.Context, accountID uuid.UUID) error

func (*Client) DeleteAttachment added in v0.0.7

func (c *Client) DeleteAttachment(ctx context.Context, workspaceID, attachmentID string, options ...OptionElement) (*models.Attachment, error)

DeleteAttachment deletes asynchronously an attachment. The attachment returned will depend of the option passed. If none is passed the attachment will be returned once the request accepted, its state will be delete_pending If the option WithWaitUntilElementUndeployed() is passed, the attachment won't be returned as it would have been deleted. However, if an error is triggered, an object could be returned with a delete_error state. If the option WithWaitUntilElementDeployed() is passed, it will not be considered hence the attachment returned will be in state delete_pending

func (*Client) DeleteNode

func (c *Client) DeleteNode(ctx context.Context, workspaceID, nodeID string, options ...OptionElement) (*models.Node, error)

DeleteNode deletes asynchronously a node. The attachment returned will depend of the option passed. If none is passed the node will be returned once the request accepted, its state will be delete_pending If the option WithWaitUntilElementUndeployed() is passed, the node won't be returned as it would have been deleted. However, if an error is triggered, an object could be returned with a delete_error state. If the option WithWaitUntilElementDeployed() is passed, it will not be considered hence the node returned will be in state delete_pending

func (*Client) DeletePhysicalPort added in v0.0.14

func (c *Client) DeletePhysicalPort(ctx context.Context, physicalPortID string) error

DeletePhysicalPort creates a physical port in Autonomi platform. As

func (*Client) DeleteTransport added in v0.0.4

func (c *Client) DeleteTransport(ctx context.Context, workspaceID, transportID string, options ...OptionElement) (*models.Transport, error)

DeleteTransport deletes asynchronously a transport. The transport returned will depend of the option passed. If none is passed the transport will be returned once the request accepted, its state will be delete_pending If the option WithWaitUntilElementUndeployed() is passed, the transport won't be returned as it would have been deleted. However, if an error is triggered, an object could be returned with a delete_error state. If the option WithWaitUntilElementDeployed() is passed, it will not be considered hence the transport returned will be in state delete_pending

func (*Client) DeleteUser added in v1.3.0

func (c *Client) DeleteUser(ctx context.Context, userID string) error

func (*Client) DeleteWorkspace

func (c *Client) DeleteWorkspace(ctx context.Context, workspaceID string) error

func (*Client) GetAttachment added in v0.0.7

func (c *Client) GetAttachment(ctx context.Context, workspaceID, attachmentID string) (*models.Attachment, error)

func (*Client) GetNode

func (c *Client) GetNode(ctx context.Context, workspaceID, nodeID string) (*models.Node, error)

func (*Client) GetPhysicalPort added in v0.0.14

func (c *Client) GetPhysicalPort(ctx context.Context, portID string) (*models.PhysicalPort, error)

func (*Client) GetSelf

func (c *Client) GetSelf() (uuid.UUID, error)

func (*Client) GetTransport added in v0.0.4

func (c *Client) GetTransport(ctx context.Context, workspaceID, transportID string) (*models.Transport, error)

func (*Client) GetWorkspace

func (c *Client) GetWorkspace(ctx context.Context, workspaceID string) (*models.Workspace, error)

func (*Client) ListAccounts added in v1.2.0

func (c *Client) ListAccounts(ctx context.Context) (models.Accounts, error)

func (*Client) ListPort added in v0.0.12

func (c *Client) ListPort(options ...OptionElement) (*[]models.PhysicalPort, error)

func (*Client) ListUsers added in v1.3.0

func (c *Client) ListUsers(ctx context.Context, accountID uuid.UUID) (models.Users, error)

func (*Client) ListWorkspaces added in v1.2.0

func (c *Client) ListWorkspaces(ctx context.Context, accountID uuid.UUID) ([]models.Workspace, error)

func (*Client) UpdateNode

func (c *Client) UpdateNode(ctx context.Context, payload models.UpdateElement, workspaceID, nodeID string) (*models.Node, error)

func (*Client) UpdateTransport added in v0.0.4

func (c *Client) UpdateTransport(ctx context.Context, payload models.UpdateElement, workspaceID, transportID string) (*models.Transport, error)

func (*Client) UpdateWorkspace

func (c *Client) UpdateWorkspace(ctx context.Context, payload models.UpdateWorkspace, workspaceID string) (*models.Workspace, error)

type Element added in v0.0.7

type Element interface {
	*models.Node | *models.Transport | *models.Attachment

	GetState() models.AdministrativeState
}

type OptionClient

type OptionClient func(*Client)

func WithHTTPClient

func WithHTTPClient(client *http.Client) OptionClient

WithHTTPClient init http client. If its timeout is above 30s it will be overide to be equal to 30 seconds

func WithHostURL

func WithHostURL(url *url.URL) OptionClient

func WithPersonalAccessToken

func WithPersonalAccessToken(token string) OptionClient

type OptionElement added in v0.0.6

type OptionElement func(*elementOptions)

func WithAdministrativeState added in v0.0.6

func WithAdministrativeState(administrativeState models.AdministrativeState) OptionElement

WithAdministrativeState allows setting a specific administrative state.

func WithWaitUntilElementDeployed added in v0.0.11

func WithWaitUntilElementDeployed() OptionElement

func WithWaitUntilElementUndeployed added in v0.0.11

func WithWaitUntilElementUndeployed() OptionElement

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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