tags

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2021 License: Apache-2.0 Imports: 1 Imported by: 8

Documentation

Overview

Package tags manages Tags on Compute V2 servers.

This extension is available since 2.26 Compute V2 API microversion.

Example to List all server Tags

	client.Microversion = "2.26"

    serverTags, err := tags.List(client, serverID).Extract()
    if err != nil {
        log.Fatal(err)
    }

    fmt.Printf("Tags: %v\n", serverTags)

Example to Check if the specific Tag exists on a server

client.Microversion = "2.26"

exists, err := tags.Check(client, serverID, tag).Extract()
if err != nil {
    log.Fatal(err)
}

if exists {
    log.Printf("Tag %s is set\n", tag)
} else {
    log.Printf("Tag %s is not set\n", tag)
}

Example to Replace all Tags on a server

client.Microversion = "2.26"

newTags, err := tags.ReplaceAll(client, serverID, tags.ReplaceAllOpts{Tags: []string{"foo", "bar"}}).Extract()
if err != nil {
    log.Fatal(err)
}

fmt.Printf("New tags: %v\n", newTags)

Example to Add a new Tag on a server

client.Microversion = "2.26"

err := tags.Add(client, serverID, "foo").ExtractErr()
if err != nil {
    log.Fatal(err)
}

Example to Delete a Tag on a server

client.Microversion = "2.26"

err := tags.Delete(client, serverID, "foo").ExtractErr()
if err != nil {
    log.Fatal(err)
}

Example to Delete all Tags on a server

client.Microversion = "2.26"

err := tags.DeleteAll(client, serverID).ExtractErr()
if err != nil {
    log.Fatal(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddResult added in v0.5.0

type AddResult struct {
	gophercloud.ErrResult
}

AddResult is the result from the Add operation.

func Add added in v0.5.0

func Add(client *gophercloud.ServiceClient, serverID, tag string) (r AddResult)

Add adds a new Tag on a server.

type CheckResult

type CheckResult struct {
	gophercloud.Result
}

CheckResult is the result from the Check operation.

func Check

func Check(client *gophercloud.ServiceClient, serverID, tag string) (r CheckResult)

Check if a tag exists on a server.

func (CheckResult) Extract

func (r CheckResult) Extract() (bool, error)

type DeleteResult added in v0.5.0

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult is the result from the Delete operation.

func Delete added in v0.5.0

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

Delete removes a tag from a server.

func DeleteAll added in v0.5.0

func DeleteAll(client *gophercloud.ServiceClient, serverID string) (r DeleteResult)

DeleteAll removes all tag from a server.

type ListResult

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

func List

func List(client *gophercloud.ServiceClient, serverID string) (r ListResult)

List all tags on a server.

func (ListResult) Extract

func (r ListResult) Extract() ([]string, error)

Extract is a function that accepts a result and extracts a tags resource.

type ReplaceAllOpts added in v0.5.0

type ReplaceAllOpts struct {
	Tags []string `json:"tags" required:"true"`
}

ReplaceAllOpts provides options used to replace Tags on a server.

func (ReplaceAllOpts) ToTagsReplaceAllMap added in v0.5.0

func (opts ReplaceAllOpts) ToTagsReplaceAllMap() (map[string]interface{}, error)

ToTagsReplaceAllMap formats a ReplaceALlOpts into the body of the ReplaceAll request.

type ReplaceAllOptsBuilder added in v0.5.0

type ReplaceAllOptsBuilder interface {
	ToTagsReplaceAllMap() (map[string]interface{}, error)
}

ReplaceAllOptsBuilder allows to add additional parameters to the ReplaceAll request.

type ReplaceAllResult added in v0.5.0

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

ReplaceAllResult is the result from the ReplaceAll operation.

func ReplaceAll added in v0.5.0

func ReplaceAll(client *gophercloud.ServiceClient, serverID string, opts ReplaceAllOptsBuilder) (r ReplaceAllResult)

ReplaceAll replaces all Tags on a server.

func (ReplaceAllResult) Extract added in v0.5.0

func (r ReplaceAllResult) Extract() ([]string, error)

Extract is a function that accepts a result and extracts a tags resource.

Directories

Path Synopsis
tags unit tests
tags unit tests

Jump to

Keyboard shortcuts

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