Documentation ¶
Index ¶
- Constants
- func ValidateHexObjectID(internalID string) error
- type APITokenStorage
- type Array
- func (s *Array) ApplyPatch(m map[string]interface{}) error
- func (s *Array) ApplyTagPatch(tags []map[string]string) error
- func (s *Array) ConvertToArrayMap() map[string]interface{}
- func (s *Array) ConvertToStatusMap() map[string]interface{}
- func (s *Array) ConvertToTagsMap() map[string]interface{}
- func (s *Array) DeleteTags(tags []string)
- func (s *Array) HasRequiredPostFields() error
- func (s *Array) MarshalJSON() ([]byte, error)
- func (s *Array) UnmarshalJSON(data []byte) error
- type ArrayCollector
- type ArrayDatabase
- type ArrayDiscovery
- type ArrayMetadata
- type ArrayPatchInfo
- type ArrayQuery
- type ArrayRegistrationInfo
- type CollectorFactory
Constants ¶
const ( // DateTimeFormat holds the format string for the date time // going in and out of Elasticsearch DateTimeFormat = "2006-01-02T15:04:05.000" )
Variables ¶
This section is empty.
Functions ¶
func ValidateHexObjectID ¶
ValidateHexObjectID checks if an internalID is a valid BSON id
Types ¶
type APITokenStorage ¶
type APITokenStorage interface { // SaveToken associates the given API token with the given array ID, and returns // if there's an error in the saving process. SaveToken(arrayID string, token string) error // HasToken checks if there's an API token associated with the given array ID. // An error is not thrown if the array ID doesn't exist, but an error is thrown // if there is an issue in the checking process itself. HasToken(arrayID string) (bool, error) // GetToken fetches the API token associated with the given array ID. An // error is thrown if the key doesn't exist or there's an issue in the fetching // process. GetToken(arrayID string) (string, error) // DeleteToken deletes the token with the given array ID from this storage. // Note that a nonexistent ID should *not* be considered an error, and the // error return value is reserved for an issue with the actual deletion process // itself. DeleteToken(arrayID string) error }
APITokenStorage defines a type that can be used to save array API tokens with their ID. This should ideally be separate from the main API server database, as the whole intent is for API tokens to be protected.
type Array ¶
type Array struct { InternalID string `json:"InternalID,omitempty"` Name string `json:"Name,omitempty"` MgmtEndPoint string `json:"MgmtEndpoint,omitempty"` APIToken string `json:"APIToken,omitempty"` Status string `json:"Status,omitempty"` Lastseen time.Time `json:"AsOf,omitempty"` Lastupdated time.Time `json:"LastUpdated,omitempty"` DeviceType string `json:"DeviceType,omitempty"` Version string `json:"Version,omitempty"` Model string `json:"Model,omitempty"` Tags []map[string]string `json:"Tags,omitempty"` }
Array provides a struct for unified FlashArray/FlashBlade metadata
func ParseArrayFromREST ¶
ParseArrayFromREST parses a map in the format of the REST API call (lower_case) and converts to an Array struct. The reason we can't use raw JSON marshal/unmarshal is because we can only convert to/from one JSON format that way, and since the output needs more variability we'll reserve JSON marshal for the more standard case of Elastic input/output.
func (*Array) ApplyPatch ¶
ApplyPatch applies the given patches to this array, with the given map in the format accepted by the REST API ("mgmt_endpoint", "device_type", etc.)
func (*Array) ApplyTagPatch ¶
ApplyTagPatch patches the tags of this array
func (*Array) ConvertToArrayMap ¶
ConvertToArrayMap converts this array into a string->interface map suitable for marshalling, with only the array properties (sans-tags)
func (*Array) ConvertToStatusMap ¶
ConvertToStatusMap converts this array into a string->interface map suitable for marshalling, with only the array ID and status
func (*Array) ConvertToTagsMap ¶
ConvertToTagsMap converts this array into a string->interface map suitable for marshalling, with only the array ID and tags
func (*Array) DeleteTags ¶
DeleteTags deletes the given tags from this device
func (*Array) HasRequiredPostFields ¶
HasRequiredPostFields checks to ensure that a storage array has all required fields filled in
func (*Array) MarshalJSON ¶
MarshalJSON provides a custom marshal override which formats dates in the format Elastic expects
func (*Array) UnmarshalJSON ¶
UnmarshalJSON provides a custom unmarshal override which parses dates in the format provided by Elastic
type ArrayCollector ¶
type ArrayCollector interface { GetAllArrayData() (*metrics.AllArrayData, error) GetAllVolumeData(timeWindow int64) (*metrics.AllVolumeData, error) GetArrayID() string GetArrayModel() (string, error) GetArrayName() (string, error) GetArrayTags() (map[string]string, error) GetArrayType() string GetArrayVersion() (string, error) GetDisplayName() string }
ArrayCollector is an interface for a FlashArray or FlashBlade collector that uses an underlying client to make requests and package the responses into the desired resources
type ArrayDatabase ¶
type ArrayDatabase interface { FindArrays(query *ArrayQuery) ([]*Array, error) PatchArray(array *Array) (*Array, error) PatchArrayTags(array *Array) (*Array, error) InsertArray(array *Array) error DeleteArray(query *ArrayQuery) ([]string, error) // Returns list of IDs deleted }
ArrayDatabase provides an interface to Elastic (or mocked data, or something else) to store and access array metadata
type ArrayDiscovery ¶
type ArrayDiscovery interface {
GetArrays() ([]*ArrayRegistrationInfo, error)
}
ArrayDiscovery represents a connection to fetch a list of arrays from an external source, whether it's a json file, a database, or a server. It fetches the struct of raw information which is then used to construct a Collector of whatever desired backend connection type (see CollectorFactory.InitializeCollector).
type ArrayMetadata ¶
type ArrayMetadata interface { Patch(arrayID string, body *ArrayPatchInfo) error GetTags(arrayID string) (map[string]string, error) }
ArrayMetadata represents a connection to modify a array or get more information about it from an external source, whether it's a json file, a database, or a server.
type ArrayPatchInfo ¶
type ArrayPatchInfo struct { Status string `json:"status,omitempty"` Model string `json:"model,omitempty"` Version string `json:"version,omitempty"` AsOf string `json:"_as_of,omitempty"` }
ArrayPatchInfo provides the data that is commonly patched on the API server
type ArrayQuery ¶
type ArrayQuery struct { Ids []string Names []string Versions []string Models []string Sort string SortDescending bool // false: ascending, true: descending Offset int Limit int }
ArrayQuery provides a struct holding possible query parameters for a request
func GenerateEmptyQuery ¶
func GenerateEmptyQuery() ArrayQuery
GenerateEmptyQuery generates an empty query, like if it was returned from parseRequestQueryParams with no query parameters.
func (*ArrayQuery) GenerateElasticQueryObject ¶
func (q *ArrayQuery) GenerateElasticQueryObject() elastic.Query
GenerateElasticQueryObject converts this query into an elastic.Query object suitable for API calls
func (*ArrayQuery) GetSortParameter ¶
func (q *ArrayQuery) GetSortParameter() (string, error)
GetSortParameter converts the parameter in the query to an Elastic sort query
func (*ArrayQuery) IsEmpty ¶
func (q *ArrayQuery) IsEmpty() bool
IsEmpty returns whether this query has any filter parameters set or not (it doesn't care about sorting or pagination)
type ArrayRegistrationInfo ¶
type ArrayRegistrationInfo struct { ID string `json:"id"` Name string `json:"name"` MgmtEndpoint string `json:"mgmt_endpoint"` APIToken string `json:"api_token"` DeviceType string `json:"device_type"` }
ArrayRegistrationInfo provides all the info needed to open a connection with an array.
func (*ArrayRegistrationInfo) GetLogFields ¶
func (a *ArrayRegistrationInfo) GetLogFields(includeEndpoint bool) log.Fields
GetLogFields is an ease-of-use method to get the easy describing fields of a device's registration info
func (*ArrayRegistrationInfo) IsEqual ¶
func (a *ArrayRegistrationInfo) IsEqual(other *ArrayRegistrationInfo) bool
IsEqual compares this struct to the given one
type CollectorFactory ¶
type CollectorFactory interface {
InitializeCollector(*ArrayRegistrationInfo) (ArrayCollector, error)
}
CollectorFactory represents a factory that converts from an array metadata struct into a backend connection. Mainly a way to allow passing mocks for testing easier.