Documentation
¶
Overview ¶
Package keypair contains functionality for working GCLoud keypairs API resources
Example to List KeyPair
listOpts := keypairs.ListOpts{
}
allPages, err := keypairs.List(client).AllPages()
if err != nil {
panic(err)
}
allKeyPairs, err := keypairs.ExtractKeyPairs(allPages)
if err != nil {
panic(err)
}
for _, keypair := range allKeyPairs {
fmt.Printf("%+v", keypair)
}
Example to Create a KeyPair
createOpts := keypairs.CreateOpts{
Name": "alice",
PublicKey: "",
}
keypairs, err := keypairs.Create(client, createOpts).Extract()
if err != nil {
panic(err)
}
Example to Delete a KeyPair
keypairID := "alica"
err := keypairs.Delete(client, keypairID).ExtractErr()
if err != nil {
panic(err)
}
Index ¶
- func ExtractKeyPairsInto(r pagination.Page, v interface{}) error
- func IDFromName(client *gcorecloud.ServiceClient, name string) (string, error)
- func List(c *gcorecloud.ServiceClient) pagination.Pager
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type GetResult
- type KeyPair
- type KeyPairPage
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractKeyPairsInto ¶
func ExtractKeyPairsInto(r pagination.Page, v interface{}) error
func IDFromName ¶
func IDFromName(client *gcorecloud.ServiceClient, name string) (string, error)
IDFromName is a convenience function that returns a keypair ID, given its name.
func List ¶
func List(c *gcorecloud.ServiceClient) pagination.Pager
Types ¶
type CreateOpts ¶
type CreateOpts struct {
Name string `json:"sshkey_name" required:"true"`
PublicKey string `json:"public_key" required:"true"`
}
CreateOpts represents options used to create a keypair.
func (CreateOpts) ToKeyPairCreateMap ¶
func (opts CreateOpts) ToKeyPairCreateMap() (map[string]interface{}, error)
ToKeyPairCreateMap builds a request body from CreateOpts.
type CreateOptsBuilder ¶
CreateOptsBuilder allows extensions to add additional parameters to the Create request.
type CreateResult ¶
type CreateResult struct {
// contains filtered or unexported fields
}
CreateResult represents the result of a create operation. Call its Extract method to interpret it as a KeyPair.
func Create ¶
func Create(c *gcorecloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create accepts a CreateOpts struct and creates a new keypair using the values provided.
func (CreateResult) Extract ¶
Extract is a function that accepts a result and extracts a keypair resource.
func (CreateResult) ExtractInto ¶
func (r CreateResult) ExtractInto(v interface{}) error
type DeleteResult ¶
type DeleteResult struct {
gcorecloud.ErrResult
}
DeleteResult represents the result of a delete operation
func Delete ¶
func Delete(c *gcorecloud.ServiceClient, keypairID string) (r DeleteResult)
Delete accepts a unique ID and deletes the keypair associated with it.
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult represents the result of a get operation. Call its Extract method to interpret it as a KeyPair.
func Get ¶
func Get(c *gcorecloud.ServiceClient, id string) (r GetResult)
Get retrieves a specific keypair based on its name or ID.
func (GetResult) Extract ¶
Extract is a function that accepts a result and extracts a keypair resource.
func (GetResult) ExtractInto ¶
func (r GetResult) ExtractInto(v interface{}) error
type KeyPair ¶
type KeyPair struct {
Name string `json:"sshkey_name"`
ID string `json:"sshkey_id"`
Fingerprint string `json:"fingerprint"`
PublicKey string `json:"public_key"`
PrivateKey *string `json:"private_key"`
}
KeyPair represents a keypair structure.
func ExtractKeyPairs ¶
func ExtractKeyPairs(r pagination.Page) ([]KeyPair, error)
ExtractKeyPair accepts a Page struct, specifically a KeyPairPage struct, and extracts the elements into a slice of KeyPair structs. In other words, a generic collection is mapped into a relevant slice.
type KeyPairPage ¶
type KeyPairPage struct {
pagination.LinkedPageBase
}
KeyPairPage is the page returned by a pager when traversing over a collection of keypairs.
func (KeyPairPage) IsEmpty ¶
func (r KeyPairPage) IsEmpty() (bool, error)
IsEmpty checks whether a KeyPairPage struct is empty.
func (KeyPairPage) NextPageURL ¶
func (r KeyPairPage) NextPageURL() (string, error)
NextPageURL is invoked when a paginated collection of keypairs has reached the end of a page and the pager seeks to traverse over a new one. In order to do this, it needs to construct the next page's URL.
type UpdateResult ¶
type UpdateResult struct {
// contains filtered or unexported fields
}
UpdateResult represents the result of an update operation. Call its Extract method to interpret it as a KeyPair.
func (UpdateResult) Extract ¶
Extract is a function that accepts a result and extracts a keypair resource.
func (UpdateResult) ExtractInto ¶
func (r UpdateResult) ExtractInto(v interface{}) error