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.
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
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.