oci

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2017 License: MPL-2.0, MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseTestConfig

func BaseTestConfig() (*ini.File, *os.File, error)

BaseTestConfig creates the base (DEFAULT) config including a temporary key file. NOTE: Caller is responsible for removing temporary key file.

func LoadConfigsFromFile

func LoadConfigsFromFile(path string) (map[string]*Config, error)

LoadConfigsFromFile loads all oracle oci configurations from a file (generally ~/.oci/config).

func LoadPrivateKey

func LoadPrivateKey(config *Config) (*rsa.PrivateKey, error)

LoadPrivateKey loads private key from disk and parses it.

func ParsePrivateKey

func ParsePrivateKey(content, password []byte) (*rsa.PrivateKey, error)

ParsePrivateKey parses a PEM encoded array of bytes into an rsa.PrivateKey. Attempts to decrypt the PEM encoded array of bytes with the given password if the PEM encoded byte array is encrypted.

func WriteTestConfig

func WriteTestConfig(cfg *ini.File) (*os.File, error)

WriteTestConfig writes a ini.File to a temporary file for use in unit tests. NOTE: Caller is responsible for removing temporary file.

Types

type APIError

type APIError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

APIError encapsulates an error returned from the API

func (APIError) Error

func (e APIError) Error() string

type Client

type Client struct {
	UserAgent string
	Compute   *ComputeClient
	Config    *Config
}

Client is the main interface through which consumers interact with the OCI API.

func NewClient

func NewClient(config *Config) (*Client, error)

NewClient creates a new Client for communicating with the OCI API.

type ComputeClient

type ComputeClient struct {
	BaseURL         string
	Instances       *InstanceService
	Images          *ImageService
	VNICAttachments *VNICAttachmentService
	VNICs           *VNICService
}

ComputeClient is a client for the OCI Compute API.

func NewComputeClient

func NewComputeClient(s *baseClient) *ComputeClient

NewComputeClient creates a new client for communicating with the OCI Compute API.

type Config

type Config struct {
	// User OCID e.g. ocid1.user.oc1..aaaaaaaadcshyehbkvxl7arse3lv7z5oknexjgfhnhwidtugsxhlm4247
	User string `ini:"user"`

	// User's Tenancy OCID e.g. ocid1.tenancy.oc1..aaaaaaaagtgvshv6opxzjyzkupkt64ymd32n6kbomadanpcg43d
	Tenancy string `ini:"tenancy"`

	// Bare metal region identifier (e.g. us-phoenix-1)
	Region string `ini:"region"`

	// Hex key fingerprint (e.g. b5:a0:62:57:28:0d:fd:c9:59:16:eb:d4:51:9f:70:e4)
	Fingerprint string `ini:"fingerprint"`

	// Path to OCI config file (e.g. ~/.oci/config)
	KeyFile string `ini:"key_file"`

	// Passphrase used for the key, if it is encrypted.
	PassPhrase string `ini:"pass_phrase"`

	// Private key (loaded via LoadPrivateKey or ParsePrivateKey)
	Key *rsa.PrivateKey
	// contains filtered or unexported fields
}

Config API authentication and target configuration

type CreateImageParams

type CreateImageParams struct {
	CompartmentID string `json:"compartmentId"`
	DisplayName   string `json:"displayName,omitempty"`
	InstanceID    string `json:"instanceId"`
}

CreateImageParams are the parameters available when communicating with the CreateImage API endpoint.

type DeleteImageParams

type DeleteImageParams struct {
	ID string `url:"imageId"`
}

DeleteImageParams are the parameters available when communicating with the DeleteImage API endpoint.

type GetImageParams

type GetImageParams struct {
	ID string `url:"imageId"`
}

GetImageParams are the paramaters available when communicating with the GetImage API endpoint.

type GetInstanceParams

type GetInstanceParams struct {
	ID string `url:"instanceId,omitempty"`
}

GetInstanceParams are the paramaters available when communicating with the GetInstance API endpoint.

type GetVNICParams

type GetVNICParams struct {
	ID string `url:"vnicId"`
}

GetVNICParams are the paramaters available when communicating with the ListVNICs API endpoint.

type Image

type Image struct {
	// The OCID of the image originally used to launch the instance.
	BaseImageID string `json:"baseImageId,omitempty"`

	// The OCID of the compartment containing the instance you want to use
	// as the basis for the image.
	CompartmentID string `json:"compartmentId"`

	// Whether instances launched with this image can be used to create new
	// images.
	CreateImageAllowed bool `json:"createImageAllowed"`

	// A user-friendly name for the image. It does not have to be unique,
	// and it's changeable. You cannot use an Oracle-provided image name
	// as a custom image name.
	DisplayName string `json:"displayName,omitempty"`

	// The OCID of the image.
	ID string `json:"id"`

	// Current state of the image. Allowed values are:
	//  - PROVISIONING
	//  - AVAILABLE
	//  - DISABLED
	//  - DELETED
	LifecycleState string `json:"lifecycleState"`

	// The image's operating system (e.g. Oracle Linux).
	OperatingSystem string `json:"operatingSystem"`

	// The image's operating system version (e.g. 7.2).
	OperatingSystemVersion string `json:"operatingSystemVersion"`

	// The date and time the image was created.
	TimeCreated time.Time `json:"timeCreated"`
}

Image details a OCI boot disk image.

type ImageService

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

ImageService enables communicating with the OCI compute API's instance related endpoints.

func NewImageService

func NewImageService(s *baseClient) *ImageService

NewImageService creates a new ImageService for communicating with the OCI compute API's instance related endpoints.

func (*ImageService) Create

func (s *ImageService) Create(params *CreateImageParams) (Image, error)

Create creates a new custom image based on a running compute instance. It does *not* wait for the imaging process to finish.

func (*ImageService) Delete

func (s *ImageService) Delete(params *DeleteImageParams) error

Delete deletes an existing custom image. NOTE: Deleting an image results in the API endpoint returning 404 on subsequent calls. As such deletion can't be waited on with a Waiter.

func (*ImageService) Get

func (s *ImageService) Get(params *GetImageParams) (Image, error)

Get returns a single Image

func (*ImageService) GetResourceState

func (s *ImageService) GetResourceState(id string) (string, error)

GetResourceState GETs the LifecycleState of the given image id.

type Instance

type Instance struct {
	// The Availability Domain the instance is running in.
	AvailabilityDomain string `json:"availabilityDomain"`

	// The OCID of the compartment that contains the instance.
	CompartmentID string `json:"compartmentId"`

	// A user-friendly name. Does not have to be unique, and it's changeable.
	DisplayName string `json:"displayName,omitempty"`

	// The OCID of the instance.
	ID string `json:"id"`

	// The image used to boot the instance.
	ImageID string `json:"imageId,omitempty"`

	// The current state of the instance. Allowed values:
	//  - PROVISIONING
	//  - RUNNING
	//  - STARTING
	//  - STOPPING
	//  - STOPPED
	//  - CREATING_IMAGE
	//  - TERMINATING
	//  - TERMINATED
	LifecycleState string `json:"lifecycleState"`

	// Custom metadata that you provide.
	Metadata map[string]string `json:"metadata,omitempty"`

	// The region that contains the Availability Domain the instance is running in.
	Region string `json:"region"`

	// The shape of the instance. The shape determines the number of CPUs
	// and the amount of memory allocated to the instance.
	Shape string `json:"shape"`

	// The date and time the instance was created.
	TimeCreated time.Time `json:"timeCreated"`
}

Instance details a OCI compute instance.

type InstanceService

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

InstanceService enables communicating with the OCI compute API's instance related endpoints.

func NewInstanceService

func NewInstanceService(s *baseClient) *InstanceService

NewInstanceService creates a new InstanceService for communicating with the OCI compute API's instance related endpoints.

func (*InstanceService) Get

func (s *InstanceService) Get(params *GetInstanceParams) (Instance, error)

Get returns a single Instance

func (*InstanceService) GetResourceState

func (s *InstanceService) GetResourceState(id string) (string, error)

GetResourceState GETs the LifecycleState of the given instance id.

func (*InstanceService) Launch

func (s *InstanceService) Launch(params *LaunchInstanceParams) (Instance, error)

Launch creates a new OCI compute instance. It does *not* wait for the instance to boot.

func (*InstanceService) Terminate

func (s *InstanceService) Terminate(params *TerminateInstanceParams) error

Terminate terminates a running OCI compute instance. instance to boot.

type LaunchInstanceParams

type LaunchInstanceParams struct {
	AvailabilityDomain string            `json:"availabilityDomain,omitempty"`
	CompartmentID      string            `json:"compartmentId,omitempty"`
	DisplayName        string            `json:"displayName,omitempty"`
	ImageID            string            `json:"imageId,omitempty"`
	Metadata           map[string]string `json:"metadata,omitempty"`
	OPCiPXEScript      string            `json:"opcIpxeScript,omitempty"`
	Shape              string            `json:"shape,omitempty"`
	SubnetID           string            `json:"subnetId,omitempty"`
}

LaunchInstanceParams are the parameters available when communicating with the LunchInstance API endpoint.

type ListVnicAttachmentsParams

type ListVnicAttachmentsParams struct {
	AvailabilityDomain string `url:"availabilityDomain,omitempty"`
	CompartmentID      string `url:"compartmentId"`
	InstanceID         string `url:"instanceId,omitempty"`
	VNICID             string `url:"vnicId,omitempty"`
}

ListVnicAttachmentsParams are the paramaters available when communicating with the ListVnicAttachments API endpoint.

type TerminateInstanceParams

type TerminateInstanceParams struct {
	ID string `url:"instanceId,omitempty"`
}

TerminateInstanceParams are the parameters available when communicating with the TerminateInstance API endpoint.

type Transport

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

Transport adds OCI signature authentication to each outgoing request.

func NewTransport

func NewTransport(transport http.RoundTripper, config *Config) *Transport

NewTransport creates a new Transport to add OCI signature authentication to each outgoing request.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

type VNIC

type VNIC struct {
	AvailabilityDomain string    `json:"availabilityDomain"`
	CompartmentID      string    `json:"compartmentId"`
	DisplayName        string    `json:"displayName,omitempty"`
	ID                 string    `json:"id"`
	LifecycleState     string    `json:"lifecycleState"`
	PrivateIP          string    `json:"privateIp"`
	PublicIP           string    `json:"publicIp"`
	SubnetID           string    `json:"subnetId"`
	TimeCreated        time.Time `json:"timeCreated"`
}

VNIC - a virtual network interface card.

type VNICAttachment

type VNICAttachment struct {
	AvailabilityDomain string    `json:"availabilityDomain"`
	CompartmentID      string    `json:"compartmentId"`
	DisplayName        string    `json:"displayName,omitempty"`
	ID                 string    `json:"id"`
	InstanceID         string    `json:"instanceId"`
	LifecycleState     string    `json:"lifecycleState"`
	SubnetID           string    `json:"subnetId"`
	TimeCreated        time.Time `json:"timeCreated"`
	VNICID             string    `json:"vnicId"`
}

VNICAttachment details the attachment of a VNIC to a OCI instance.

type VNICAttachmentService

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

VNICAttachmentService enables communicating with the OCI compute API's VNIC attachment endpoint.

func NewVNICAttachmentService

func NewVNICAttachmentService(s *baseClient) *VNICAttachmentService

NewVNICAttachmentService creates a new VNICAttachmentService for communicating with the OCI compute API's instance related endpoints.

func (*VNICAttachmentService) List

List returns an array of VNICAttachments.

type VNICService

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

VNICService enables communicating with the OCI compute API's VNICs endpoint.

func NewVNICService

func NewVNICService(s *baseClient) *VNICService

NewVNICService creates a new VNICService for communicating with the OCI compute API's instance related endpoints.

func (*VNICService) Get

func (s *VNICService) Get(params *GetVNICParams) (VNIC, error)

Get returns an individual VNIC.

type WaitableService

type WaitableService interface {
	GetResourceState(id string) (string, error)
}

type Waiter

type Waiter struct {
	WaitDurationMS int
	MaxRetries     int
}

func NewWaiter

func NewWaiter() *Waiter

NewWaiter creates a waiter with default wait duration and unlimited retry operations.

func (*Waiter) WaitForResourceToReachState

func (w *Waiter) WaitForResourceToReachState(svc WaitableService, id string, waitStates []string, terminalState string) error

WaitForResourceToReachState polls a resource that implements WaitableService repeatedly until it reaches a known state or fails if it reaches an unexpected state. The duration of the interval and number of polls is determined by the Waiter configuration.

Jump to

Keyboard shortcuts

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