go-selvpcclient: github.com/selectel/go-selvpcclient/selvpcclient/resell/v2/keypairs Index | Files | Directories

package keypairs

import "github.com/selectel/go-selvpcclient/selvpcclient/resell/v2/keypairs"

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, resellClient)
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(ctx, resellClient, 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(ctx, resellClient, keypairName, userID)
if err != nil {
  log.Fatal(err)
}

Index

Package Files

doc.go requests.go requests_opts.go schemas.go

func Delete Uses

func Delete(ctx context.Context, client *selvpcclient.ServiceClient, name, userID string) (*selvpcclient.ResponseResult, error)

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

type Keypair Uses

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 Uses

func Create(ctx context.Context, client *selvpcclient.ServiceClient, createOpts KeypairOpts) ([]*Keypair, *selvpcclient.ResponseResult, error)

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

func List Uses

func List(ctx context.Context, client *selvpcclient.ServiceClient) ([]*Keypair, *selvpcclient.ResponseResult, error)

List gets a list of keypairs in the current domain.

type KeypairOpts Uses

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

PathSynopsis
testing

Package keypairs imports 6 packages (graph) and is imported by 1 packages. Updated 2019-01-03. Refresh now. Tools for package owners.