tsigkeys

package
v2.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package tsigkeys provides information and interaction with the TSIG key API resource for the OpenStack DNS service.

TSIG (Transaction SIGnature) keys are used to authenticate DNS transactions between servers, such as zone transfers and dynamic updates.

Example to List TSIG Keys

listOpts := tsigkeys.ListOpts{
	Scope: "POOL",
}

allPages, err := tsigkeys.List(dnsClient, listOpts).AllPages(context.TODO())
if err != nil {
	panic(err)
}

allTSIGKeys, err := tsigkeys.ExtractTSIGKeys(allPages)
if err != nil {
	panic(err)
}

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

Example to Create a TSIG Key

createOpts := tsigkeys.CreateOpts{
	Name:       "mytsigkey",
	Algorithm:  "hmac-sha256",
	Secret:     "example-secret-key-value==",
	Scope:      "POOL",
	ResourceID: "pool-id-here",
}

tsigkey, err := tsigkeys.Create(context.TODO(), dnsClient, createOpts).Extract()
if err != nil {
	panic(err)
}

Example to Get a TSIG Key

tsigkeyID := "99d10f68-5623-4491-91a0-6daafa32b60e"
tsigkey, err := tsigkeys.Get(context.TODO(), dnsClient, tsigkeyID).Extract()
if err != nil {
	panic(err)
}

Example to Update a TSIG Key

tsigkeyID := "99d10f68-5623-4491-91a0-6daafa32b60e"
updateOpts := tsigkeys.UpdateOpts{
	Name:   "updatedname",
	Secret: "updated-secret-key-value==",
}

tsigkey, err := tsigkeys.Update(context.TODO(), dnsClient, tsigkeyID, updateOpts).Extract()
if err != nil {
	panic(err)
}

Example to Delete a TSIG Key

tsigkeyID := "99d10f68-5623-4491-91a0-6daafa32b60e"
err := tsigkeys.Delete(context.TODO(), dnsClient, tsigkeyID).ExtractErr()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

List implements a TSIG key List request.

Types

type CreateOpts

type CreateOpts struct {
	// Name of the TSIG key.
	Name string `json:"name" required:"true"`

	// Algorithm is the TSIG algorithm (e.g., hmac-sha256, hmac-sha512).
	Algorithm string `json:"algorithm" required:"true"`

	// Secret is the base64-encoded secret key.
	Secret string `json:"secret" required:"true"`

	// Scope defines the scope of the TSIG key (ZONE or POOL).
	Scope string `json:"scope" required:"true"`

	// ResourceID is the ID of the resource (zone or pool) this key is associated with.
	ResourceID string `json:"resource_id" required:"true"`
}

CreateOpts specifies the attributes used to create a TSIG key.

func (CreateOpts) ToTSIGKeyCreateMap

func (opts CreateOpts) ToTSIGKeyCreateMap() (map[string]any, error)

ToTSIGKeyCreateMap formats a CreateOpts structure into a request body.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToTSIGKeyCreateMap() (map[string]any, error)
}

CreateOptsBuilder allows extensions to add additional attributes to the Create request.

type CreateResult

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

CreateResult is the result of a Create request. Call its Extract method to interpret the result as a TSIGKey.

func Create

Create implements a TSIG key create request.

func (CreateResult) Extract

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

Extract interprets a GetResult, CreateResult or UpdateResult as a TSIGKey. An error is returned if the original call or the extraction failed.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult is the result of a Delete request. Call its ExtractErr method to determine if the request succeeded or failed.

func Delete

func Delete(ctx context.Context, client *gophercloud.ServiceClient, tsigkeyID string) (r DeleteResult)

Delete implements a TSIG key delete request.

type GetResult

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

GetResult is the result of a Get request. Call its Extract method to interpret the result as a TSIGKey.

func Get

func Get(ctx context.Context, client *gophercloud.ServiceClient, tsigkeyID string) (r GetResult)

Get returns information about a TSIG key, given its ID.

func (GetResult) Extract

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

Extract interprets a GetResult, CreateResult or UpdateResult as a TSIGKey. An error is returned if the original call or the extraction failed.

type ListOpts

type ListOpts struct {
	// Integer value for the limit of values to return.
	Limit int `q:"limit"`

	// UUID of the TSIG key at which you want to set a marker.
	Marker string `q:"marker"`

	// Name of the TSIG key.
	Name string `q:"name"`

	// Algorithm used by the TSIG key.
	Algorithm string `q:"algorithm"`

	// Scope of the TSIG key (ZONE or POOL).
	Scope string `q:"scope"`
}

ListOpts allows the filtering and sorting of paginated collections through the API. Filtering is achieved by passing in struct field values that map to the server attributes you want to see returned. Marker and Limit are used for pagination. https://docs.openstack.org/api-ref/dns/

func (ListOpts) ToTSIGKeyListQuery

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

ToTSIGKeyListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

ListOptsBuilder allows extensions to add parameters to the List request.

type TSIGKey

type TSIGKey struct {
	// ID uniquely identifies this TSIG key.
	ID string `json:"id"`

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

	// Algorithm is the TSIG algorithm used (e.g., hmac-sha256, hmac-sha512).
	Algorithm string `json:"algorithm"`

	// Secret is the base64-encoded secret key.
	Secret string `json:"secret"`

	// Scope defines the scope of the TSIG key (ZONE or POOL).
	Scope string `json:"scope"`

	// ResourceID is the ID of the resource (zone or pool) this key is associated with.
	ResourceID string `json:"resource_id"`

	// CreatedAt is the date when the TSIG key was created.
	CreatedAt time.Time `json:"-"`

	// UpdatedAt is the date when the TSIG key was last updated.
	UpdatedAt time.Time `json:"-"`

	// Links includes HTTP references to the itself.
	Links map[string]any `json:"links"`
}

TSIGKey represents a TSIG key for DNS transaction authentication.

func ExtractTSIGKeys

func ExtractTSIGKeys(r pagination.Page) ([]TSIGKey, error)

ExtractTSIGKeys extracts a slice of TSIGKeys from a List result.

func (*TSIGKey) UnmarshalJSON

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

type TSIGKeyPage

type TSIGKeyPage struct {
	pagination.LinkedPageBase
}

TSIGKeyPage is a single page of TSIGKey results.

func (TSIGKeyPage) IsEmpty

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

IsEmpty returns true if the page contains no results.

type UpdateOpts

type UpdateOpts struct {
	// Name of the TSIG key.
	Name string `json:"name,omitempty"`

	// Algorithm is the TSIG algorithm.
	Algorithm string `json:"algorithm,omitempty"`

	// Secret is the base64-encoded secret key.
	Secret string `json:"secret,omitempty"`

	// Scope defines the scope of the TSIG key.
	Scope string `json:"scope,omitempty"`

	// ResourceID is the ID of the resource this key is associated with.
	ResourceID string `json:"resource_id,omitempty"`
}

UpdateOpts specifies the attributes to update a TSIG key.

func (UpdateOpts) ToTSIGKeyUpdateMap

func (opts UpdateOpts) ToTSIGKeyUpdateMap() (map[string]any, error)

ToTSIGKeyUpdateMap formats an UpdateOpts structure into a request body.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToTSIGKeyUpdateMap() (map[string]any, error)
}

UpdateOptsBuilder allows extensions to add additional attributes to the Update request.

type UpdateResult

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

UpdateResult is the result of an Update request. Call its Extract method to interpret the result as a TSIGKey.

func Update

func Update(ctx context.Context, client *gophercloud.ServiceClient, tsigkeyID string, opts UpdateOptsBuilder) (r UpdateResult)

Update implements a TSIG key update request.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*TSIGKey, error)

Extract interprets a GetResult, CreateResult or UpdateResult as a TSIGKey. An error is returned if the original call or the extraction failed.

Directories

Path Synopsis
tsigkeys unit tests
tsigkeys unit tests

Jump to

Keyboard shortcuts

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