Documentation
¶
Overview ¶
Package opsmanager hosts a HTTP client which abstracts communication with Ops Manager instances.
To create a new client, you have to call the following code:
resolver := httpclient.NewURLResolverWithPrefix("http://OPS-MANAGER-INSTANCE", opsmanager.PublicApiPrefix) client := opsmanager.NewClient(WithResolver(resolver))
The client can then be used to issue requests such as:
user := User{Username: ..., Password: ..., ...} globalOwner := client.CreateFirstUser(user, WhitelistAllowAll)
See the Client interface below for a list of all the support operations. If however, you need one that is not currently supported, the _opsManagerApi_ struct extends _httpclient.BasicHTTPOperation_, allowing you to issue raw HTTP requests to the specified Ops Manager instance.
url := resolver.Of("/path/to/a/resource/%s", id) resp:= client.GetJSON(url) useful.PanicOnUnrecoverableError(resp.Err) defer useful.LogError(resp.Response.Body.Close) var data SomeType decoder := json.NewDecoder(resp.Response.Body) err := decoder.Decode(&result) useful.PanicOnUnrecoverableError(err) // do something with _data_
You can create an authenticated client as follows:
resolver := httpclient.NewURLResolverWithPrefix("http://OPS-MANAGER-INSTANCE", PublicAPIPrefix) client:= opsmanager.NewClientWithDigestAuth(resolver, "username", "password")
The code above is a simplification of the following (which can be used for a more configurable set-up):
withResolver := opsmanager.WithResolver(httpclient.NewURLResolverWithPrefix("http://OPS-MANAGER-INSTANCE", PublicAPIPrefix)) withDigestAuth := httpclient.WithDigestAuthentication(publicKey, privateKey) withHTTPClient := opsmanager.WithHTTPClient(httpclient.NewClient(withDigestAuth)) client := opsmanager.NewClient(withResolver, withHTTPClient)
The following can be used for authentication:
- Ops Manager user credentials: (username, password) - only works with some APIs and should not be used
- Programmatic API keys: (publicKey, privateKey) - preferred credentials pair
- Ops Manager user and a Personal API Key: (username, personalAPIKey) - deprecated
You can read more about this topic here: https://docs.opsmanager.mongodb.com/master/tutorial/configure-public-api-access/#configure-public-api-access
Index ¶
- Constants
- func AddProcessToDeployment(process Process, automationConfig map[string]interface{}) map[string]interface{}
- func WithHTTPClient(basicClient httpclient.BasicClient) func(*opsManagerClient)
- func WithResolver(resolver httpclient.URLResolver) func(*opsManagerClient)
- type AgentAttributes
- type AgentResult
- type AgentVersion
- type Args26
- type Auth
- type AutomationConfig
- type AutomationStatusResponse
- type BackupConfigs
- type BackupResult
- type Build
- type Client
- type CreateAgentAPIKEYResponse
- type CreateFirstUserResponse
- type GetAgentsByTypeResponse
- type HostCounts
- type HostResponse
- type HostsResponse
- type LDAPGroupMapping
- type Link
- type LogRotate
- type Member
- type MongoDBVersion
- type Net
- type NetSSL
- type Options
- type Process
- type ProjectResponse
- type ProjectsResponse
- type RawAutomationConfig
- type ReplicaSet
- type ReplicationArg
- type Result
- type Role
- type SSL
- type Shard
- type Sharding
- type ShardingArg
- type StorageArg
- type SystemLog
- type User
- type UserResponse
- type UserRole
- type UserWanted
Constants ¶
const PublicAPIPrefix = "/api/public/v1.0"
PublicAPIPrefix prefix
Variables ¶
This section is empty.
Functions ¶
func AddProcessToDeployment ¶
func AddProcessToDeployment(process Process, automationConfig map[string]interface{}) map[string]interface{}
AddProcessToDeployment adds the specified Process to the processes list of the given deployment
func WithHTTPClient ¶
func WithHTTPClient(basicClient httpclient.BasicClient) func(*opsManagerClient)
WithHTTPClient configures an Ops Manager which delegates basic HTTP operations to the specified client
func WithResolver ¶
func WithResolver(resolver httpclient.URLResolver) func(*opsManagerClient)
WithResolver configures an Ops Manager client which relies on the specified resolver
Types ¶
type AgentAttributes ¶ added in v0.0.2
type AgentAttributes struct { LogPath string `json:"logPath,omitempty"` LogPathWindows string `json:"logPathWindows,omitempty"` LogRotate *LogRotate `json:"logRotate"` Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` KerberosPrincipal string `json:"kerberosPrincipal,omitempty"` KerberosKeytab string `json:"kerberosKeytab,omitempty"` KerberowWindowsUsername string `json:"kerberosWindowsUsername,omitempty"` KerberowWindowsPassword string `json:"kerberosWindowsPassword,omitempty"` SSLPEMKeyfile string `json:"sslPEMKeyfile,omitempty"` SSLPEMKeyfileWindows string `json:"sslPEMKeyfileWindows,omitempty"` SSLPEMKeyPwd string `json:"sslPEMKeyPwd,omitempty"` }
AgentAttributes represent an agent properties
type AgentResult ¶
type AgentResult struct { ConfCount int `json:"confCount,omitempty"` Hostname string `json:"hostname,omitempty"` LastConf string `json:"lastConf,omitempty"` StateName string `json:"stateName,omitempty"` TypeName string `json:"typeName,omitempty"` }
AgentResult represents an agent returned by the GetAgentsByType() call
type AgentVersion ¶ added in v0.0.2
type AgentVersion struct { Name string `json:"name,omitempty"` Hostname string `json:"hostname"` LogPath string `json:"logPath,omitempty"` LogRotate *LogRotate `json:"logRotate,omitempty"` }
AgentVersion agent versions struct
type Args26 ¶
type Args26 struct { NET *Net `json:"net,omitempty"` Storage *StorageArg `json:"storage,omitempty"` SystemLog *SystemLog `json:"systemLog,omitempty"` Replication *ReplicationArg `json:"replication,omitempty"` Sharding *ShardingArg `json:"sharding,omitempty"` }
Args26 part of the internal Process struct
type Auth ¶ added in v0.0.2
type Auth struct { AutoUser string `json:"autoUser"` AutoPwd string `json:"autoPwd"` DeploymentAuthMechanisms []string `json:"deploymentAuthMechanisms"` Key string `json:"key"` Keyfile string `json:"keyfile"` KeyfileWindows string `json:"keyfileWindows"` Disabled bool `json:"disabled"` UsersDeleted []interface{} `json:"usersDeleted"` UsersWanted []UserWanted `json:"usersWanted"` AutoAuthMechanism string `json:"autoAuthMechanism"` }
Auth authentication config
type AutomationConfig ¶
type AutomationConfig struct { Auth Auth `json:"auth,omitempty"` LDAP map[string]interface{} `json:"ldap,omitempty"` Processes []*Process `json:"processes,omitempty"` ReplicaSets []ReplicaSet `json:"replicaSets,omitempty"` Roles []map[string]interface{} `json:"roles,omitempty"` MonitoringVersions []*AgentVersion `json:"monitoringVersions,omitempty"` BackupVersions []*AgentVersion `json:"backupVersions,omitempty"` MongoSQLDs []map[string]interface{} `json:"mongosqlds,omitempty"` MongoDBVersions []*MongoDBVersion `json:"mongoDbVersions,omitempty"` AgentVersion map[string]interface{} `json:"agentVersion,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"` MongoTs []map[string]interface{} `json:"mongots,omitempty"` Options *Options `json:"options"` SSL *SSL `json:"ssl,omitempty"` Version int `json:"version,omitempty"` Sharding []Sharding `json:"sharding,omitempty"` UIBaseURL string `json:"uiBaseUrl,omitempty"` }
AutomationConfig represents a cluster definition within an automation config object NOTE: this struct is mutable
type AutomationStatusResponse ¶
type AutomationStatusResponse struct { Processes []Process `json:"processes"` GoalVersion int `json:"goalVersion"` }
AutomationStatusResponse automation status
type BackupConfigs ¶ added in v0.1.0
type BackupConfigs struct { Links []Link `json:"links"` BackupResults []BackupResult `json:"results"` TotalCount int `json:"totalCount"` }
BackupConfigs response structure
type BackupResult ¶ added in v0.1.0
type BackupResult struct { AuthMechanismName string `json:"authMechanismName,omitempty"` ClusterID string `json:"clusterId,omitempty"` EncryptionEnabled bool `json:"encryptionEnabled,omitempty"` ExcludedNamespaces []string `json:"excludedNamespaces,omitempty"` IncludedNamespaces []string `json:"includednamespaces,omitempty"` GroupID string `json:"groupId,omitempty"` Links []Link `json:"links,omitempty"` SSLEnabled bool `json:"sslEnabled,omitempty"` StatusName string `json:"statusName,omitempty"` StorageEngineName string `json:"storageEngineName,omitempty"` Username string `json:"username,omitempty"` }
BackupResult response structure
type Build ¶
type Build struct { Architecture string `json:"architecture"` Bits int `json:"bits"` Flavor string `json:"flavor,omitempty"` GitVersion string `json:"gitVersion,omitempty"` MaxOsVersion string `json:"maxOsVersion,omitempty"` MinOsVersion string `json:"minOsVersion,omitempty"` Platform string `json:"platform,omitempty"` URL string `json:"url,omitempty"` Modules []string `json:"modules,omitempty"` Win2008plus bool `json:"win2008plus,omitempty"` WinVCRedistDll string `json:"winVCRedistDll,omitempty"` WinVCRedistOptions []string `json:"winVCRedistOptions,omitempty"` WinVCRedistURL string `json:"winVCRedistUrl,omitempty"` WinVCRedistVersion string `json:"winVCRedistVersion,omitempty"` }
Build a MongoDB build
type Client ¶
type Client interface { httpclient.BasicClient // https://docs.opsmanager.mongodb.com/master/reference/api/user-create-first/ CreateFirstUser(user User, whitelistIP string) (CreateFirstUserResponse, error) // https://docs.opsmanager.mongodb.com/master/reference/api/groups/get-all-groups-for-current-user/ GetAllProjects() (ProjectsResponse, error) // https://docs.opsmanager.mongodb.com/master/reference/api/groups/create-one-group/ CreateOneProject(name string, orgID string) (ProjectResponse, error) // https://docs.opsmanager.mongodb.com/master/reference/api/automation-config/#get-the-automation-configuration GetAutomationConfig(projectID string) (AutomationConfig, error) // https://docs.opsmanager.mongodb.com/master/reference/api/automation-config/#update-the-automation-configuration UpdateAutomationConfig(projectID string, config AutomationConfig) (AutomationConfig, error) // GET /agents/api/automation/conf/v1/{projectID} GetRawAutomationConfig(projectID string) (RawAutomationConfig, error) // https://docs.opsmanager.mongodb.com/master/reference/api/automation-status/ GetAutomationStatus(projectID string) (AutomationStatusResponse, error) // https://docs.opsmanager.mongodb.com/master/reference/api/agents-get-by-type/ GetAgentsByType(projectID string, agentType string) (GetAgentsByTypeResponse, error) // https://docs.opsmanager.mongodb.com/master/reference/api/automation-config/#update-the-automation-configuration UpdateDeployments(projectID string, body io.Reader) (map[string]interface{}, error) // https://docs.opsmanager.mongodb.com/master/reference/api/agentapikeys/create-one-agent-api-key/ CreateAgentAPIKEY(projectID string, desc string) (CreateAgentAPIKEYResponse, error) // https://docs.opsmanager.mongodb.com/master/reference/api/groups/get-one-group-by-id/ GetProjectByID(projectID string) (ProjectResponse, error) // https://docs.opsmanager.mongodb.com/master/reference/api/groups/get-one-group-by-name/ GetProjectByName(name string) (ProjectResponse, error) // https://docs.opsmanager.mongodb.com/master/reference/api/groups/delete-one-group/ DeleteProject(projectID string) error // https://docs.opsmanager.mongodb.com/master/reference/api/groups/add-or-remove-tags-from-one-group/ SetProjectTags(projectID string, tags []string) (ProjectResponse, error) // https://docs.opsmanager.mongodb.com/master/reference/api/hosts/get-all-hosts-in-group/ GetHosts(projectID string) (HostsResponse, error) // https://docs.opsmanager.mongodb.com/master/reference/api/automation-config/index.html#update-the-monitoring-or-backup UpdateMonitoringConfig(projectID string, config AgentAttributes) error // https://docs.opsmanager.mongodb.com/master/reference/api/automation-config/index.html#update-the-monitoring-or-backup UpdateBackupConfig(projectID string, config AgentAttributes) error // https://docs.opsmanager.mongodb.com/master/reference/api/backup/get-all-backup-configs-for-group/ GetBackupConfigs(projectID string) (BackupConfigs, error) }
Client defines the API actions implemented in this client
func NewClient ¶
func NewClient(configs ...func(*opsManagerClient)) Client
NewClient builds a new API client for connecting to Ops Manager
func NewClientWithDigestAuth ¶
func NewClientWithDigestAuth(resolver httpclient.URLResolver, username string, password string) Client
NewClientWithDigestAuth builds a new API client with default configurations, which uses digest authentication
func NewDefaultClient ¶
func NewDefaultClient(resolver httpclient.URLResolver) Client
NewDefaultClient builds a new, unauthenticated, API client with default configurations
type CreateAgentAPIKEYResponse ¶
type CreateAgentAPIKEYResponse struct { ID string `json:"_id,omitempty"` CreatedBy string `json:"createdBy,omitempty"` CreatedIPAddr string `json:"createdIpAddr,omitempty"` CreatedTime int `json:"createdTime,omitempty"` CreatedUserID string `json:"createdUserId,omitempty"` Desc string `json:"desc,omitempty"` Key string `json:"key,omitempty"` }
CreateAgentAPIKEYResponse API response for the CreateAgentAPIKEY() call
type CreateFirstUserResponse ¶
type CreateFirstUserResponse struct { APIKey string `json:"apiKey"` User UserResponse `json:"user"` }
CreateFirstUserResponse API response for the CreateFirstUser() call
type GetAgentsByTypeResponse ¶
type GetAgentsByTypeResponse struct { Links []Link `json:"links,omitempty"` Results []AgentResult `json:"results,omitempty"` TotalCount int `json:"totalCount,omitempty"` }
GetAgentsByTypeResponse API response for the GetAgentsByType() call
type HostCounts ¶
type HostCounts struct { Arbiter int `json:"arbiter"` Config int `json:"config"` Primary int `json:"primary"` Secondary int `json:"secondary"` Mongos int `json:"mongos"` Master int `json:"master"` Slave int `json:"slave"` }
HostCounts for the project
type HostResponse ¶ added in v0.0.2
type HostResponse struct { ID string `json:"id"` Aliases []string `json:"aliases,omitempty"` AlertsEnabled bool `json:"alertsEnabled"` AuthMechanismName string `json:"authMechanismName,omitempty"` ClusterID string `json:"clusterId,omitempty"` Created string `json:"created,omitempty"` Deactivated bool `json:"deactivated"` GroupID string `json:"groupId,omitempty"` HasStartupWarnings bool `json:"hasStartupWarnings"` Hidden bool `json:"hidden"` HiddenSecondary bool `json:"hiddenSecondary"` HostEnabled bool `json:"hostEnabled"` Hostname string `json:"hostname,omitempty"` IPAddress string `json:"ipAddress,omitempty"` JournalingEnabled bool `json:"journalingEnabled"` LastDataSizeBytes int `json:"lastDataSizeBytes,omitempty"` LastIndexSizeBytes int `json:"lastIndexSizeBytes,omitempty"` LastPing string `json:"lastPing,omitempty"` LastRestart string `json:"lastRestart,omitempty"` Links []interface{} `json:"links,omitempty"` LogsEnabled bool `json:"logsEnabled"` LowULimit bool `json:"lowULimit"` MuninEnabled bool `json:"muninEnabled"` MuninPort int `json:"muninPort,omitempty"` Port int `json:"port,omitempty"` ProfilerEnabled bool `json:"profilerEnabled"` ReplicaSetName string `json:"replicaSetName,omitempty"` ReplicaStateName string `json:"replicaStateName,omitempty"` ShardName string `json:"shardName,omitempty"` SlaveDelaySec int `json:"slaveDelaySec,omitempty"` SSLEnabled bool `json:"sslEnabled"` TypeName string `json:"typeName,omitempty"` UptimeMSec int `json:"uptimeMsec,omitempty"` Version string `json:"version,omitempty"` }
HostResponse represents a host information
type HostsResponse ¶ added in v0.0.2
type HostsResponse struct { Results []HostResponse `json:"results,omitempty"` Links []interface{} `json:"links,omitempty"` TotalCount int `json:"totalCount,omitempty"` }
HostsResponse an array of hosts
type LDAPGroupMapping ¶
type LDAPGroupMapping struct { RoleName string `json:"roleName,omitempty"` LdapGroups []string `json:"ldapGroups,omitempty"` }
LDAPGroupMapping holds a single mapping of role to LDAP groups
type LogRotate ¶
type LogRotate struct { SizeThresholdMB float64 `json:"sizeThresholdMB,omitempty"` TimeThresholdHrs int `json:"timeThresholdHrs,omitempty"` }
LogRotate part of the internal Process struct
type Member ¶ added in v0.0.2
type Member struct { ID int `json:"_id"` ArbiterOnly bool `json:"arbiterOnly"` Hidden bool `json:"hidden"` Host string `json:"host"` Priority float64 `json:"priority"` SlaveDelay int `json:"slaveDelay"` Votes float64 `json:"votes"` }
Member configs
type MongoDBVersion ¶
type MongoDBVersion struct { Name string `json:"name,omitempty"` Builds []Build `json:"builds,omitempty"` }
MongoDBVersion ways to install MongoDB
type Options ¶ added in v0.0.2
type Options struct {
DownloadBase string `json:"downloadBase"`
}
Options configs
type Process ¶
type Process struct { Name string `json:"name,omitempty"` ProcessType string `json:"processType,omitempty"` Version string `json:"version,omitempty"` AuthSchemaVersion int `json:"authSchemaVersion,omitempty"` FeatureCompatibilityVersion string `json:"featureCompatibilityVersion,omitempty"` Disabled bool `json:"disabled,omitempty"` ManualMode bool `json:"manualMode,omitempty"` Hostname string `json:"hostname,omitempty"` Args26 *Args26 `json:"args2_6,omitempty"` LogRotate *LogRotate `json:"logRotate,omitempty"` Plan []string `json:"plan,omitempty"` LastGoalVersionAchieved int `json:"lastGoalVersionAchieved,omitempty"` Cluster string `json:"cluster,omitempty"` }
Process represents a single process in a deployment
type ProjectResponse ¶
type ProjectResponse struct { ID string `json:"id"` OrgID string `json:"orgId"` Name string `json:"name"` LastActiveAgent string `json:"lastActiveAgent,omitempty"` AgentAPIKey string `json:"agentApiKey,omitempty"` ActiveAgentCount int `json:"activeAgentCount"` HostCounts HostCounts `json:"hostCounts,omitempty"` PublicAPIEnabled bool `json:"publicApiEnabled"` ReplicaSetCount int `json:"replicaSetCount"` ShardCount int `json:"shardCount"` Tags []string `json:"tags,omitempty"` Links []Link `json:"links,omitempty"` LDAPGroupMappings []LDAPGroupMapping `json:"ldapGroupMappings,omitempty"` }
ProjectResponse represents the structure of a project
type ProjectsResponse ¶
type ProjectsResponse struct { Links []Link `json:"links"` Results []ProjectResponse `json:"results"` TotalCount int `json:"totalCount"` }
ProjectsResponse represents a array of project
type RawAutomationConfig ¶
type RawAutomationConfig struct { IDCounter int `json:"idCounter,omitempty"` State string `json:"state,omitempty"` Version int `json:"version,omitempty"` GroupID string `json:"groupId,omitempty"` UserID string `json:"userId,omitempty"` PublishTimestamp int `json:"publishTimestamp,omitempty"` PublishedVersion string `json:"publishedVersion,omitempty"` SaveTimestamp int `json:"saveTimestamp,omitempty"` LatestAutomationAgentVersionName string `json:"latestAutomationAgentVersionName,omitempty"` LatestMonitoringAgentVersionName string `json:"latestMonitoringAgentVersionName,omitempty"` LatestBackupAgentVersionName string `json:"latestBackupAgentVersionName,omitempty"` LatestBiConnectorVersionName string `json:"latestBiConnectorVersionName,omitempty"` Cluster *AutomationConfig `json:"cluster,omitempty"` VersionConfig map[string]interface{} `json:"versionConfig,omitempty"` LogRotate map[string]interface{} `json:"logRotate,omitempty"` MonitoringAgentTemplate map[string]interface{} `json:"monitoringAgentTemplate,omitempty"` BackupAgentTemplate map[string]interface{} `json:"backupAgentTemplate,omitempty"` CPSModuleTemplate map[string]interface{} `json:"cpsModuleTemplate,omitempty"` DeploymentJobStatuses []interface{} }
RawAutomationConfig represents a raw automation config NOTE: this struct is mutable
type ReplicaSet ¶ added in v0.0.2
type ReplicaSet struct { ID string `json:"_id"` ProtocolVersion string `json:"protocolVersion,omitempty"` Members []Member `json:"members"` }
ReplicaSet configs
type ReplicationArg ¶ added in v0.0.2
type ReplicationArg struct {
ReplSetName string `json:"replSetName"`
}
ReplicationArg is part of the internal Process struct
type Result ¶
type Result struct { Links []Link `json:"links"` RoleNames []string `json:"roleNames"` TeamID string `json:"teamId"` }
Result is part of TeamsAssigned structure
type SSL ¶ added in v0.0.2
type SSL struct { AutoPEMKeyFilePath string `json:"autoPEMKeyFilePath"` CAFilePath string `json:"CAFilePath"` ClientCertificateMode string `json:"clientCertificateMode"` }
SSL ssl config properties
type Sharding ¶ added in v0.0.2
type Sharding struct { Shards []Shard `json:"shards"` Name string `json:"name"` ConfigServer []interface{} `json:"configServer"` ConfigServerReplica string `json:"configServerReplica"` Collections []interface{} `json:"collections"` }
Sharding configs
type ShardingArg ¶ added in v0.0.2
type ShardingArg struct {
ClusterRole string `json:"clusterRole"`
}
ShardingArg is part of the internal Process struct
type StorageArg ¶ added in v0.0.2
type StorageArg struct {
DBPath string `json:"dbPath,omitempty"`
}
StorageArg 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 User ¶
type User struct { Username string `json:"username"` Password string `json:"password,omitempty"` FirstName string `json:"firstName"` LastName string `json:"lastName"` EmailAddress string `json:"emailAddress,omitempty"` }
User request object which identifies a user
type UserResponse ¶
type UserResponse struct { User ID string `json:"id"` Links []Link `json:"links,omitempty"` Roles []UserRole `json:"roles,omitempty"` }
UserResponse wrapper for a user response, augmented with a few extra fields
Source Files
¶
- api_create_agent_api_key.go
- api_create_first_user.go
- api_create_project.go
- api_delete_project.go
- api_get_agents_by_type.go
- api_get_all_projects.go
- api_get_automation_config.go
- api_get_automation_status.go
- api_get_backup_configs.go
- api_get_hosts.go
- api_get_project_by_id.go
- api_get_project_by_name.go
- api_get_raw_automation_config.go
- api_set_project_tags.go
- api_update_automation_config.go
- api_update_deployments.go
- api_update_monitoring_config.go
- client.go
- prefixes.go
- schema_automation.go
- schema_link.go
- schema_process.go