receivers

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

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

Example to Create a Receiver

createOpts := receivers.CreateOpts{
	Action:     "CLUSTER_DEL_NODES",
	ClusterID:  "b7b870ee-d3c5-4a93-b9d7-846c53b2c2dc",
	Name:       "test_receiver",
	Type:       receivers.WebhookReceiver,
}

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

fmt.Printf("%v\n", receiver)

Example to Get a Receiver

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

fmt.Printf("%v\n", receiver)

Example to Delete receiver

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

fmt.Printf("%v\n", receiver)

Example to Update Receiver

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

receiverID := "6dc6d336e3fc4c0a951b5698cd1236ee"
receiver, err := receivers.Update(serviceClient, receiverID, updateOpts).Extract()
if err != nil {
	panic(err)
}

fmt.Printf("%v\n", receiver)

Example to List Receivers

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

receivers.List(serviceClient, listOpts).EachPage(func(page pagination.Page) (bool, error) {
	allReceivers, err := receivers.ExtractReceivers(page)
	if err != nil {
		panic(err)
	}

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

Example to Notify a Receiver

receiverID := "6dc6d336e3fc4c0a951b5698cd1236ee"
requestID, err := receivers.Notify(serviceClient, receiverID).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 cluster.

Types

type CreateOpts

type CreateOpts struct {
	Name      string                 `json:"name" required:"true"`
	ClusterID string                 `json:"cluster_id,omitempty"`
	Type      ReceiverType           `json:"type" required:"true"`
	Action    string                 `json:"action,omitempty"`
	Actor     map[string]interface{} `json:"actor,omitempty"`
	Params    map[string]interface{} `json:"params,omitempty"`
}

CreatOpts represents options used to create a receiver.

func (CreateOpts) ToReceiverCreateMap

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

ToReceiverCreateMap constructs a request body from CreateOpts.

type CreateOptsBuilder

type CreateOptsBuilder interface {
	ToReceiverCreateMap() (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 Receiver.

func Create

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

Create requests the creation of a new receiver.

func (CreateResult) Extract

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

Extract interprets any commonResult-based result as a Receiver.

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 receiver ID.

type GetResult

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

GetResult is the result for of a Get operation. Call its Extract method to interpret it as a Receiver.

func Get

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

Get retrieves details of a single receiver. Use Extract to convert its result into a Receiver.

func (GetResult) Extract

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

Extract interprets any commonResult-based result as a Receiver.

type ListOpts

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

ListOpts represents options used to list recievers.

func (ListOpts) ToReceiverListQuery

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

ToReceiverListQuery formats a ListOpts into a query string.

type ListOptsBuilder

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

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

type NotifyResult

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

NotifyResult is the result from a Notify operation. Call its Extract method to determine if the call succeeded or failed.

func Notify

func Notify(client *gophercloud.ServiceClient, id string) (r NotifyResult)

Notify Notifies message type receiver

func (NotifyResult) Extract

func (r NotifyResult) Extract() (string, error)

Extract returns action for notify receivers

type Receiver

type Receiver struct {
	Action    string                 `json:"action"`
	Actor     map[string]interface{} `json:"actor"`
	Channel   map[string]interface{} `json:"channel"`
	ClusterID string                 `json:"cluster_id"`
	CreatedAt time.Time              `json:"-"`
	Domain    string                 `json:"domain"`
	ID        string                 `json:"id"`
	Name      string                 `json:"name"`
	Params    map[string]interface{} `json:"params"`
	Project   string                 `json:"project"`
	Type      string                 `json:"type"`
	UpdatedAt time.Time              `json:"-"`
	User      string                 `json:"user"`
}

Receiver represent a detailed receiver

func ExtractReceivers

func ExtractReceivers(r pagination.Page) ([]Receiver, error)

ExtractReceivers returns a slice of Receivers from the List operation.

func (*Receiver) UnmarshalJSON

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

type ReceiverPage

type ReceiverPage struct {
	pagination.LinkedPageBase
}

ReceiverPage contains a single page of all nodes from a List operation.

func (ReceiverPage) IsEmpty

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

IsEmpty determines if a ReceiverPage contains any results.

type ReceiverType

type ReceiverType string

ReceiverType represents a valid type of receiver

const (
	WebhookReceiver ReceiverType = "webhook"
	MessageReceiver ReceiverType = "message"
)

type UpdateOpts

type UpdateOpts struct {
	Name   string                 `json:"name,omitempty"`
	Action string                 `json:"action,omitempty"`
	Params map[string]interface{} `json:"params,omitempty"`
}

UpdateOpts represents options used to update a receiver.

func (UpdateOpts) ToReceiverUpdateMap

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

ToReceiverUpdateMap constructs a request body from UpdateOpts.

type UpdateOptsBuilder

type UpdateOptsBuilder interface {
	ToReceiverUpdateMap() (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 operation. Call its Extract method to interpret it as a Receiver.

func Update

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

Update requests the update of a receiver.

func (UpdateResult) Extract

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

Extract interprets any commonResult-based result as a Receiver.

Directories

Path Synopsis
clustering_receivers_v1
clustering_receivers_v1

Jump to

Keyboard shortcuts

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