keypairs

package
v3.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package keypairs provides the ability to retrieve and manage keypairs through the Resell v2 API.

Example of getting keypairs in the current domain

allKeypairs, _, err = keypairs.List(context, client)
if err != nil {
  log.Fatal(err)
}
for _, myKeypair := range allKeypairs {
  fmt.Println(myKeypair)
}

Example of creating keypairs in all regions with the same options

newKeypairOptions := keypairs.KeypairOpts{
  Name:      "my_keypair",
  PublicKey: "ssh-rsa public_key_part user0@example.org",
  UserID:    "82a026cae2104e92b999dbe00cdb9435",
}
newKeypairs, _, err := keypairs.Create(client, newKeypairOptions)
if err != nil {
  log.Fatal(err)
}
for _, newKeypair := range newKeypairs {
  fmt.Printf("%v\n", newKeypair)
}

Example of deleting a single keypair of a user

keypairName := "my_keypair"
userID := 82a026cae2104e92b999dbe00cdb9435""
_, err = keypairs.Delete(client, keypairName, userID)
if err != nil {
  log.Fatal(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(client *selvpcclient.Client, name, userID string) (*clientservices.ResponseResult, error)

Delete deletes a single keypair by its name and user ID.

Types

type Keypair

type Keypair struct {
	// Name contains a human-readable name for the keypair.
	Name string `json:"name"`

	// PublicKey contains a public part of the keypair.
	PublicKey string `json:"public_key"`

	// Regions contains a list of OpenStack Identity service regions where users
	// can use this keypair.
	Regions []string `json:"regions"`

	// UserID contains an ID of an OpenStack Identity service user that owns
	// this keypair.
	UserID string `json:"user_id"`
}

Keypair represents a single Resell API Keypair.

func Create

func Create(client *selvpcclient.Client, createOpts KeypairOpts) ([]*Keypair, *clientservices.ResponseResult, error)

Create requests a creation of the keypar with the specified options.

func List

List gets a list of keypairs in the current domain.

type KeypairOpts

type KeypairOpts struct {
	// Name contains a human-readable name for the keypair.
	Name string `json:"name"`

	// PublicKey contains a public part of the keypair.
	PublicKey string `json:"public_key"`

	// Regions contains a list of OpenStack Identity service regions where users
	// can use this keypair.
	Regions []string `json:"regions,omitempty"`

	// UserID contains an ID of an OpenStack Identity service user that owns
	// this keypair.
	UserID string `json:"user_id"`
}

KeypairOpts represents options for the keypair Create request.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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