rainmaker

package module
v0.0.0-...-d533d01 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2016 License: MIT Imports: 9 Imported by: 4

README

A Client Library for CC, written in Go

Rainmaker provides a library of functionality for interacting with the Cloud Controller. The library supports management of organizations, spaces and users.

GoDoc

Caveat Emptor

Rainmaker is still under development and the APIs shown herein are subject to change.

Example

Rainmaker can be used in a variety of ways. Here is a simple example to get you started:

package main

import (
	"log"

	"github.com/pivotal-cf-experimental/rainmaker"
)

func main() {
	r := rainmaker.NewClient(rainmaker.Config{
		Host: "https://api.example.com",
	})

	org, err := client.Organizations.Create("A New Org", token)
	if err != nil {
		log.Fatalf("Unable to create organization: %s", err)
	}

	fetchedOrg, err := client.Organizations.Get(org.GUID, token)
	if err != nil {
		log.Fatalf("Unable to fetch organization: %s", err)
	}

	log.Printf("%+v\n", fetchedOrg)
	// => {GUID:eedacbb8-72c6-11e5-a4a4-6b0a4f4c3afa, Name:A New Org, ...}

	space, err := client.Spaces.Create("Interesting Space", org.GUID, token)
	if err != nil {
		log.Fatalf("Unable to create space: %s", err)
	}

	fetchedSpace, err := client.Spaces.Get(space.GUID, token)
	if err != nil {
		log.Fatalf("Unable to fetch space: %s", err)
	}

	log.Printf("%+v\n", fetchedSpace)
	// => {GUID:7aa59fd2-72c8-11e5-b644-4f220f7a6847, OrganizationGUID:eedacbb8-72c6-11e5-a4a4-6b0a4f4c3afa, Name:Interesting Space, ...}

	spaceList, err := client.Spaces.List(token)
	if err != nil {
		log.Fatalf("Unable to fetch the list of spaces: %s", err)
	}

	log.Printf("%+v\n", spaceList.Spaces)
	// => [{GUID:7aa59fd2-72c8-11e5-b644-4f220f7a6847, OrganizationGUID:eedacbb8-72c6-11e5-a4a4-6b0a4f4c3afa, Name:Interesting Space, ...}]

	err = client.Spaces.Delete(space.GUID, token)
	if err != nil {
		log.Fatalf("Unable to delete organization: %s", err)
	}

	err = client.Organizations.Delete(org.GUID, token)
	if err != nil {
		log.Fatalf("Unable to delete organization: %s", err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolPtr

func BoolPtr(boolean bool) *bool

func IntPtr

func IntPtr(integer int) *int

func StringPtr

func StringPtr(str string) *string

Types

type Application

type Application struct {
	GUID      string
	Name      string
	SpaceGUID string
	Diego     bool
	// contains filtered or unexported fields
}

func NewApplication

func NewApplication(config Config, guid string) Application

type ApplicationsList

type ApplicationsList struct {
	TotalResults int
	TotalPages   int
	NextURL      string
	PrevURL      string
	Applications []Application
	// contains filtered or unexported fields
}

func NewApplicationsList

func NewApplicationsList(config Config, plan requestPlan) ApplicationsList

func (*ApplicationsList) Fetch

func (list *ApplicationsList) Fetch(token string) error

func (ApplicationsList) HasNextPage

func (list ApplicationsList) HasNextPage() bool

func (ApplicationsList) HasPrevPage

func (list ApplicationsList) HasPrevPage() bool

func (ApplicationsList) Next

func (list ApplicationsList) Next(token string) (ApplicationsList, error)

func (ApplicationsList) Prev

func (list ApplicationsList) Prev(token string) (ApplicationsList, error)

type ApplicationsService

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

func NewApplicationsService

func NewApplicationsService(config Config) ApplicationsService

func (ApplicationsService) Create

func (service ApplicationsService) Create(application Application, token string) (Application, error)

func (ApplicationsService) Delete

func (service ApplicationsService) Delete(guid, token string) error

func (ApplicationsService) Get

func (service ApplicationsService) Get(guid, token string) (Application, error)

func (ApplicationsService) List

func (service ApplicationsService) List(token string) (ApplicationsList, error)

type Buildpack

type Buildpack struct {
	GUID      string
	URL       string
	CreatedAt time.Time
	UpdatedAt time.Time
	Name      string
	Position  int
	Enabled   bool
	Locked    bool
	Filename  string
}

type BuildpacksService

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

func NewBuildpacksService

func NewBuildpacksService(config Config) BuildpacksService

func (BuildpacksService) Create

func (b BuildpacksService) Create(name string, token string, options *CreateBuildpackOptions) (Buildpack, error)

func (BuildpacksService) Delete

func (b BuildpacksService) Delete(guid, token string) error

func (BuildpacksService) Get

func (b BuildpacksService) Get(guid string, token string) (Buildpack, error)

func (BuildpacksService) Update

func (b BuildpacksService) Update(buildpack Buildpack, token string) (Buildpack, error)

type Client

type Client struct {
	Organizations    OrganizationsService
	Spaces           SpacesService
	Applications     ApplicationsService
	Users            UsersService
	ServiceInstances ServiceInstancesService
	Buildpacks       BuildpacksService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(config Config) Client

type Config

type Config struct {
	SkipVerifySSL bool
	Host          string
	TraceWriter   io.Writer
}

type CreateBuildpackOptions

type CreateBuildpackOptions struct {
	Position *int
	Enabled  *bool
	Locked   *bool
	Filename *string
}

type Error

type Error struct {
	Err error
}

func (Error) Error

func (e Error) Error() string

type NotFoundError

type NotFoundError struct {
	Err error
}

func (NotFoundError) Error

func (e NotFoundError) Error() string

type Organization

type Organization struct {
	GUID                     string
	Name                     string
	URL                      string
	BillingEnabled           bool
	Status                   string
	QuotaDefinitionGUID      string
	QuotaDefinitionURL       string
	SpacesURL                string
	DomainsURL               string
	PrivateDomainsURL        string
	UsersURL                 string
	ManagersURL              string
	BillingManagersURL       string
	AuditorsURL              string
	AppEventsURL             string
	SpaceQuotaDefinitionsURL string
	CreatedAt                time.Time
	UpdatedAt                time.Time
	Users                    UsersList
	BillingManagers          UsersList
	Auditors                 UsersList
	Managers                 UsersList
	// contains filtered or unexported fields
}

func NewOrganization

func NewOrganization(config Config, guid string) Organization

type OrganizationsList

type OrganizationsList struct {
	Page

	Organizations []Organization
	// contains filtered or unexported fields
}

func NewOrganizationsList

func NewOrganizationsList(config Config, plan requestPlan) OrganizationsList

func (OrganizationsList) Create

func (list OrganizationsList) Create(org Organization, token string) (Organization, error)

func (*OrganizationsList) Fetch

func (list *OrganizationsList) Fetch(token string) error

func (OrganizationsList) Next

func (list OrganizationsList) Next(token string) (OrganizationsList, error)

func (OrganizationsList) Prev

func (list OrganizationsList) Prev(token string) (OrganizationsList, error)

type OrganizationsService

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

func NewOrganizationsService

func NewOrganizationsService(config Config) OrganizationsService

func (OrganizationsService) Create

func (service OrganizationsService) Create(name string, token string) (Organization, error)

func (OrganizationsService) Delete

func (service OrganizationsService) Delete(guid, token string) error

func (OrganizationsService) Get

func (service OrganizationsService) Get(guid, token string) (Organization, error)

func (OrganizationsService) List

func (service OrganizationsService) List(token string) (OrganizationsList, error)

func (OrganizationsService) ListAuditors

func (service OrganizationsService) ListAuditors(guid, token string) (UsersList, error)

func (OrganizationsService) ListBillingManagers

func (service OrganizationsService) ListBillingManagers(guid, token string) (UsersList, error)

func (OrganizationsService) ListManagers

func (service OrganizationsService) ListManagers(guid, token string) (UsersList, error)

func (OrganizationsService) ListSpaces

func (service OrganizationsService) ListSpaces(guid, token string) (SpacesList, error)

func (OrganizationsService) ListUsers

func (service OrganizationsService) ListUsers(guid, token string) (UsersList, error)

func (OrganizationsService) Update

func (service OrganizationsService) Update(org Organization, token string) (Organization, error)

type Page

type Page struct {
	TotalResults int
	TotalPages   int
	NextURL      string
	PrevURL      string
	Resources    []json.RawMessage
	// contains filtered or unexported fields
}

func NewPage

func NewPage(config Config, plan requestPlan) Page

func (*Page) Fetch

func (p *Page) Fetch(token string) error

func (Page) HasNextPage

func (p Page) HasNextPage() bool

func (Page) HasPrevPage

func (p Page) HasPrevPage() bool

func (Page) Next

func (p Page) Next(token string) (Page, error)

func (Page) Prev

func (p Page) Prev(token string) (Page, error)

type ServiceInstance

type ServiceInstance struct {
	GUID      string
	Name      string
	PlanGUID  string
	SpaceGUID string
}

type ServiceInstancesService

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

func NewServiceInstancesService

func NewServiceInstancesService(config Config) ServiceInstancesService

func (*ServiceInstancesService) Create

func (service *ServiceInstancesService) Create(name, planGUID, spaceGUID, token string) (ServiceInstance, error)

func (*ServiceInstancesService) Get

func (service *ServiceInstancesService) Get(guid, token string) (ServiceInstance, error)

type Space

type Space struct {
	GUID                     string
	URL                      string
	CreatedAt                time.Time
	UpdatedAt                time.Time
	Name                     string
	OrganizationGUID         string `json:"organization_guid"` // TODO: why is this here?
	SpaceQuotaDefinitionGUID string
	OrganizationURL          string
	DevelopersURL            string
	ManagersURL              string
	AuditorsURL              string
	AppsURL                  string
	RoutesURL                string
	DomainsURL               string
	ServiceInstancesURL      string
	AppEventsURL             string
	EventsURL                string
	SecurityGroupsURL        string
	Developers               UsersList
	// contains filtered or unexported fields
}

func NewSpace

func NewSpace(config Config, guid string) Space

type SpacesList

type SpacesList struct {
	TotalResults int
	TotalPages   int
	NextURL      string
	PrevURL      string
	Spaces       []Space
	// contains filtered or unexported fields
}

func NewSpacesList

func NewSpacesList(config Config, plan requestPlan) SpacesList

func (SpacesList) Create

func (list SpacesList) Create(space Space, token string) (Space, error)

func (*SpacesList) Fetch

func (list *SpacesList) Fetch(token string) error

func (SpacesList) HasNextPage

func (list SpacesList) HasNextPage() bool

func (SpacesList) HasPrevPage

func (list SpacesList) HasPrevPage() bool

func (SpacesList) Next

func (list SpacesList) Next(token string) (SpacesList, error)

func (SpacesList) Prev

func (list SpacesList) Prev(token string) (SpacesList, error)

type SpacesService

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

func NewSpacesService

func NewSpacesService(config Config) SpacesService

func (SpacesService) Create

func (service SpacesService) Create(name, orgGUID, token string) (Space, error)

func (SpacesService) Delete

func (service SpacesService) Delete(guid, token string) error

func (SpacesService) Get

func (service SpacesService) Get(guid, token string) (Space, error)

func (SpacesService) List

func (service SpacesService) List(token string) (SpacesList, error)

func (SpacesService) ListUsers

func (service SpacesService) ListUsers(guid, token string) (UsersList, error)

type User

type User struct {
	GUID                           string
	URL                            string
	CreatedAt                      time.Time
	UpdatedAt                      time.Time
	Admin                          bool
	Active                         bool
	DefaultSpaceGUID               string
	SpacesURL                      string
	OrganizationsURL               string
	ManagedOrganizationsURL        string
	BillingManagedOrganizationsURL string
	AuditedOrganizationsURL        string
	ManagedSpacesURL               string
	AuditedSpacesURL               string
	// contains filtered or unexported fields
}

func NewUser

func NewUser(config Config, guid string) User

type UsersList

type UsersList struct {
	TotalResults int
	TotalPages   int
	NextURL      string
	PrevURL      string
	Users        []User
	// contains filtered or unexported fields
}

func NewUsersList

func NewUsersList(config Config, plan requestPlan) UsersList

func (UsersList) Associate

func (list UsersList) Associate(userGUID, token string) error

func (UsersList) Create

func (list UsersList) Create(user User, token string) (User, error)

func (*UsersList) Fetch

func (list *UsersList) Fetch(token string) error

func (UsersList) HasNextPage

func (list UsersList) HasNextPage() bool

func (UsersList) HasPrevPage

func (list UsersList) HasPrevPage() bool

func (UsersList) Next

func (list UsersList) Next(token string) (UsersList, error)

func (UsersList) Prev

func (list UsersList) Prev(token string) (UsersList, error)

type UsersService

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

func NewUsersService

func NewUsersService(config Config) UsersService

func (UsersService) Create

func (service UsersService) Create(guid, token string) (User, error)

func (UsersService) Get

func (service UsersService) Get(guid, token string) (User, error)

Directories

Path Synopsis
internal
network
Package network provides an HTTP network abstraction that is bound to the request/response cycle of commands to the UAA service.
Package network provides an HTTP network abstraction that is bound to the request/response cycle of commands to the UAA service.

Jump to

Keyboard shortcuts

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