README

openstack

openstack is the API to an OpenStack cloud.

  • session.go - A Session object that encapsulates the HTTP REST handler and authentication and logging

  • auth.go - The basic authentication interface

  • auth-password.go - Implements password authentication (v2 only at present)

  • auth-token.go - The returned token objects

Expand ▾ Collapse ▴

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Debug = new(bool)

Functions

func Delete

func Delete(
	url string,
	params *url.Values,
	headers *http.Header,
) (resp *http.Response, err error)

    Delete sends a DELETE request.

    func Get

    func Get(
    	url string,
    	params *url.Values,
    	headers *http.Header,
    ) (resp *http.Response, err error)

      Get sends a GET request.

      func GetJSON

      func GetJSON(
      	url string,
      	params *url.Values,
      	headers *http.Header,
      	responseContainer interface{},
      ) (resp *http.Response, err error)

        GetJSON sends a GET request and unmarshalls returned JSON.

        func Post

        func Post(
        	url string,
        	params *url.Values,
        	headers *http.Header,
        	body *[]byte,
        ) (resp *http.Response, err error)

          Post sends a POST request.

          func PostJSON

          func PostJSON(
          	url string,
          	params *url.Values,
          	headers *http.Header,
          	body interface{},
          	responseContainer interface{},
          ) (resp *http.Response, err error)

            PostJSON sends a POST request and unmarshalls returned JSON.

            func Put

            func Put(
            	url string,
            	params *url.Values,
            	headers *http.Header,
            	body *[]byte,
            ) (resp *http.Response, err error)

              Put sends a PUT request.

              Types

              type AccessType

              type AccessType struct {
              	Token          Token                 `json:"token"`
              	User           interface{}           `json:"user"`
              	ServiceCatalog []ServiceCatalogEntry `json:"servicecatalog"`
              }

              type AuthFunc

              type AuthFunc func(s *Session, opts interface{}) (AuthRef, error)

                Generic callback to get a token from the auth plugin

                type AuthOpts

                type AuthOpts struct {
                	// AuthUrl is always required
                	AuthUrl string
                
                	// Domain is ignored for v2 and required for v3 auth
                	Domain string
                
                	// Project is optional to get an unscoped token but required for
                	// a scoped token, which is required to do pretty much everything
                	// except list projects
                	ProjectName string
                
                	ProjectId string
                
                	// Username is required for password auth
                	Username string
                
                	// Password is required for password auth
                	Password string
                
                	// Token is required for Toekn auth
                	Token string
                }

                  AuthOpts is the set of credentials used to authenticate to OpenStack

                  func (*AuthOpts) GetAuthType

                  func (s *AuthOpts) GetAuthType() (string, error)

                  type AuthRef

                  type AuthRef interface {
                  	GetToken() string
                  	GetExpiration() time.Time
                  	GetEndpoint(string, string) (string, error)
                  	GetProject() string
                  }

                    AuthRef is the returned authentication object, maybe v2 or v3

                    func DoAuthRequest

                    func DoAuthRequest(authopts AuthOpts) (AuthRef, error)

                      Basic auth call These args should be an interface??

                      type AuthToken

                      type AuthToken struct {
                      	Access AccessType `json:"access"`
                      }

                      func (AuthToken) GetEndpoint

                      func (s AuthToken) GetEndpoint(serviceType string, regionName string) (string, error)

                      func (AuthToken) GetExpiration

                      func (s AuthToken) GetExpiration() time.Time

                      func (AuthToken) GetProject

                      func (s AuthToken) GetProject() string

                      func (AuthToken) GetToken

                      func (s AuthToken) GetToken() string

                      type OSAuth

                      type OSAuth struct {
                      	PasswordCredentials `json:"passwordCredentials"`
                      	ProjectName         string `json:"tenantName"`
                      	ProjectId           string `json:"tenantId"`
                      }

                      type PasswordCredentials

                      type PasswordCredentials struct {
                      	Username string `json:"username"`
                      	Password string `json:"password"`
                      }

                      type Response

                      type Response struct {
                      	Resp *http.Response
                      	Body []byte
                      }

                      type ServiceCatalogEntry

                      type ServiceCatalogEntry struct {
                      	Name      string            `json:"name"`
                      	Type      string            `json:"type"`
                      	Endpoints []ServiceEndpoint `json:"endpoints"`
                      }

                      func (ServiceCatalogEntry) GetEndpoint

                      func (sce ServiceCatalogEntry) GetEndpoint(
                      	serviceType string,
                      	interfaceType string,
                      	regionName string,
                      ) (string, error)

                        Valid interfaceType values: 'public', 'publicURL', 'admin', 'admin URL', 'internal', 'internalURL'

                        type ServiceEndpoint

                        type ServiceEndpoint struct {
                        	Type        string `json:"type"`
                        	Region      string `json:"region"`
                        	PublicURL   string `json:"publicurl"`
                        	AdminURL    string `json:"adminurl"`
                        	InternalURL string `json:"internalurl"`
                        	VersionID   string `json:"versionid"`
                        }

                        type Session

                        type Session struct {
                        	AuthToken AuthRef
                        	Headers   http.Header
                        	// contains filtered or unexported fields
                        }

                        func NewSession

                        func NewSession(hclient *http.Client, auth AuthRef, tls *tls.Config) (session *Session, err error)

                        func (*Session) Delete

                        func (s *Session) Delete(
                        	url string,
                        	params *url.Values,
                        	headers *http.Header,
                        ) (resp *http.Response, err error)

                        func (*Session) Do

                        func (s *Session) Do(req *http.Request) (*http.Response, error)

                        func (*Session) Get

                        func (s *Session) Get(
                        	url string,
                        	params *url.Values,
                        	headers *http.Header,
                        ) (resp *http.Response, err error)

                        func (*Session) GetJSON

                        func (s *Session) GetJSON(
                        	url string,
                        	params *url.Values,
                        	headers *http.Header,
                        	responseContainer interface{},
                        ) (resp *http.Response, err error)

                        func (*Session) Head

                        func (s *Session) Head(
                        	url string,
                        	params *url.Values,
                        	headers *http.Header,
                        ) (resp *http.Response, err error)

                        func (*Session) NewRequest

                        func (s *Session) NewRequest(method, url string, headers *http.Header, body io.Reader) (req *http.Request, err error)

                        func (*Session) Post

                        func (s *Session) Post(
                        	url string,
                        	params *url.Values,
                        	headers *http.Header,
                        	body *[]byte,
                        ) (resp *http.Response, err error)

                        func (*Session) PostJSON

                        func (s *Session) PostJSON(
                        	url string,
                        	params *url.Values,
                        	headers *http.Header,
                        	body interface{},
                        	responseContainer interface{},
                        ) (resp *http.Response, err error)

                        func (*Session) Put

                        func (s *Session) Put(
                        	url string,
                        	params *url.Values,
                        	headers *http.Header,
                        	body *[]byte,
                        ) (resp *http.Response, err error)

                        func (*Session) Request

                        func (s *Session) Request(
                        	method string,
                        	url string,
                        	params *url.Values,
                        	headers *http.Header,
                        	body *[]byte,
                        ) (resp *http.Response, err error)

                          Perform a simple get to an endpoint

                          func (*Session) RequestJSON

                          func (s *Session) RequestJSON(
                          	method string,
                          	url string,
                          	params *url.Values,
                          	headers *http.Header,
                          	body interface{},
                          	responseContainer interface{},
                          ) (resp *http.Response, err error)

                            Perform a simple get to an endpoint and unmarshall returned JSON

                            type Token

                            type Token struct {
                            	ID      string    `json:"id"`
                            	Expires time.Time `json:"expires"`
                            	Project struct {
                            		ID   string `json:"id"`
                            		Name string `json:"name"`
                            	} `json:"tenant"`
                            }

                            type UserPassV2

                            type UserPassV2 struct {
                            	OSAuth  `json:"auth"`
                            	AuthUrl string `json:"-"`
                            }

                            func NewUserPassV2

                            func NewUserPassV2(ao AuthOpts) (upv2 *UserPassV2, err error)

                            func (*UserPassV2) JSON

                            func (s *UserPassV2) JSON() []byte

                              Produce JSON output