cloudmanager

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Version          = "0.1" // Version for client
	CloudURL         = "https://cloud.mongodb.com"
	DefaultBaseURL   = CloudURL + APIPublicV1Path                                            // DefaultBaseURL API default base URL for cloud manager
	APIPublicV1Path  = "/api/public/v1.0/"                                                   // DefaultAPIPath default root path for all API endpoints
	DefaultUserAgent = "pcgc/" + Version + " (" + runtime.GOOS + "; " + runtime.GOARCH + ")" // DefaultUserAgent To be submitted by the client

)

Variables

This section is empty.

Functions

This section is empty.

Types

type Args26

type Args26 struct {
	NET         Net          `json:"net"`                   // NET configuration for db connection (ports)
	Replication *Replication `json:"replication,omitempty"` // Replication configuration for ReplicaSets, omit this field if setting Sharding
	Sharding    *Sharding    `json:"sharding,omitempty"`    // Replication configuration for sharded clusters, omit this field if setting Replication
	Storage     *Storage     `json:"storage,omitempty"`     // Storage configuration for dbpath, config servers don't define this
	SystemLog   SystemLog    `json:"systemLog"`             // SystemLog configuration for the dblog
}

Args26 part of the internal Process struct

type Auth

type Auth struct {
	AutoAuthMechanism        string                   `json:"autoAuthMechanism"`
	AutoUser                 string                   `json:"autoUser,omitempty"`
	AutoPwd                  string                   `json:"autoPwd,omitempty"`
	DeploymentAuthMechanisms []string                 `json:"deploymentAuthMechanisms"`
	Key                      string                   `json:"key,omitempty"`
	Keyfile                  string                   `json:"keyfile,omitempty"`
	KeyfileWindows           string                   `json:"keyfileWindows,omitempty"`
	UsersDeleted             []interface{}            `json:"usersDeleted"`
	UsersWanted              []map[string]interface{} `json:"usersWanted"`
	AuthoritativeSet         bool                     `json:"authoritativeSet"`
	Disabled                 bool                     `json:"disabled"`
}

Auth authentication config

type AutomationConfig

type AutomationConfig struct {
	AgentVersion       *map[string]interface{}   `json:"agentVersion,omitempty"`
	Auth               Auth                      `json:"auth"`
	BackupVersions     []*map[string]interface{} `json:"backupVersions,omitempty"`
	Balancer           *map[string]interface{}   `json:"balancer,omitempty"`
	CPSModules         []*map[string]interface{} `json:"cpsModules,omitempty"`
	IndexConfigs       []*map[string]interface{} `json:"indexConfigs,omitempty"`
	Kerberos           *map[string]interface{}   `json:"kerberos,omitempty"`
	LDAP               *map[string]interface{}   `json:"ldap,omitempty"`
	MongoDBVersions    []*map[string]interface{} `json:"mongoDbVersions,omitempty"`
	MongoSQLDs         []*map[string]interface{} `json:"mongosqlds,omitempty"`
	MonitoringVersions []*map[string]interface{} `json:"monitoringVersions,omitempty"`
	MongoTs            []*map[string]interface{} `json:"mongots,omitempty"`
	Options            *Options                  `json:"options"`
	Processes          []*Process                `json:"processes,omitempty"`
	ReplicaSets        []*ReplicaSet             `json:"replicaSets,omitempty"`
	Roles              []*map[string]interface{} `json:"roles,omitempty"`
	Sharding           *[]map[string]interface{} `json:"sharding,omitempty"`
	SSL                *SSL                      `json:"ssl,omitempty"`
	UIBaseURL          string                    `json:"uiBaseUrl,omitempty"`
	Version            int                       `json:"version,omitempty"`
}

type AutomationService

type AutomationService interface {
	Get(context.Context, string) (*AutomationConfig, *atlas.Response, error)
	Update(context.Context, string, *AutomationConfig) (*atlas.Response, error)
}

AutomationService is an interface for interfacing with the Automation Config endpoints of the MongoDB CLoud API. See more: https://docs.cloudmanager.mongodb.com/reference/api/automation-config/

type AutomationServiceOp

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

AutomationServiceOp handles communication with the Automation config related methods of the MongoDB Cloud API

type Client

type Client struct {
	BaseURL   *url.URL
	UserAgent string

	Organizations    OrganizationsService
	Projects         ProjectsService
	AutomationConfig AutomationService
	UnauthUsers      UnauthUsersService
	// contains filtered or unexported fields
}

Client manages communication with MongoDBAtlas v1.0 API

func New

func New(httpClient *http.Client, opts ...ClientOpt) (*Client, error)

New returns a new CloudManager API client instance.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new Cloud Manager API Client

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*atlas.Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response will be written to v, without attempting to decode it.

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, which will be resolved to the BaseURL of the Client. Relative URLS should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included in as the request body.

func (*Client) OnRequestCompleted

func (c *Client) OnRequestCompleted(rc RequestCompletionCallback)

OnRequestCompleted sets the DO API request completion callback

type ClientOpt

type ClientOpt func(*Client) error

ClientOpt are options for New.

func SetBaseURL

func SetBaseURL(bu string) ClientOpt

SetBaseURL is a client option for setting the base URL.

func SetUserAgent

func SetUserAgent(ua string) ClientOpt

SetUserAgent is a client option for setting the user agent.

type CreateUserResponse

type CreateUserResponse struct {
	APIKey string `json:"apiKey"`
	User   *User  `json:"user"`
}

CreateUserResponse API response for the CreateFirstUser() call

type HostCount

type HostCount struct {
	Arbiter   int `json:"arbiter"`
	Config    int `json:"config"`
	Master    int `json:"master"`
	Mongos    int `json:"mongos"`
	Primary   int `json:"primary"`
	Secondary int `json:"secondary"`
	Slave     int `json:"slave"`
}

HostCount number of processes per project.

type LogRotate

type LogRotate struct {
	SizeThresholdMB  float64 `json:"sizeThresholdMB,omitempty"`
	TimeThresholdHrs int     `json:"timeThresholdHrs,omitempty"`
}

LogRotate part of the internal Process struct

type Member

type Member struct {
	ID           int     `json:"_id"`
	ArbiterOnly  bool    `json:"arbiterOnly"`
	BuildIndexes bool    `json:"buildIndexes"`
	Hidden       bool    `json:"hidden"`
	Host         string  `json:"host"`
	Priority     float64 `json:"priority"`
	SlaveDelay   float64 `json:"slaveDelay"`
	Votes        float64 `json:"votes"`
}

Member configs

type Net

type Net struct {
	Port int     `json:"port,omitempty"`
	SSL  *NetSSL `json:"ssl,omitempty"`
}

Net part of the internal Process struct

type NetSSL

type NetSSL struct {
	Mode       string `json:"mode"`
	PEMKeyFile string `json:"PEMKeyFile"`
}

NetSSL defines SSL parameters for Net

type Options

type Options struct {
	DownloadBase string `json:"downloadBase"`
}

Options configs

type Organization

type Organization struct {
	ID    string        `json:"id,omitempty"`
	Links []*atlas.Link `json:"links,omitempty"`
	Name  string        `json:"name,omitempty"`
}

Organization represents the structure of an organization.

type Organizations

type Organizations struct {
	Links      []*atlas.Link   `json:"links"`
	Results    []*Organization `json:"results"`
	TotalCount int             `json:"totalCount"`
}

Organizations represents a array of organization

type OrganizationsService

type OrganizationsService interface {
	GetAllOrganizations(context.Context) (*Organizations, *atlas.Response, error)
	GetOneOrganization(context.Context, string) (*Organization, *atlas.Response, error)
	GetProjects(context.Context, string) (*Projects, *atlas.Response, error)
	Create(context.Context, *Organization) (*Organization, *atlas.Response, error)
	Delete(context.Context, string) (*atlas.Response, error)
}

OrganizationsService is an interface for interfacing with the Organizations endpoints of the MongoDB Atlas API. See more: https://docs.cloudmanager.mongodb.com/reference/api/organizations/

type OrganizationsServiceOp

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

OrganizationsServiceOp handles communication with the Projects related methods of the MongoDB Atlas API

func (*OrganizationsServiceOp) Create

func (s *OrganizationsServiceOp) Create(ctx context.Context, createRequest *Organization) (*Organization, *atlas.Response, error)

Create creates an organization. See more: https://docs.cloudmanager.mongodb.com/reference/api/organizations/organization-create-one/

func (*OrganizationsServiceOp) Delete

func (s *OrganizationsServiceOp) Delete(ctx context.Context, orgID string) (*atlas.Response, error)

Delete deletes an organization. See more: https://docs.cloudmanager.mongodb.com/reference/api/organizations/organization-delete-one/

func (*OrganizationsServiceOp) GetAllOrganizations

func (s *OrganizationsServiceOp) GetAllOrganizations(ctx context.Context) (*Organizations, *atlas.Response, error)

GetAllOrganizations gets all organizations. See more: https://docs.cloudmanager.mongodb.com/reference/api/organizations/organization-get-all/

func (*OrganizationsServiceOp) GetOneOrganization

func (s *OrganizationsServiceOp) GetOneOrganization(ctx context.Context, orgID string) (*Organization, *atlas.Response, error)

GetOneOrganization gets a single organization. See more: https://docs.cloudmanager.mongodb.com/reference/api/organizations/organization-get-one/

func (*OrganizationsServiceOp) GetProjects

func (s *OrganizationsServiceOp) GetProjects(ctx context.Context, orgID string) (*Projects, *atlas.Response, error)

GetProjects gets all projects for the given organization ID See more: https://docs.cloudmanager.mongodb.com/reference/api/organizations/organization-get-all-projects/

type Process

type Process struct {
	Args26                      Args26     `json:"args2_6"`
	AuthSchemaVersion           int        `json:"authSchemaVersion,omitempty"`
	LastGoalVersionAchieved     int        `json:"lastGoalVersionAchieved,omitempty"`
	Name                        string     `json:"name,omitempty"`
	Cluster                     string     `json:"cluster,omitempty"`
	FeatureCompatibilityVersion string     `json:"featureCompatibilityVersion,omitempty"`
	Hostname                    string     `json:"hostname,omitempty"`
	LogRotate                   *LogRotate `json:"logRotate,omitempty"`
	Plan                        []string   `json:"plan,omitempty"`
	ProcessType                 string     `json:"processType,omitempty"`
	Version                     string     `json:"version,omitempty"`
	Disabled                    bool       `json:"disabled,omitempty"`
	ManualMode                  bool       `json:"manualMode,omitempty"`
}

Process represents a single process in a deployment

type Project

type Project struct {
	ActiveAgentCount int           `json:"activeAgentCount,omitempty"`
	HostCounts       *HostCount    `json:"hostCounts,omitempty"`
	ID               string        `json:"id,omitempty"`
	LastActiveAgent  string        `json:"lastActiveAgent,omitempty"`
	Links            []*atlas.Link `json:"links,omitempty"`
	Name             string        `json:"name,omitempty"`
	OrgID            string        `json:"orgId,omitempty"`
	PublicAPIEnabled bool          `json:"publicApiEnabled,omitempty"`
	ReplicaSetCount  int           `json:"replicaSetCount,omitempty"`
	ShardCount       int           `json:"shardCount,omitempty"`
	Tags             []*string     `json:"tags,omitempty"`
}

Project represents the structure of a project.

type Projects

type Projects struct {
	Links      []*atlas.Link `json:"links"`
	Results    []*Project    `json:"results"`
	TotalCount int           `json:"totalCount"`
}

Projects represents a array of project

type ProjectsService

type ProjectsService interface {
	GetAllProjects(context.Context) (*Projects, *atlas.Response, error)
	GetOneProject(context.Context, string) (*Project, *atlas.Response, error)
	GetOneProjectByName(context.Context, string) (*Project, *atlas.Response, error)
	Create(context.Context, *Project) (*Project, *atlas.Response, error)
	Delete(context.Context, string) (*atlas.Response, error)
}

ProjectsService is an interface for interfacing with the Projects endpoints of the MongoDB Cloud Manager API. See more: https://docs.cloudmanager.mongodb.com/reference/api/groups/

type ProjectsServiceOp

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

ProjectsServiceOp handles communication with the Projects related methods of the MongoDB Cloud Manager API

func (*ProjectsServiceOp) Create

func (s *ProjectsServiceOp) Create(ctx context.Context, createRequest *Project) (*Project, *atlas.Response, error)

Create creates a project. See more: https://docs.cloudmanager.mongodb.com/reference/api/groups/create-one-group/

func (*ProjectsServiceOp) Delete

func (s *ProjectsServiceOp) Delete(ctx context.Context, projectID string) (*atlas.Response, error)

Delete deletes a project. See more: https://docs.cloudmanager.mongodb.com/reference/api/groups/delete-one-group/

func (*ProjectsServiceOp) GetAllProjects

func (s *ProjectsServiceOp) GetAllProjects(ctx context.Context) (*Projects, *atlas.Response, error)

GetAllProjects gets all projects. See more: https://docs.cloudmanager.mongodb.com/reference/api/groups/get-all-groups-for-current-user/

func (*ProjectsServiceOp) GetOneProject

func (s *ProjectsServiceOp) GetOneProject(ctx context.Context, projectID string) (*Project, *atlas.Response, error)

GetOneProject gets a single project. See more: https://docs.cloudmanager.mongodb.com/reference/api/groups/get-one-group-by-id/

func (*ProjectsServiceOp) GetOneProjectByName

func (s *ProjectsServiceOp) GetOneProjectByName(ctx context.Context, projectName string) (*Project, *atlas.Response, error)

GetOneProjectByName gets a single project by its name. See more: https://docs.cloudmanager.mongodb.com/reference/api/groups/get-one-group-by-name/

type ReplicaSet

type ReplicaSet struct {
	ID              string   `json:"_id"`
	ProtocolVersion string   `json:"protocolVersion,omitempty"`
	Members         []Member `json:"members"`
}

ReplicaSet configs

type Replication

type Replication struct {
	ReplSetName string `json:"replSetName,omitempty"`
}

Replication is part of the internal Process struct

type RequestCompletionCallback

type RequestCompletionCallback func(*http.Request, *http.Response)

RequestCompletionCallback defines the type of the request callback function

type SSL

type SSL struct {
	AutoPEMKeyFilePath    string `json:"autoPEMKeyFilePath,omitempty"`
	CAFilePath            string `json:"CAFilePath,omitempty"`
	ClientCertificateMode string `json:"clientCertificateMode,omitempty"`
}

SSL ssl config properties

type Sharding

type Sharding struct {
	ClusterRole string `json:"clusterRole"`
}

Sharding is part of the internal Process struct

type Storage

type Storage struct {
	DBPath string `json:"dbPath,omitempty"`
}

Storage part of the internal Process struct

type SystemLog

type SystemLog struct {
	Destination string `json:"destination,omitempty"`
	Path        string `json:"path,omitempty"`
}

SystemLog part of the internal Process struct

type UnauthUsersService

type UnauthUsersService interface {
	CreateFirstUser(context.Context, *User, *WhitelistOpts) (*CreateUserResponse, *atlas.Response, error)
}

UnauthUsersService is an interface for interfacing with unauthenticated APIs

type UnauthUsersServiceOp

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

UnauthUsersServiceOp handles communication with the unauthenticated API

func (*UnauthUsersServiceOp) CreateFirstUser

func (s *UnauthUsersServiceOp) CreateFirstUser(ctx context.Context, user *User, opts *WhitelistOpts) (*CreateUserResponse, *atlas.Response, error)

CreateFirstUser creates the first user for a new installation See more: https://docs.opsmanager.mongodb.com/master/reference/api/user-create-first/

type User

type User struct {
	Username     string        `json:"username"`
	Password     string        `json:"password,omitempty"`
	FirstName    string        `json:"firstName,omitempty"`
	LastName     string        `json:"lastName,omitempty"`
	EmailAddress string        `json:"emailAddress,omitempty"`
	ID           string        `json:"id,omitempty"`
	Links        []*atlas.Link `json:"links,omitempty"`
	Roles        []*UserRole   `json:"roles,omitempty"`
}

User wrapper for a user response, augmented with a few extra fields

type UserRole

type UserRole struct {
	RoleName string `json:"roleName"`
	GroupID  string `json:"groupId,omitempty"`
	OrgID    string `json:"orgId,omitempty"`
}

UserRole denotes a single user role

type WhitelistOpts

type WhitelistOpts struct {
	Whitelist []string `url:"whitelist"`
}

Jump to

Keyboard shortcuts

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