containers

package
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package containers manages and retrieves containers in the OpenStack Key Manager Service.

Example to List Containers

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

allContainers, err := containers.ExtractContainers(allPages)
if err != nil {
	panic(err)
}

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

Example to Create a Container

createOpts := containers.CreateOpts{
	Type: containers.GenericContainer,
	Name: "mycontainer",
	SecretRefs: []containers.SecretRef{
		{
			Name: secret.Name,
			SecretRef: secret.SecretRef,
		},
	},
}

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

fmt.Printf("%v\n", container)

Example to Delete a Container

err := containers.Delete(client, containerID).ExtractErr()
if err != nil {
	panic(err)
}

Example to List Consumers of a Container

allPages, err := containers.ListConsumers(client, containerID, nil).AllPages()
if err != nil {
	panic(err)
}

allConsumers, err := containers.ExtractConsumers(allPages)
if err != nil {
	panic(err)
}

fmt.Printf("%v\n", allConsumers)

Example to Create a Consumer of a Container

createOpts := containers.CreateConsumerOpts{
	Name: "jdoe",
	URL:  "http://example.com",
}

container, err := containers.CreateConsumer(client, containerID, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a Consumer of a Container

deleteOpts := containers.DeleteConsumerOpts{
	Name: "jdoe",
	URL:  "http://example.com",
}

container, err := containers.DeleteConsumer(client, containerID, deleteOpts).Extract()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager

List retrieves a list of containers.

func ListConsumers

func ListConsumers(client *gophercloud.ServiceClient, containerID string, opts ListConsumersOptsBuilder) pagination.Pager

ListConsumers retrieves a list of consumers from a container.

Types

type Consumer

type Consumer struct {
	// Created is the date the container was created.
	Created time.Time `json:"-"`

	// Name is the name of the container.
	Name string `json:"name"`

	// Status is the status of the container.
	Status string `json:"status"`

	// Updated is the date the container was updated.
	Updated time.Time `json:"-"`

	// URL is the url to the consumer.
	URL string `json:"url"`
}

Consumer represents a consumer in a container.

func ExtractConsumers

func ExtractConsumers(r pagination.Page) ([]Consumer, error)

ExtractConsumers returns a slice of Consumers contained in a single page of results.

func (*Consumer) UnmarshalJSON

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

type ConsumerPage

type ConsumerPage struct {
	pagination.LinkedPageBase
}

ConsumerPage is a single page of consumer results.

func (ConsumerPage) IsEmpty

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

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

func (ConsumerPage) NextPageURL

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

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

type ConsumerRef

type ConsumerRef struct {
	// Name is the name of the consumer.
	Name string `json:"name"`

	// URL is the URL to the consumer resource.
	URL string `json:"url"`
}

ConsumerRef represents a consumer reference in a container.

type Container

type Container struct {
	// Consumers are the consumers of the container.
	Consumers []ConsumerRef `json:"consumers"`

	// ContainerRef is the URL to the container
	ContainerRef string `json:"container_ref"`

	// Created is the date the container was created.
	Created time.Time `json:"-"`

	// CreatorID is the creator of the container.
	CreatorID string `json:"creator_id"`

	// Name is the name of the container.
	Name string `json:"name"`

	// SecretRefs are the secret references of the container.
	SecretRefs []SecretRef `json:"secret_refs"`

	// Status is the status of the container.
	Status string `json:"status"`

	// Type is the type of container.
	Type string `json:"type"`

	// Updated is the date the container was updated.
	Updated time.Time `json:"-"`
}

Container represents a container in the key manager service.

func ExtractContainers

func ExtractContainers(r pagination.Page) ([]Container, error)

ExtractContainers returns a slice of Containers contained in a single page of results.

func (*Container) UnmarshalJSON

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

type ContainerPage

type ContainerPage struct {
	pagination.LinkedPageBase
}

ContainerPage is a single page of container results.

func (ContainerPage) IsEmpty

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

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

func (ContainerPage) NextPageURL

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

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

type ContainerType

type ContainerType string

ContainerType represents the valid types of containers.

const (
	GenericContainer     ContainerType = "generic"
	RSAContainer         ContainerType = "rsa"
	CertificateContainer ContainerType = "certificate"
)

type CreateConsumerOpts

type CreateConsumerOpts struct {
	// Name is the name of the consumer.
	Name string `json:"name"`

	// URL is the URL to the consumer resource.
	URL string `json:"URL"`
}

CreateConsumerOpts provides options used to create a container.

func (CreateConsumerOpts) ToContainerConsumerCreateMap

func (opts CreateConsumerOpts) ToContainerConsumerCreateMap() (map[string]interface{}, error)

ToContainerConsumerCreateMap formats a CreateConsumerOpts into a create request.

type CreateConsumerOptsBuilder

type CreateConsumerOptsBuilder interface {
	ToContainerConsumerCreateMap() (map[string]interface{}, error)
}

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

type CreateConsumerResult

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

CreateConsumerResult is the response from a CreateConsumer operation. Call its Extract method to interpret it as a container.

func CreateConsumer

func CreateConsumer(client *gophercloud.ServiceClient, containerID string, opts CreateConsumerOptsBuilder) (r CreateConsumerResult)

CreateConsumer creates a new consumer.

func (CreateConsumerResult) Extract

func (r CreateConsumerResult) Extract() (*Container, error)

Extract interprets any commonResult as a Container.

type CreateOpts

type CreateOpts struct {
	// Type represents the type of container.
	Type ContainerType `json:"type" required:"true"`

	// Name is the name of the container.
	Name string `json:"name"`

	// SecretRefs is a list of secret refs for the container.
	SecretRefs []SecretRef `json:"secret_refs,omitempty"`
}

CreateOpts provides options used to create a container.

func (CreateOpts) ToContainerCreateMap

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

ToContainerCreateMap formats a CreateOpts into a create request.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToContainerCreateMap() (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 response from a Create operation. Call its Extract method to interpret it as a container.

func Create

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

Create creates a new container.

func (CreateResult) Extract

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

Extract interprets any commonResult as a Container.

type CreateSecretRefResult

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

CreateSecretRefResult is the response from a CreateSecretRef operation. Call its Extract method to interpret it as a container.

func CreateSecretRef

func CreateSecretRef(client *gophercloud.ServiceClient, containerID string, opts SecretRefBuilder) (r CreateSecretRefResult)

CreateSecret creates a new consumer.

func (CreateSecretRefResult) Extract

func (r CreateSecretRefResult) Extract() (*Container, error)

Extract interprets any CreateSecretRefResult as a Container

type DeleteConsumerOpts

type DeleteConsumerOpts struct {
	// Name is the name of the consumer.
	Name string `json:"name"`

	// URL is the URL to the consumer resource.
	URL string `json:"URL"`
}

DeleteConsumerOpts represents options used for deleting a consumer.

func (DeleteConsumerOpts) ToContainerConsumerDeleteMap

func (opts DeleteConsumerOpts) ToContainerConsumerDeleteMap() (map[string]interface{}, error)

ToContainerConsumerDeleteMap formats a DeleteConsumerOpts into a create request.

type DeleteConsumerOptsBuilder

type DeleteConsumerOptsBuilder interface {
	ToContainerConsumerDeleteMap() (map[string]interface{}, error)
}

DeleteConsumerOptsBuilder allows extensions to add additional parameters to the Delete request.

type DeleteConsumerResult

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

DeleteConsumerResult is the response from a DeleteConsumer operation. Call its Extract to interpret it as a container.

func DeleteConsumer

func DeleteConsumer(client *gophercloud.ServiceClient, containerID string, opts DeleteConsumerOptsBuilder) (r DeleteConsumerResult)

DeleteConsumer deletes a consumer.

func (DeleteConsumerResult) Extract

func (r DeleteConsumerResult) Extract() (*Container, error)

Extract interprets any commonResult as a Container.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult is the response from a Delete operation. Call its ExtractErr to determine if the request succeeded or failed.

func Delete

func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult)

Delete deletes a container.

type DeleteSecretRefResult

type DeleteSecretRefResult struct {
	gophercloud.ErrResult
}

DeleteSecretRefResult is the response from a DeleteSecretRef operation.

func DeleteSecretRef

func DeleteSecretRef(client *gophercloud.ServiceClient, containerID string, opts SecretRefBuilder) (r DeleteSecretRefResult)

DeleteSecret deletes a consumer.

type GetResult

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

GetResult is the response from a Get operation. Call its Extract method to interpret it as a container.

func Get

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

Get retrieves details of a container.

func (GetResult) Extract

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

Extract interprets any commonResult as a Container.

type ListConsumersOpts

type ListConsumersOpts struct {
	// Limit is the amount of consumers to retrieve.
	Limit int `q:"limit"`

	// Offset is the index within the list to retrieve.
	Offset int `q:"offset"`
}

ListConsumersOpts provides options to filter the List results.

type ListConsumersOptsBuilder

type ListConsumersOptsBuilder interface {
	ToContainerListConsumersQuery() (string, error)
}

ListConsumersOptsBuilder allows extensions to add additional parameters to the ListConsumers request

type ListOpts

type ListOpts struct {
	// Limit is the amount of containers to retrieve.
	Limit int `q:"limit"`

	// Name is the name of the container
	Name string `q:"name"`

	// Offset is the index within the list to retrieve.
	Offset int `q:"offset"`
}

ListOpts provides options to filter the List results.

func (ListOpts) ToContainerListConsumersQuery

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

ToContainerListConsumersQuery formats a ListConsumersOpts into a query string.

func (ListOpts) ToContainerListQuery

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

ToContainerListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

ListOptsBuilder allows extensions to add additional parameters to the List request

type SecretRef

type SecretRef struct {
	SecretRef string `json:"secret_ref"`
	Name      string `json:"name"`
}

SecretRef is a reference to a secret.

func (SecretRef) ToContainerSecretRefMap

func (opts SecretRef) ToContainerSecretRefMap() (map[string]interface{}, error)

ToContainerSecretRefMap formats a SecretRefBuilder into a create request.

type SecretRefBuilder

type SecretRefBuilder interface {
	ToContainerSecretRefMap() (map[string]interface{}, error)
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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