profiles

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: Apache-2.0 Imports: 6 Imported by: 9

Documentation

Overview

Package profiles provides information and interaction with profiles through the OpenStack Clustering service.

Example to Create a Profile

networks := []map[string]interface{} {
	{"network": "test-network"},
}

props := map[string]interface{}{
	"name":            "test_gophercloud_profile",
	"flavor":          "t2.micro",
	"image":           "centos7.3-latest",
	"networks":        networks,
	"security_groups": "",
}

createOpts := profiles.CreateOpts {
	Name: "test_profile",
	Spec: profiles.Spec{
		Type:       "os.nova.server",
		Version:    "1.0",
		Properties: props,
	},
}

profile, err := profiles.Create(serviceClient, createOpts).Extract()
if err != nil {
	panic(err)
}

fmt.Println("Profile", profile)

Example to Get a Profile

profile, err := profiles.Get(serviceClient, "profile-name").Extract()
if err != nil {
	panic(err)
}

fmt.Print("profile", profile)

Example to List Profiles

listOpts := profiles.ListOpts{
	Limit: 2,
}

profiles.List(serviceClient, listOpts).EachPage(func(page pagination.Page) (bool, error) {
	allProfiles, err := profiles.ExtractProfiles(page)
	if err != nil {
		panic(err)
	}

	for _, profile := range allProfiles {
		fmt.Printf("%+v\n", profile)
	}
	return true, nil
})

Example to Update a Profile

updateOpts := profiles.UpdateOpts{
	Name: "new-name",
}

profile, err := profiles.Update(serviceClient, profileName, updateOpts).Extract()
if err != nil {
	panic(err)
}

fmt.Print("profile", profile)

Example to Delete a Profile

profileID := "6dc6d336e3fc4c0a951b5698cd1236ee"
err := profiles.Delete(serviceClient, profileID).ExtractErr()
if err != nil {
	panic(err)
}

Example to Validate a profile

serviceClient.Microversion = "1.2"

validateOpts := profiles.ValidateOpts{
	Spec: profiles.Spec{
		Properties: map[string]interface{}{
			"flavor":   "t2.micro",
			"image":    "cirros-0.3.4-x86_64-uec",
			"key_name": "oskey",
			"name":     "cirros_server",
			"networks": []interface{}{
				map[string]interface{}{"network": "private"},
			},
		},
		Type:    "os.nova.server",
		Version: "1.0",
	},
}

profile, err := profiles.Validate(serviceClient, validateOpts).Extract()
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

List instructs OpenStack to provide a list of profiles.

Types

type CreateOpts

type CreateOpts struct {
	Name     string                 `json:"name" required:"true"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
	Spec     Spec                   `json:"spec" required:"true"`
}

CreateOpts represents options used for creating a profile.

func (CreateOpts) ToProfileCreateMap

func (opts CreateOpts) ToProfileCreateMap() (map[string]interface{}, error)

ToProfileCreateMap constructs a request body from CreateOpts.

type CreateOptsBuilder

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

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

type CreateResult

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

CreateResult is the result of a Create operation. Call its Extract method to interpret it as a Profile.

func Create

func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)

Create requests the creation of a new profile on the server.

func (CreateResult) Extract

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

Extract provides access to Profile returned by the Get and Create functions.

type DeleteResult

type DeleteResult struct {
	gophercloud.ErrResult
}

DeleteResult is the result from a Delete operation. Call its ExtractErr method to determine if the call succeeded or failed.

func Delete

func Delete(client *gophercloud.ServiceClient, id string) (r DeleteResult)

Delete deletes the specified profile via profile id.

type GetResult

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

GetResult is the result of a Get operations. Call its Extract method to interpret it as a Profile.

func Get

func Get(client *gophercloud.ServiceClient, id string) (r GetResult)

Get retrieves detail of a single profile.

func (GetResult) Extract

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

Extract provides access to Profile returned by the Get and Create functions.

type ListOpts

type ListOpts struct {
	GlobalProject *bool  `q:"global_project"`
	Limit         int    `q:"limit"`
	Marker        string `q:"marker"`
	Name          string `q:"name"`
	Sort          string `q:"sort"`
	Type          string `q:"type"`
}

ListOpts represents options used to list profiles.

func (ListOpts) ToProfileListQuery

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

ToProfileListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

ListOptsBuilder allows extensions to add additional parameters to the List request.

type Profile

type Profile struct {
	CreatedAt time.Time              `json:"-"`
	Domain    string                 `json:"domain"`
	ID        string                 `json:"id"`
	Metadata  map[string]interface{} `json:"metadata"`
	Name      string                 `json:"name"`
	Project   string                 `json:"project"`
	Spec      Spec                   `json:"spec"`
	Type      string                 `json:"type"`
	UpdatedAt time.Time              `json:"-"`
	User      string                 `json:"user"`
}

Profile represent a detailed profile.

func ExtractProfiles

func ExtractProfiles(r pagination.Page) ([]Profile, error)

ExtractProfiles returns a slice of Profiles from the List operation.

func (*Profile) UnmarshalJSON

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

type ProfilePage

type ProfilePage struct {
	pagination.LinkedPageBase
}

ProfilePage contains a single page of all profiles from a List operation.

func (ProfilePage) IsEmpty

func (page ProfilePage) IsEmpty() (bool, error)

IsEmpty determines if a ProfilePage contains any results.

type Spec

type Spec struct {
	Type       string                 `json:"type"`
	Version    string                 `json:"-"`
	Properties map[string]interface{} `json:"properties"`
}

Spec represents a profile spec.

func (Spec) MarshalJSON

func (r Spec) MarshalJSON() ([]byte, error)

func (*Spec) UnmarshalJSON

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

type UpdateOpts

type UpdateOpts struct {
	Metadata map[string]interface{} `json:"metadata,omitempty"`
	Name     string                 `json:"name,omitempty"`
}

UpdateOpts represents options used to update a profile.

func (UpdateOpts) ToProfileUpdateMap

func (opts UpdateOpts) ToProfileUpdateMap() (map[string]interface{}, error)

ToProfileUpdateMap constructs a request body from UpdateOpts.

type UpdateOptsBuilder

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

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

type UpdateResult

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

UpdateResult is the result of a Update operations. Call its Extract method to interpret it as a Profile.

func Update

func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)

Update updates a profile.

func (UpdateResult) Extract

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

Extract provides access to Profile returned by the Get and Create functions.

type ValidateOpts

type ValidateOpts struct {
	Spec Spec `json:"spec" required:"true"`
}

ValidateOpts params

func (ValidateOpts) ToProfileValidateMap

func (opts ValidateOpts) ToProfileValidateMap() (map[string]interface{}, error)

ToProfileValidateMap formats a CreateOpts into a body map.

type ValidateOptsBuilder

type ValidateOptsBuilder interface {
	ToProfileValidateMap() (map[string]interface{}, error)
}

ValidateOptsBuilder allows extensions to add additional parameters to the Validate request.

type ValidateResult

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

ValidateResult is the response of a Validate operations.

func Validate

func Validate(client *gophercloud.ServiceClient, opts ValidateOpts) (r ValidateResult)

Validate profile.

func (ValidateResult) Extract

func (r ValidateResult) Extract() (*Profile, error)

Extract provides access to Profile returned by the Get and Create functions.

Directories

Path Synopsis
clustering_profiles_v1
clustering_profiles_v1

Jump to

Keyboard shortcuts

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