Documentation ¶
Overview ¶
Package policies provides information and interaction with the policies through the OpenStack Clustering service.
Example to List Policies
listOpts := policies.ListOpts{ Limit: 2, } allPages, err := policies.List(clusteringClient, listOpts).AllPages() if err != nil { panic(err) } allPolicies, err := policies.ExtractPolicies(allPages) if err != nil { panic(err) } for _, policy := range allPolicies { fmt.Printf("%+v\n", policy) }
Example to Create a Policy
opts := policies.CreateOpts{ Name: "new_policy", Spec: policies.Spec{ Description: "new policy description", Properties: map[string]interface{}{ "hooks": map[string]interface{}{ "type": "zaqar", "params": map[string]interface{}{ "queue": "my_zaqar_queue", }, "timeout": 10, }, }, Type: "senlin.policy.deletion", Version: "1.1", }, } createdPolicy, err := policies.Create(client, opts).Extract() if err != nil { panic(err) }
Example to Get a Policy
policyName := "get_policy" policyDetail, err := policies.Get(clusteringClient, policyName).Extract() if err != nil { panic(err) } fmt.Printf("%+v\n", policyDetail)
Example to Update a Policy
opts := policies.UpdateOpts{ Name: "update_policy", } updatePolicy, err := policies.Update(client, opts).Extract() if err != nil { panic(err) }
Example to Validate a Policy
opts := policies.ValidateOpts{ Spec: policies.Spec{ Description: "new policy description", Properties: map[string]interface{}{ "hooks": map[string]interface{}{ "type": "zaqar", "params": map[string]interface{}{ "queue": "my_zaqar_queue", }, "timeout": 10, }, }, Type: "senlin.policy.deletion", Version: "1.1", }, } validatePolicy, err := policies.Validate(client, opts).Extract() if err != nil { panic(err) }
Index ¶
- func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type GetResult
- type ListOpts
- type ListOptsBuilder
- type Policy
- type PolicyPage
- type Spec
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
- type ValidateOpts
- type ValidateOptsBuilder
- type ValidateResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List instructs OpenStack to retrieve a list of policies.
Types ¶
type CreateOpts ¶
CreateOpts represents options used to create a policy.
func (CreateOpts) ToPolicyCreateMap ¶
func (opts CreateOpts) ToPolicyCreateMap() (map[string]interface{}, error)
ToPolicyCreateMap constructs 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 is the result of an Update operation. Call its Extract method to interpret it as a Policy.
func Create ¶
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create makes a request against the API to create a policy
type DeleteResult ¶
type DeleteResult struct {
gophercloud.ErrResult
}
DeleteResult is the result of a Delete operation. Call its Extract method to interpret it as a DeleteHeader.
func Delete ¶
func Delete(client *gophercloud.ServiceClient, policyID string) (r DeleteResult)
Delete makes a request against the API to delete a policy.
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult is the result of a Get operation. Call its Extract method to interpret it as a Policy.
func Get ¶
func Get(client *gophercloud.ServiceClient, policyTypeName string) (r GetResult)
Get makes a request against the API to get details for a policy.
type ListOpts ¶
type ListOpts struct { // Limit limits the number of Policies to return. Limit int `q:"limit"` // Marker and Limit control paging. Marker instructs List where to start // listing from. Marker string `q:"marker"` // Sorts the response by one or more attribute and optional sort direction // combinations. Sort string `q:"sort"` // GlobalProject indicates whether to include resources for all projects or // resources for the current project. GlobalProject *bool `q:"global_project"` // Name to filter the response by the specified name property of the object. Name string `q:"name"` // Filter the response by the specified type property of the object. Type string `q:"type"` }
ListOpts represents options used to list policies.
func (ListOpts) ToPolicyListQuery ¶
ToPolicyListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request.
type Policy ¶
type Policy struct { CreatedAt time.Time `json:"-"` Data map[string]interface{} `json:"data"` Domain string `json:"domain"` ID string `json:"id"` Name string `json:"name"` Project string `json:"project"` Spec Spec `json:"spec"` Type string `json:"type"` UpdatedAt time.Time `json:"-"` User string `json:"user"` }
Policy represents a clustering policy in the Openstack cloud.
func ExtractPolicies ¶
func ExtractPolicies(r pagination.Page) ([]Policy, error)
ExtractPolicies returns a slice of Policies from the List operation.
func (*Policy) UnmarshalJSON ¶
type PolicyPage ¶
type PolicyPage struct {
pagination.MarkerPageBase
}
PolicyPage contains a list page of all policies from a List call.
func (PolicyPage) IsEmpty ¶
func (page PolicyPage) IsEmpty() (bool, error)
IsEmpty determines if a PolicyPage contains any results.
func (PolicyPage) LastMarker ¶
func (r PolicyPage) LastMarker() (string, error)
LastMarker returns the last policy ID in a ListResult.
type Spec ¶
type Spec struct { Description string `json:"description"` Properties map[string]interface{} `json:"properties"` Type string `json:"type"` Version string `json:"-"` }
Spec represents an OpenStack clustering policy spec.
func (Spec) MarshalJSON ¶
func (*Spec) UnmarshalJSON ¶
type UpdateOpts ¶
type UpdateOpts struct {
Name string `json:"name,omitempty"`
}
UpdateOpts represents options to update a policy.
func (UpdateOpts) ToPolicyUpdateMap ¶
func (opts UpdateOpts) ToPolicyUpdateMap() (map[string]interface{}, error)
ToPolicyUpdateMap constructs a request body from UpdateOpts.
type UpdateOptsBuilder ¶
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 an Update operation. Call its Extract method to interpret it as a Policy.
func Update ¶
func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)
Update updates a specified policy.
type ValidateOpts ¶
type ValidateOpts struct {
Spec Spec `json:"spec"`
}
ValidateOpts represents options used to validate a policy.
func (ValidateOpts) ToPolicyValidateMap ¶
func (opts ValidateOpts) ToPolicyValidateMap() (map[string]interface{}, error)
ToPolicyValidateMap formats a CreateOpts into a body map.
type ValidateOptsBuilder ¶
ValidateOptsBuilder allows extensions to add additional parameters to the Validate request.
type ValidateResult ¶
type ValidateResult struct {
// contains filtered or unexported fields
}
ValidateResult is the result of a Validate operation. Call its Extract method to interpret it as a Policy.
func Validate ¶
func Validate(client *gophercloud.ServiceClient, opts ValidateOptsBuilder) (r ValidateResult)
Validate policy will validate a specified policy.