openstack

package module
v0.0.0-...-771c80a Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2026 License: BSD-3-Clause Imports: 32 Imported by: 0

README

go-ruby-openstack/openstack

A pure-Go (CGO=0) Ruby-facing OpenStack client. It puts a clean, idiomatic API on top of the reference Go OpenStack SDK gophercloud/v2 — the mature, de-facto pure-Go OpenStack client — the same way go-ruby-confd reuses confd.

gophercloud does all the OpenStack work (Keystone auth, the service catalog, request signing, pagination, the per-service HTTP APIs); this package adds only the importable Ruby-facing surface: a Connection, per-service accessors with list/get/create/update/delete over the core resources, resources as Ruby-style hashes, a typed error tree, and an injectable HTTP transport seam so a consumer such as go-embedded-ruby (rbgo) and its tests can plug in a fake — no live cloud required. The Ruby semantics mirror the fog-openstack gem's collection/model shape.

Install

go get github.com/go-ruby-openstack/openstack@latest

Module path github.com/go-ruby-openstack/openstack; go.mod floor go 1.26 (matching gophercloud/v2). CGO is not used.

Usage

package main

import (
	"context"
	"fmt"

	"github.com/go-ruby-openstack/openstack"
)

func main() {
	conn, err := openstack.Connect(context.Background(), openstack.Options{
		AuthURL:     "https://keystone.example.com/v3", // OS_AUTH_URL
		Username:    "admin",
		Password:    "secret",
		ProjectName: "demo",
		DomainName:  "Default",
		Region:      "RegionOne",
	})
	if err != nil {
		panic(err) // openstack.AuthError on bad credentials
	}

	compute, err := conn.Compute()
	if err != nil {
		panic(err)
	}

	servers, err := compute.Servers() // []openstack.Resource (Ruby hashes)
	if err != nil {
		if openstack.IsNotFound(err) { /* ... */ }
		panic(err)
	}
	for _, s := range servers {
		fmt.Println(s["id"], s["name"], s["status"])
	}

	srv, err := compute.CreateServer(openstack.Resource{
		"name":      "web-1",
		"flavorRef": "2",
		"imageRef":  "cirros-uuid",
	})
	_ = srv
	_ = err
}

A Resource is map[string]any keyed by the resource's wire (snake_case) JSON attributes — the natural shape for a Ruby Hash.

Authentication styles

Options supports password (Username/UserID + Password), token (Token) and application-credential (ApplicationCredentialID/Name + Secret) authentication, each scoped by the project/domain fields.

Injectable transport

Set Options.Transport (an http.RoundTripper) or Options.HTTPClient to feed requests through a fake; the whole test suite runs against an in-process net/http/httptest cloud with no network.

Errors

Connect and every operation return the typed tree, mirroring the Ruby exception hierarchy a binding exposes:

Go type Ruby class gophercloud source
*Error OpenStack::Error transport / 5xx / other
*NotFoundError OpenStack::NotFound HTTP 404
*AuthError OpenStack::AuthError HTTP 401 / auth failure
*ForbiddenError OpenStack::Forbidden HTTP 403
*ConflictError OpenStack::Conflict HTTP 409
*BadRequestError OpenStack::BadRequest HTTP 400

All satisfy the APIError interface (Error(), Status(), Unwrap()). Use the IsNotFound / IsAuth / IsForbidden / IsConflict / IsBadRequest predicates.

Coverage

Core CRUD for the six main services, tested against mocked OpenStack APIs. Advanced / less-common services are not yet wrapped but remain reachable via gophercloud directly against the authenticated Connection.

Service Accessor Resources (list / get / create / update / delete unless noted)
Identity (Keystone v3) conn.Identity() projects, users, roles, domains
Compute (Nova) conn.Compute() servers (+ start/stop/reboot, attach/detach volume), flavors (list/get), keypairs (list/get/create/delete)
Network (Neutron) conn.Network() networks, subnets, ports, routers, security groups, security-group rules (no update), floating IPs
Block Storage (Cinder v3) conn.BlockStorage() volumes, snapshots, volume types
Object Storage (Swift) conn.ObjectStorage() containers (list/create/delete), objects (list / put / get / delete)
Image (Glance v2) conn.Image() images (list/get/create/update/delete) + binary upload

Deferred (use gophercloud directly if needed): Heat/orchestration, LBaaS/Octavia, DNS/Designate, bare-metal/Ironic, shared-file-systems/Manila, key-manager/Barbican, container-infra/Magnum, placement, quotas, per-resource metadata/tags/extra-specs, and the many advanced actions each service exposes.

Testing

100% statement coverage of this package's adapter code (gophercloud is a dependency, not counted), every service's CRUD, authentication and each error branch exercised against an in-process mocked OpenStack API — no live cloud. The suite builds and runs on all six 64-bit architectures (amd64/arm64/riscv64/loong64/ppc64le/s390x). See BENCHMARKS.md.

Licensing

This package is BSD-3-Clause (the go-ruby-openstack/openstack authors).

It imports github.com/gophercloud/gophercloud/v2, which is licensed under Apache-2.0. gophercloud is a normal Go module dependency — imported, never vendored — so its Apache-2.0 license applies to that dependency, not to this code. Downstreams redistributing a binary that links gophercloud should comply with Apache-2.0 for that component.

Documentation

Overview

Package openstack is a pure-Go (no cgo) Ruby-facing OpenStack client. It puts a clean, idiomatic surface on top of the reference Go OpenStack SDK github.com/gophercloud/gophercloud/v2 (Apache-2.0 licensed; imported, never vendored). gophercloud already implements everything that is OpenStack: the Keystone authentication dance, the service catalog, request signing, pagination and the per-service HTTP APIs. This package does not reimplement any of that; it wraps gophercloud and adds the thin conveniences a consumer such as go-embedded-ruby (rbgo) needs to expose an OpenStack client to Ruby:

Scope: the core CRUD for the six main services (Nova, Neutron, Cinder, Swift, Glance, Keystone). The full OpenStack API is enormous; less-common services and advanced per-resource operations are intentionally not wrapped but remain reachable through gophercloud directly against the authenticated Connection. See the README for the exact coverage matrix.

The package has no dependency on any Ruby runtime: the surface is Go-typed, and a Ruby binding layer marshals Ruby values onto these Go types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAuth

func IsAuth(err error) bool

IsAuth reports whether err is (or wraps) an AuthError.

func IsBadRequest

func IsBadRequest(err error) bool

IsBadRequest reports whether err is (or wraps) a BadRequestError.

func IsConflict

func IsConflict(err error) bool

IsConflict reports whether err is (or wraps) a ConflictError.

func IsForbidden

func IsForbidden(err error) bool

IsForbidden reports whether err is (or wraps) a ForbiddenError.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound reports whether err is (or wraps) a NotFoundError.

Types

type APIError

type APIError interface {
	error
	// Status returns the HTTP status code carried by the underlying API
	// response, or 0 when the error did not originate from one.
	Status() int
	// Unwrap exposes the wrapped gophercloud error for errors.Is/As.
	Unwrap() error
}

APIError is implemented by every error this package returns. It mirrors the Ruby exception hierarchy that a binding layer exposes as

OpenStack::Error < StandardError
  OpenStack::NotFound   < OpenStack::Error
  OpenStack::AuthError  < OpenStack::Error
  OpenStack::Forbidden  < OpenStack::Error
  OpenStack::Conflict   < OpenStack::Error
  OpenStack::BadRequest < OpenStack::Error

Every concrete type below satisfies APIError, so a consumer can either type switch, use the Is* predicates, or (in Ruby) rescue the mapped class.

type AuthError

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

AuthError maps gophercloud's 401 responses and authentication failures (OpenStack::AuthError).

func (*AuthError) Error

func (e *AuthError) Error() string

Error implements the error interface.

func (*AuthError) Status

func (e *AuthError) Status() int

Status returns the HTTP status code, or 0 if not from an API response.

func (*AuthError) Unwrap

func (e *AuthError) Unwrap() error

Unwrap returns the wrapped gophercloud error.

type BadRequestError

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

BadRequestError maps gophercloud's 400 responses (OpenStack::BadRequest).

func (*BadRequestError) Error

func (e *BadRequestError) Error() string

Error implements the error interface.

func (*BadRequestError) Status

func (e *BadRequestError) Status() int

Status returns the HTTP status code, or 0 if not from an API response.

func (*BadRequestError) Unwrap

func (e *BadRequestError) Unwrap() error

Unwrap returns the wrapped gophercloud error.

type BlockStorage

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

BlockStorage is the Cinder (v3) service accessor: volumes, snapshots and volume types.

func (*BlockStorage) CreateSnapshot

func (b *BlockStorage) CreateSnapshot(opts Resource) (Resource, error)

CreateSnapshot creates a snapshot (volume_id, name, ...).

func (*BlockStorage) CreateVolume

func (b *BlockStorage) CreateVolume(opts Resource) (Resource, error)

CreateVolume creates a volume (size, name, ...).

func (*BlockStorage) CreateVolumeType

func (b *BlockStorage) CreateVolumeType(opts Resource) (Resource, error)

CreateVolumeType creates a volume type (name, description, ...).

func (*BlockStorage) DeleteSnapshot

func (b *BlockStorage) DeleteSnapshot(id string) error

DeleteSnapshot deletes a snapshot by ID.

func (*BlockStorage) DeleteVolume

func (b *BlockStorage) DeleteVolume(id string) error

DeleteVolume deletes a volume by ID.

func (*BlockStorage) DeleteVolumeType

func (b *BlockStorage) DeleteVolumeType(id string) error

DeleteVolumeType deletes a volume type by ID.

func (*BlockStorage) GetSnapshot

func (b *BlockStorage) GetSnapshot(id string) (Resource, error)

GetSnapshot fetches a snapshot by ID.

func (*BlockStorage) GetVolume

func (b *BlockStorage) GetVolume(id string) (Resource, error)

GetVolume fetches a volume by ID.

func (*BlockStorage) GetVolumeType

func (b *BlockStorage) GetVolumeType(id string) (Resource, error)

GetVolumeType fetches a volume type by ID.

func (*BlockStorage) Snapshots

func (b *BlockStorage) Snapshots() ([]Resource, error)

Snapshots lists all volume snapshots (detailed).

func (*BlockStorage) UpdateSnapshot

func (b *BlockStorage) UpdateSnapshot(id string, opts Resource) (Resource, error)

UpdateSnapshot updates a snapshot (name, description).

func (*BlockStorage) UpdateVolume

func (b *BlockStorage) UpdateVolume(id string, opts Resource) (Resource, error)

UpdateVolume updates a volume (name, description, ...).

func (*BlockStorage) UpdateVolumeType

func (b *BlockStorage) UpdateVolumeType(id string, opts Resource) (Resource, error)

UpdateVolumeType updates a volume type.

func (*BlockStorage) VolumeTypes

func (b *BlockStorage) VolumeTypes() ([]Resource, error)

VolumeTypes lists all volume types.

func (*BlockStorage) Volumes

func (b *BlockStorage) Volumes() ([]Resource, error)

Volumes lists all volumes (detailed).

type Compute

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

Compute is the Nova service accessor, exposing the core CRUD over servers, flavors and keypairs plus server power actions and volume attachment. The shape mirrors fog-openstack's Fog::OpenStack::Compute collections.

func (*Compute) AttachVolume

func (c *Compute) AttachVolume(serverID string, opts Resource) (Resource, error)

AttachVolume attaches a volume to a server; opts carries at least {"volumeId" => "..."}.

func (*Compute) CreateKeypair

func (c *Compute) CreateKeypair(opts Resource) (Resource, error)

CreateKeypair creates (or imports) a keypair from the option hash (name, public_key).

func (*Compute) CreateServer

func (c *Compute) CreateServer(opts Resource) (Resource, error)

CreateServer boots a server from the supplied option hash (name, flavorRef, imageRef, networks, ...).

func (*Compute) DeleteKeypair

func (c *Compute) DeleteKeypair(name string) error

DeleteKeypair deletes a keypair by name.

func (*Compute) DeleteServer

func (c *Compute) DeleteServer(id string) error

DeleteServer deletes a server by ID.

func (*Compute) DetachVolume

func (c *Compute) DetachVolume(serverID, volumeID string) error

DetachVolume detaches a volume from a server.

func (*Compute) Flavor

func (c *Compute) Flavor(id string) (Resource, error)

Flavor fetches a single flavor by ID.

func (*Compute) Flavors

func (c *Compute) Flavors() ([]Resource, error)

Flavors lists all flavors (detailed).

func (*Compute) Keypair

func (c *Compute) Keypair(name string) (Resource, error)

Keypair fetches a single keypair by name.

func (*Compute) Keypairs

func (c *Compute) Keypairs() ([]Resource, error)

Keypairs lists all keypairs.

func (*Compute) RebootServer

func (c *Compute) RebootServer(id, method string) error

RebootServer reboots a server. method is "SOFT" (default) or "HARD".

func (*Compute) Server

func (c *Compute) Server(id string) (Resource, error)

Server fetches a single server by ID.

func (*Compute) Servers

func (c *Compute) Servers() ([]Resource, error)

Servers lists all servers (detailed).

func (*Compute) StartServer

func (c *Compute) StartServer(id string) error

StartServer powers on a stopped server.

func (*Compute) StopServer

func (c *Compute) StopServer(id string) error

StopServer powers off a running server.

func (*Compute) UpdateServer

func (c *Compute) UpdateServer(id string, opts Resource) (Resource, error)

UpdateServer updates a server's mutable attributes (name, ...).

type ConflictError

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

ConflictError maps gophercloud's 409 responses (OpenStack::Conflict).

func (*ConflictError) Error

func (e *ConflictError) Error() string

Error implements the error interface.

func (*ConflictError) Status

func (e *ConflictError) Status() int

Status returns the HTTP status code, or 0 if not from an API response.

func (*ConflictError) Unwrap

func (e *ConflictError) Unwrap() error

Unwrap returns the wrapped gophercloud error.

type Connection

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

Connection is an authenticated OpenStack session. It owns a gophercloud ProviderClient (carrying the token and service catalog) and hands out the per-service accessors below.

func Connect

func Connect(ctx context.Context, opts Options) (*Connection, error)

Connect authenticates against Keystone v3 and returns a ready Connection. A missing AuthURL, or any authentication failure, yields an *AuthError.

func (*Connection) BlockStorage

func (c *Connection) BlockStorage() (*BlockStorage, error)

BlockStorage returns the Cinder (block storage v3) service accessor.

func (*Connection) Compute

func (c *Connection) Compute() (*Compute, error)

Compute returns the Nova (compute) service accessor.

func (*Connection) Identity

func (c *Connection) Identity() (*Identity, error)

Identity returns the Keystone (identity v3) service accessor.

func (*Connection) Image

func (c *Connection) Image() (*Image, error)

Image returns the Glance (image v2) service accessor.

func (*Connection) Network

func (c *Connection) Network() (*Network, error)

Network returns the Neutron (network) service accessor.

func (*Connection) ObjectStorage

func (c *Connection) ObjectStorage() (*ObjectStorage, error)

ObjectStorage returns the Swift (object storage) service accessor.

type Error

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

Error is the generic error returned when no more specific type applies (for example a transport failure or a 5xx response). It is the base of the tree.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

func (*Error) Status

func (e *Error) Status() int

Status returns the HTTP status code, or 0 if not from an API response.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the wrapped gophercloud error.

type ForbiddenError

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

ForbiddenError maps gophercloud's 403 responses (OpenStack::Forbidden).

func (*ForbiddenError) Error

func (e *ForbiddenError) Error() string

Error implements the error interface.

func (*ForbiddenError) Status

func (e *ForbiddenError) Status() int

Status returns the HTTP status code, or 0 if not from an API response.

func (*ForbiddenError) Unwrap

func (e *ForbiddenError) Unwrap() error

Unwrap returns the wrapped gophercloud error.

type Identity

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

Identity is the Keystone (v3) service accessor: projects, users, roles and domains.

func (*Identity) CreateDomain

func (i *Identity) CreateDomain(opts Resource) (Resource, error)

CreateDomain creates a domain (name, description, enabled).

func (*Identity) CreateProject

func (i *Identity) CreateProject(opts Resource) (Resource, error)

CreateProject creates a project (name, domain_id, description, ...).

func (*Identity) CreateRole

func (i *Identity) CreateRole(opts Resource) (Resource, error)

CreateRole creates a role (name, domain_id, ...).

func (*Identity) CreateUser

func (i *Identity) CreateUser(opts Resource) (Resource, error)

CreateUser creates a user (name, domain_id, password, ...).

func (*Identity) DeleteDomain

func (i *Identity) DeleteDomain(id string) error

DeleteDomain deletes a domain by ID.

func (*Identity) DeleteProject

func (i *Identity) DeleteProject(id string) error

DeleteProject deletes a project by ID.

func (*Identity) DeleteRole

func (i *Identity) DeleteRole(id string) error

DeleteRole deletes a role by ID.

func (*Identity) DeleteUser

func (i *Identity) DeleteUser(id string) error

DeleteUser deletes a user by ID.

func (*Identity) Domains

func (i *Identity) Domains() ([]Resource, error)

Domains lists all domains.

func (*Identity) GetDomain

func (i *Identity) GetDomain(id string) (Resource, error)

GetDomain fetches a domain by ID.

func (*Identity) GetProject

func (i *Identity) GetProject(id string) (Resource, error)

GetProject fetches a project by ID.

func (*Identity) GetRole

func (i *Identity) GetRole(id string) (Resource, error)

GetRole fetches a role by ID.

func (*Identity) GetUser

func (i *Identity) GetUser(id string) (Resource, error)

GetUser fetches a user by ID.

func (*Identity) Projects

func (i *Identity) Projects() ([]Resource, error)

Projects lists all projects.

func (*Identity) Roles

func (i *Identity) Roles() ([]Resource, error)

Roles lists all roles.

func (*Identity) UpdateDomain

func (i *Identity) UpdateDomain(id string, opts Resource) (Resource, error)

UpdateDomain updates a domain.

func (*Identity) UpdateProject

func (i *Identity) UpdateProject(id string, opts Resource) (Resource, error)

UpdateProject updates a project.

func (*Identity) UpdateRole

func (i *Identity) UpdateRole(id string, opts Resource) (Resource, error)

UpdateRole updates a role.

func (*Identity) UpdateUser

func (i *Identity) UpdateUser(id string, opts Resource) (Resource, error)

UpdateUser updates a user.

func (*Identity) Users

func (i *Identity) Users() ([]Resource, error)

Users lists all users.

type Image

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

Image is the Glance (v2) service accessor: image records and their data. Glance returns image objects unwrapped, so single results carry no envelope.

func (*Image) CreateImage

func (i *Image) CreateImage(opts Resource) (Resource, error)

CreateImage creates an image record (name, disk_format, container_format, ...). Upload the binary payload separately with UploadImage.

func (*Image) DeleteImage

func (i *Image) DeleteImage(id string) error

DeleteImage deletes an image by ID.

func (*Image) GetImage

func (i *Image) GetImage(id string) (Resource, error)

GetImage fetches an image record by ID.

func (*Image) Images

func (i *Image) Images() ([]Resource, error)

Images lists all images.

func (*Image) UpdateImage

func (i *Image) UpdateImage(id string, opts images.UpdateOpts) (Resource, error)

UpdateImage updates an image record's mutable attributes. Glance uses a JSON patch document, so callers pass a typed images.UpdateOpts (a list of Add/Replace/Remove operations).

func (*Image) UploadImage

func (i *Image) UploadImage(id string, data io.Reader) error

UploadImage streams the binary image payload for a previously-created image.

type Network

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

Network is the Neutron service accessor: networks, subnets, ports, routers, security groups and their rules, and floating IPs.

func (*Network) CreateFloatingIP

func (n *Network) CreateFloatingIP(opts Resource) (Resource, error)

CreateFloatingIP allocates a floating IP (floating_network_id, ...).

func (*Network) CreateNetwork

func (n *Network) CreateNetwork(opts Resource) (Resource, error)

CreateNetwork creates a network from the option hash (name, admin_state_up, ...).

func (*Network) CreatePort

func (n *Network) CreatePort(opts Resource) (Resource, error)

CreatePort creates a port (network_id, ...).

func (*Network) CreateRouter

func (n *Network) CreateRouter(opts Resource) (Resource, error)

CreateRouter creates a router (name, admin_state_up, external_gateway_info, ...).

func (*Network) CreateSecurityGroup

func (n *Network) CreateSecurityGroup(opts Resource) (Resource, error)

CreateSecurityGroup creates a security group (name, description).

func (*Network) CreateSecurityGroupRule

func (n *Network) CreateSecurityGroupRule(opts Resource) (Resource, error)

CreateSecurityGroupRule creates a rule (security_group_id, direction, protocol, port_range_min, ...).

func (*Network) CreateSubnet

func (n *Network) CreateSubnet(opts Resource) (Resource, error)

CreateSubnet creates a subnet (network_id, cidr, ip_version, ...).

func (*Network) DeleteFloatingIP

func (n *Network) DeleteFloatingIP(id string) error

DeleteFloatingIP releases a floating IP by ID.

func (*Network) DeleteNetwork

func (n *Network) DeleteNetwork(id string) error

DeleteNetwork deletes a network by ID.

func (*Network) DeletePort

func (n *Network) DeletePort(id string) error

DeletePort deletes a port by ID.

func (*Network) DeleteRouter

func (n *Network) DeleteRouter(id string) error

DeleteRouter deletes a router by ID.

func (*Network) DeleteSecurityGroup

func (n *Network) DeleteSecurityGroup(id string) error

DeleteSecurityGroup deletes a security group by ID.

func (*Network) DeleteSecurityGroupRule

func (n *Network) DeleteSecurityGroupRule(id string) error

DeleteSecurityGroupRule deletes a rule by ID.

func (*Network) DeleteSubnet

func (n *Network) DeleteSubnet(id string) error

DeleteSubnet deletes a subnet by ID.

func (*Network) FloatingIPs

func (n *Network) FloatingIPs() ([]Resource, error)

FloatingIPs lists all floating IPs.

func (*Network) GetFloatingIP

func (n *Network) GetFloatingIP(id string) (Resource, error)

GetFloatingIP fetches a floating IP by ID.

func (*Network) GetNetwork

func (n *Network) GetNetwork(id string) (Resource, error)

GetNetwork fetches a network by ID.

func (*Network) GetPort

func (n *Network) GetPort(id string) (Resource, error)

GetPort fetches a port by ID.

func (*Network) GetRouter

func (n *Network) GetRouter(id string) (Resource, error)

GetRouter fetches a router by ID.

func (*Network) GetSecurityGroup

func (n *Network) GetSecurityGroup(id string) (Resource, error)

GetSecurityGroup fetches a security group by ID.

func (*Network) GetSecurityGroupRule

func (n *Network) GetSecurityGroupRule(id string) (Resource, error)

GetSecurityGroupRule fetches a security group rule by ID.

func (*Network) GetSubnet

func (n *Network) GetSubnet(id string) (Resource, error)

GetSubnet fetches a subnet by ID.

func (*Network) Networks

func (n *Network) Networks() ([]Resource, error)

Networks lists all networks.

func (*Network) Ports

func (n *Network) Ports() ([]Resource, error)

Ports lists all ports.

func (*Network) Routers

func (n *Network) Routers() ([]Resource, error)

Routers lists all routers.

func (*Network) SecurityGroupRules

func (n *Network) SecurityGroupRules() ([]Resource, error)

SecurityGroupRules lists all security group rules.

func (*Network) SecurityGroups

func (n *Network) SecurityGroups() ([]Resource, error)

SecurityGroups lists all security groups.

func (*Network) Subnets

func (n *Network) Subnets() ([]Resource, error)

Subnets lists all subnets.

func (*Network) UpdateFloatingIP

func (n *Network) UpdateFloatingIP(id string, opts Resource) (Resource, error)

UpdateFloatingIP associates/disassociates a floating IP (port_id).

func (*Network) UpdateNetwork

func (n *Network) UpdateNetwork(id string, opts Resource) (Resource, error)

UpdateNetwork updates a network.

func (*Network) UpdatePort

func (n *Network) UpdatePort(id string, opts Resource) (Resource, error)

UpdatePort updates a port.

func (*Network) UpdateRouter

func (n *Network) UpdateRouter(id string, opts Resource) (Resource, error)

UpdateRouter updates a router.

func (*Network) UpdateSecurityGroup

func (n *Network) UpdateSecurityGroup(id string, opts Resource) (Resource, error)

UpdateSecurityGroup updates a security group.

func (*Network) UpdateSubnet

func (n *Network) UpdateSubnet(id string, opts Resource) (Resource, error)

UpdateSubnet updates a subnet.

type NotFoundError

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

NotFoundError maps gophercloud's 404 responses (OpenStack::NotFound).

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

Error implements the error interface.

func (*NotFoundError) Status

func (e *NotFoundError) Status() int

Status returns the HTTP status code, or 0 if not from an API response.

func (*NotFoundError) Unwrap

func (e *NotFoundError) Unwrap() error

Unwrap returns the wrapped gophercloud error.

type ObjectStorage

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

ObjectStorage is the Swift service accessor: containers and objects. Swift list responses are bare JSON arrays, so the items come back without an envelope key.

func (*ObjectStorage) Containers

func (o *ObjectStorage) Containers() ([]Resource, error)

Containers lists all containers (with metadata).

func (*ObjectStorage) CreateContainer

func (o *ObjectStorage) CreateContainer(name string) error

CreateContainer creates (or updates) a container by name.

func (*ObjectStorage) DeleteContainer

func (o *ObjectStorage) DeleteContainer(name string) error

DeleteContainer deletes an empty container by name.

func (*ObjectStorage) DeleteObject

func (o *ObjectStorage) DeleteObject(container, name string) error

DeleteObject deletes an object from a container.

func (*ObjectStorage) GetObject

func (o *ObjectStorage) GetObject(container, name string) ([]byte, error)

GetObject downloads an object's content from a container.

func (*ObjectStorage) Objects

func (o *ObjectStorage) Objects(container string) ([]Resource, error)

Objects lists the objects (with metadata) in a container.

func (*ObjectStorage) PutObject

func (o *ObjectStorage) PutObject(container, name string, content io.Reader) error

PutObject uploads an object's content into a container.

type Options

type Options struct {
	// AuthURL is the Keystone v3 identity endpoint ("OS_AUTH_URL"), e.g.
	// https://keystone.example.com/v3. Required.
	AuthURL string

	// Username / UserID + Password select password authentication.
	Username string
	UserID   string
	Password string

	// Token authenticates with an existing Keystone token ID.
	Token string

	// Application-credential authentication.
	ApplicationCredentialID     string
	ApplicationCredentialName   string
	ApplicationCredentialSecret string

	// ProjectName / ProjectID and DomainName / DomainID scope the token.
	ProjectName string
	ProjectID   string
	DomainName  string
	DomainID    string

	// Region selects which catalog endpoint to use for every service. Leave
	// empty when the cloud publishes a single region.
	Region string

	// AllowReauth lets gophercloud transparently re-authenticate when the token
	// expires.
	AllowReauth bool

	// Transport is the injectable HTTP transport seam. When non-nil it becomes
	// the RoundTripper of the underlying gophercloud client, letting tests and
	// rbgo supply a fake so no live cloud is needed. Mutually exclusive with
	// HTTPClient (HTTPClient wins when both are set).
	Transport http.RoundTripper

	// HTTPClient, when non-nil, is used verbatim as the gophercloud HTTP client.
	HTTPClient *http.Client
}

Options carries the Keystone v3 authentication parameters plus the pluggable HTTP transport. It mirrors the keyword arguments a Ruby caller passes to OpenStack::Connection.new(auth_url:, username:, password:, project_name:, domain_name:, region:, ...). Three authentication styles are supported:

  • password: Username (or UserID) + Password + a domain;
  • token: Token (an existing Keystone token, scoped by the project fields);
  • application credential: ApplicationCredentialID/Name + Secret.

type Resource

type Resource = map[string]any

Resource is a Ruby-style hash describing a single OpenStack resource. Keys are the resource's JSON attribute names exactly as the OpenStack API returns them (id, name, status, admin_state_up, ...) and values are the decoded JSON scalars, arrays and nested hashes. This is the natural shape for a Ruby binding: it maps directly onto a Ruby Hash.

Conversions read the raw API response rather than re-marshalling gophercloud's typed structs, so the keys are always the wire (snake_case) names even for the few gophercloud structs that omit output JSON tags.

Jump to

Keyboard shortcuts

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