rubrikpolaris

package
v1.0.15 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package rubrikpolaris transforms the Rubrik API functionality into easy to consume functions. This eliminates the need to understand how to consume raw Rubrik APIs with Go and extends upon one of Rubrik’s main design centers - simplicity. Rubrik’s API first architecture enables organizations to embrace and integrate Rubrik functionality into their existing automation processes.

Index

Constants

View Source
const (
	DefaultServiceAccountFile = "~/.rubrik/polaris-service-account.json"
)

Variables

This section is empty.

Functions

func ExpandTildePath added in v1.0.11

func ExpandTildePath(path string) (string, error)

ExpandTildePath will replace a "~/" prefix with the user home directory. Caveat: only "~/" is supported (~user/path is not).

func GetStringFromSlice added in v1.0.11

func GetStringFromSlice(s []string, index int, replaceEmpty bool,
	defaultVal string) string

GetStringFromSlice is useful to emulate default function params: it returns s[index] if it exists; if it doesn't, it returns defaultVal; if replaceEmpty is true and s[index] is empty, it also returns defaultVal.

func OperationNamePrefix added in v1.0.12

func OperationNamePrefix(operationNameSecondPrefix ...string) string

OperationNamePrefix returns a prefix string to be used when sending up operation names to Rubrik. The default is "SdkGoLang". So for instance if sending up the query "RadarEventsPerTimePeriod", the operation name will be "SdkGoLangRadarEventsPerTimePeriod".

A less common use case is to specify a *second* prefix: say operationNameSecondPrefix="XYZ", then for the query above, the operation name sent up to Rubrik would be "SdkGoLangXYZRadarEventsPerTimePeriod"

Types

type AllAuditLog

type AllAuditLog struct {
	Data struct {
		UserAuditConnection struct {
			Edges []struct {
				Node struct {
					ID       string `mapstructure:"id"`
					Message  string `mapstructure:"message"`
					Time     string `mapstructure:"time"`
					Severity string `mapstructure:"severity"`
					Status   string `mapstructure:"status"`
					Cluster  struct {
						ID   string `mapstructure:"id"`
						Name string `mapstructure:"name"`
					} `mapstructure:"cluster"`
				} `mapstructure:"node"`
			} `mapstructure:"edges"`
		} `mapstructure:"userAuditConnection"`
	} `mapstructure:"data"`
}

type AllEvent

type AllEvent struct {
	Data struct {
		ActivitySeriesConnection struct {
			Edges []struct {
				Node struct {
					ID                   int         `mapstructure:"id"`
					Fid                  string      `mapstructure:"fid"`
					ActivitySeriesID     string      `mapstructure:"activitySeriesId"`
					LastUpdated          string      `mapstructure:"lastUpdated"`
					LastActivityType     string      `mapstructure:"lastActivityType"`
					LastActivityStatus   string      `mapstructure:"lastActivityStatus"`
					ObjectID             string      `mapstructure:"objectId"`
					ObjectName           string      `mapstructure:"objectName"`
					ObjectType           string      `mapstructure:"objectType"`
					Severity             string      `mapstructure:"severity"`
					Progress             interface{} `mapstructure:"progress"`
					IsCancelable         interface{} `mapstructure:"isCancelable"`
					IsPolarisEventSeries bool        `mapstructure:"isPolarisEventSeries"`
					Cluster              struct {
						ID   string `mapstructure:"id"`
						Name string `mapstructure:"name"`
					} `mapstructure:"cluster"`
					ActivityConnection struct {
						Nodes []struct {
							ID      string `mapstructure:"id"`
							Message string `mapstructure:"message"`
						} `mapstructure:"nodes"`
					} `mapstructure:"activityConnection"`
				} `mapstructure:"node"`
			} `mapstructure:"edges"`
			PageInfo struct {
				EndCursor       string `mapstructure:"endCursor"`
				HasNextPage     bool   `mapstructure:"hasNextPage"`
				HasPreviousPage bool   `mapstructure:"hasPreviousPage"`
			} `mapstructure:"pageInfo"`
		} `mapstructure:"activitySeriesConnection"`
	} `mapstructure:"data"`
}

type AllEvents

type AllEvents struct {
	Data struct {
		ActivitySeriesConnection struct {
			Edges []struct {
				Node struct {
					ID                   int         `mapstructure:"id"`
					Fid                  string      `mapstructure:"fid"`
					ActivitySeriesID     string      `mapstructure:"activitySeriesId"`
					LastUpdated          string      `mapstructure:"lastUpdated"`
					LastActivityType     string      `mapstructure:"lastActivityType"`
					LastActivityStatus   string      `mapstructure:"lastActivityStatus"`
					ObjectID             string      `mapstructure:"objectId"`
					ObjectName           string      `mapstructure:"objectName"`
					ObjectType           string      `mapstructure:"objectType"`
					Severity             string      `mapstructure:"severity"`
					Progress             string      `mapstructure:"progress"`
					IsCancelable         interface{} `mapstructure:"isCancelable"`
					IsPolarisEventSeries bool        `mapstructure:"isPolarisEventSeries"`
					Typename             string      `mapstructure:"__typename"`
					Cluster              struct {
						ID       string `mapstructure:"id"`
						Name     string `mapstructure:"name"`
						Typename string `mapstructure:"__typename"`
					} `mapstructure:"cluster"`
					ActivityConnection struct {
						Nodes []struct {
							ID       string `mapstructure:"id"`
							Message  string `mapstructure:"message"`
							Typename string `mapstructure:"__typename"`
						} `mapstructure:"nodes"`
						Typename string `mapstructure:"__typename"`
					} `mapstructure:"activityConnection"`
				} `mapstructure:"node"`
				Typename string `mapstructure:"__typename"`
			} `mapstructure:"edges"`
			PageInfo struct {
				EndCursor       string `mapstructure:"endCursor"`
				HasNextPage     bool   `mapstructure:"hasNextPage"`
				HasPreviousPage bool   `mapstructure:"hasPreviousPage"`
				Typename        string `mapstructure:"__typename"`
			} `mapstructure:"pageInfo"`
			Typename string `mapstructure:"__typename"`
		} `mapstructure:"activitySeriesConnection"`
	} `mapstructure:"data"`
}

type ClusterIdByName

type ClusterIdByName struct {
	Data struct {
		ClusterConnection struct {
			Edges []struct {
				Node struct {
					ID   string `mapstructure:"id"`
					NAME string `mapstructure:"name"`
				} `mapstructure:"node"`
			} `mapstructure:"edges"`
			PageInfo struct {
				EndCursor   string `mapstructure:"endCursor"`
				HasNextPage bool   `mapstructure:"hasNextPage"`
			} `mapstructure:"pageInfo"`
		} `mapstructure:"clusterConnection"`
	} `mapstructure:"data"`
}

type Credentials

type Credentials struct {
	PolarisDomain  string
	Host           string
	Username       string
	Password       string
	OperationName  string
	ClientId       string
	ClientSecret   string
	AccessTokenUri string
}

Credentials contains the parameters used to authenticate against the Rubrik cluster and can be populated through the ConnectX() factory functions: - Connect(), - ConnectEnv(), - ConnectServiceAccountFromFile() and - ConnectServiceAccountFromString()

func Connect

func Connect(
	nodeIP, username, password string,
	operationName ...string) *Credentials

Connect initializes a new API client based on manually provided Rubrik cluster credentials. When possible, the Rubrik credentials should not be stored as plain text in your .go file. ConnectEnv() can be used as a safer alternative. The operationName is an optional value which can be used to add a custom prefix to the GraphQL Operation Name which is useful for tracking specific usage in the Polaris logs.

func ConnectEnv

func ConnectEnv(
	operationName ...string) (*Credentials, error)

ConnectEnv is the preferred method to initialize a new API client by attempting to read the following environment variables:

rubrik_polaris_domain

rubrik_polaris_username

rubrik_polaris_password

rubrik_cdm_token will always take precedence over rubrik_polaris_username and rubrik_polaris_password

func ConnectServiceAccount

func ConnectServiceAccount(
	args ...string) (*Credentials, error)

ConnectServiceAccount is deprecated. It is equivalent to: ConnectServiceAccountFromFile(DefaultServiceAccountFile)

Use ConnectServiceAccountFromFile or ConnectServiceAccountFromString instead. @deprecated

func ConnectServiceAccountFromFile added in v1.0.12

func ConnectServiceAccountFromFile(
	serviceAccountFile string,
	operationName ...string) (*Credentials, error)

ConnectServiceAccountFromFile is similar to Connect but retrieves secrets from a service account JSON file.

Example: use the default service account file:

creds,err := ConnectServiceAccountFromFile(DefaultServiceAccountFile)

func ConnectServiceAccountFromString added in v1.0.11

func ConnectServiceAccountFromString(
	jsonString string,
	operationName ...string) (*Credentials, error)

ConnectServiceAccountFromString is similar to ConnectServiceAccountFromFile but takes the JSON string as parameter instead of the JSON file path.

func (*Credentials) EnableRadar

func (c *Credentials) EnableRadar(clusterId string, timeout ...int) (*EnableRadar, error)

GetRadarAndSonarEvents returns all Radar and Sonar events for the specified time period

func (*Credentials) GetAllAuditLog

func (c *Credentials) GetAllAuditLog(timeAgo string, timeout ...int) (*AllAuditLog, error)

func (*Credentials) GetAllEvents

func (c *Credentials) GetAllEvents(secondsTimeRange int, timeout ...int) (*AllEvents, error)

func (*Credentials) GetAllPolarisEvents

func (c *Credentials) GetAllPolarisEvents(timeAgo string, timeout ...int) (*PolarisEvents, error)

func (*Credentials) GetAllRscEventsForCluster added in v1.0.15

func (c *Credentials) GetAllRscEventsForCluster(timeAgo string, clusterId string, timeout ...int) (*PolarisEvents, error)

func (*Credentials) GetCDMClusterIdByName

func (c *Credentials) GetCDMClusterIdByName(clusterNames []string, timeout ...int) ([]string, error)

func (*Credentials) GetEventDetails

func (c *Credentials) GetEventDetails(activitySeriesID, clusterUUID string, timeout ...int) (*EventSeriesDetail, error)

func (*Credentials) GetRadarAndSonarEvents

func (c *Credentials) GetRadarAndSonarEvents(timeAgo string, timeout ...int) (*RadarEvent, error)

GetRadarAndSonarEvents returns all Radar and Sonar events for the specified time period

func (*Credentials) GetRadarEnabledClusters

func (c *Credentials) GetRadarEnabledClusters(timeout ...int) (map[string]string, error)

GetRadarEnabledClusters returns the name of each Rubrik cluster with Radar enabled map to its ID value.

func (*Credentials) GetRadarEvents

func (c *Credentials) GetRadarEvents(timeAgo string, timeout ...int) (*RadarEvent, error)

GetRadarEvents returns the name of each Rubrik cluster with Radar enabled map to its ID value.

func (*Credentials) GetRadarEventsLast24Hours

func (c *Credentials) GetRadarEventsLast24Hours(timeout ...int) (float64, error)

RadarEventsLast24Hours returns the number of Radar events that occured in the last 24 hours

func (*Credentials) GetRadarEventsLast30Days

func (c *Credentials) GetRadarEventsLast30Days(timeout ...int) (float64, error)

RadarEventsLast30Days returns the number of Radar events that occured in the last 30 days

func (*Credentials) GetRadarEventsLastYear

func (c *Credentials) GetRadarEventsLastYear(timeout ...int) (float64, error)

RadarEventsLastYear returns the number of Radar events that occured in the last year

func (*Credentials) MutationWithVariables

func (c *Credentials) MutationWithVariables(
	query string,
	variables map[string]interface{},
	timeout ...int) (interface{}, error)

func (*Credentials) Query

func (c *Credentials) Query(query string, timeout ...int) (interface{}, error)

Query sends a POST request to the provided Rubrik API endpoint and returns the full API response. Supported "apiVersions" are v1, v2, and internal. The optional timeout value corresponds to the number of seconds to wait to establish a connection to the Rubrik cluster before returning a timeout error. If no value is provided, a default of 15 seconds will be used.

func (*Credentials) QueryWithVariables

func (c *Credentials) QueryWithVariables(
	query string,
	variables map[string]interface{},
	timeout ...int) (interface{}, error)

type EnableRadar

type EnableRadar struct {
	Data struct {
		EnableAutomaticFmdUpload struct {
			ClusterID string `mapstructure:"clusterId"`
			Enabled   bool   `mapstructure:"enabled"`
		} `mapstructure:"enableAutomaticFmdUpload"`
	} `mapstructure:"data"`
}

type EventSeriesDetail

type EventSeriesDetail struct {
	Data struct {
		ActivitySeries struct {
			ActivityConnection struct {
				Nodes []struct {
					Message  string `mapstructure:"message"`
					Status   string `mapstructure:"status"`
					Time     string `mapstructure:"time"`
					Severity string `mapstructure:"severity"`
				} `mapstructure:"nodes"`
			} `mapstructure:"activityConnection"`
			ID               int    `mapstructure:"id"`
			Fid              string `mapstructure:"fid"`
			ActivitySeriesID string `mapstructure:"activitySeriesId"`
			ObjectID         string `mapstructure:"objectId"`
			ObjectName       string `mapstructure:"objectName"`
			ObjectType       string `mapstructure:"objectType"`
			Cluster          struct {
				ID   string `mapstructure:"id"`
				Name string `mapstructure:"name"`
			} `mapstructure:"cluster"`
			LastActivityStatus string `mapstructure:"lastActivityStatus"`
		} `mapstructure:"activitySeries"`
	} `mapstructure:"data"`
}

type EventSeriesDetailMessage

type EventSeriesDetailMessage struct {
	Message          string `mapstructure:"message"`
	Status           string `mapstructure:"status"`
	Time             string `mapstructure:"time"`
	Severity         string `mapstructure:"severity"`
	ID               int    `mapstructure:"id"`
	Fid              string `mapstructure:"fid"`
	ActivitySeriesID string `mapstructure:"activitySeriesId"`
	ObjectID         string `mapstructure:"objectId"`
	ObjectName       string `mapstructure:"objectName"`
	ObjectType       string `mapstructure:"objectType"`
	Cluster          struct {
		ID   string `mapstructure:"id"`
		Name string `mapstructure:"name"`
	} `mapstructure:"cluster"`
}

type PolarisEvents

type PolarisEvents struct {
	Data struct {
		ActivitySeriesConnection struct {
			Edges []struct {
				Node struct {
					ID                 int    `mapstructure:"id"`
					Fid                string `mapstructure:"fid"`
					ActivitySeriesID   string `mapstructure:"activitySeriesId"`
					LastUpdated        string `mapstructure:"lastUpdated"`
					LastActivityType   string `mapstructure:"lastActivityType"`
					LastActivityStatus string `mapstructure:"lastActivityStatus"`
					ObjectID           string `mapstructure:"objectId"`
					ObjectName         string `mapstructure:"objectName"`
					ObjectType         string `mapstructure:"objectType"`
					Severity           string `mapstructure:"severity"`
					Progress           string `mapstructure:"progress"`
					Cluster            struct {
						ID   string `mapstructure:"id"`
						Name string `mapstructure:"name"`
					} `mapstructure:"cluster"`
					ActivityConnection struct {
						Nodes []struct {
							ID      string `mapstructure:"id"`
							Message string `mapstructure:"message"`
							Time    string `mapstructure:"time"`
						} `mapstructure:"nodes"`
					} `mapstructure:"activityConnection"`
				} `mapstructure:"node"`
			} `mapstructure:"edges"`
			PageInfo struct {
				EndCursor       string `mapstructure:"endCursor"`
				HasNextPage     bool   `mapstructure:"hasNextPage"`
				HasPreviousPage bool   `mapstructure:"hasPreviousPage"`
			} `mapstructure:"pageInfo"`
		} `mapstructure:"activitySeriesConnection"`
	} `mapstructure:"data"`
}

type PolarisEventsEdge

type PolarisEventsEdge struct {
	Node struct {
		ID                 int    `mapstructure:"id"`
		Fid                string `mapstructure:"fid"`
		ActivitySeriesID   string `mapstructure:"activitySeriesId"`
		LastUpdated        string `mapstructure:"lastUpdated"`
		LastActivityType   string `mapstructure:"lastActivityType"`
		LastActivityStatus string `mapstructure:"lastActivityStatus"`
		ObjectID           string `mapstructure:"objectId"`
		ObjectName         string `mapstructure:"objectName"`
		ObjectType         string `mapstructure:"objectType"`
		Severity           string `mapstructure:"severity"`
		Progress           string `mapstructure:"progress"`
		Cluster            struct {
			ID   string `mapstructure:"id"`
			Name string `mapstructure:"name"`
		} `mapstructure:"cluster"`
		ActivityConnection struct {
			Nodes []struct {
				ID      string `mapstructure:"id"`
				Message string `mapstructure:"message"`
				Time    string `mapstructure:"time"`
			} `mapstructure:"nodes"`
		} `mapstructure:"activityConnection"`
	} `mapstructure:"node"`
}

type RadarEnabledClusters

type RadarEnabledClusters struct {
	Data struct {
		RadarClusterConnection struct {
			Nodes []struct {
				ID           string      `mapstructure:"id"`
				LambdaConfig interface{} `mapstructure:"lambdaConfig"`
				Name         string      `mapstructure:"name"`
			} `mapstructure:"nodes"`
		} `mapstructure:"radarClusterConnection"`
	} `mapstructure:"data"`
}

type RadarEvent

type RadarEvent struct {
	Data struct {
		ActivitySeriesConnection struct {
			Edges []struct {
				Node struct {
					ID                 int    `mapstructure:"id"`
					Fid                string `mapstructure:"fid"`
					ActivitySeriesID   string `mapstructure:"activitySeriesId"`
					LastUpdated        string `mapstructure:"lastUpdated"`
					LastActivityType   string `mapstructure:"lastActivityType"`
					LastActivityStatus string `mapstructure:"lastActivityStatus"`
					ObjectID           string `mapstructure:"objectId"`
					ObjectName         string `mapstructure:"objectName"`
					ObjectType         string `mapstructure:"objectType"`
					Severity           string `mapstructure:"severity"`
					Progress           string `mapstructure:"progress"`
					Cluster            struct {
						ID   string `mapstructure:"id"`
						Name string `mapstructure:"name"`
					} `mapstructure:"cluster"`
					ActivityConnection struct {
						Nodes []struct {
							ID      string `mapstructure:"id"`
							Message string `mapstructure:"message"`
							Time    string `mapstructure:"time"`
						} `mapstructure:"nodes"`
					} `mapstructure:"activityConnection"`
				} `mapstructure:"node"`
			} `mapstructure:"edges"`
		} `mapstructure:"activitySeriesConnection"`
	} `mapstructure:"data"`
}

Jump to

Keyboard shortcuts

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