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, 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 ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
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.
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(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 ¶
func List(ctx context.Context, client *selvpcclient.ServiceClient) ([]*Keypair, *selvpcclient.ResponseResult, error)
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.
Click to show internal directories.
Click to hide internal directories.