vrop

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

README

go-vrop

vRealize API Client Library

Table of Contents

Getting Started

First, install vropcli:

go get -u github.com/greenpau/go-vrop/cmd/vropcli

Next, set environment variables for vRealize API Token:

export VROP_HOST=vrop
export VROP_USERNAME=admin
export VROP_PASSWORD=My@Password

Alternatively, the settings could be passed in a configuration file. There are two options:

  1. The vropcli.yaml should be located in $HOME/.config/vropcli or current directory
  2. Pass the location via -config flag
---
host: vrop
username: admin
password: password

The following command fetches virtual machines data from vRealize API:

vropcli -get-virtual-machines

Documentation

Index

Constants

View Source
const ReceiverDataLimit int64 = 1e6

ReceiverDataLimit is the limit of data in bytes the client will read from a server.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthResponse

type AuthResponse struct {
	Token     string        `json:"token,omitempty"`
	Validity  float64       `json:"validity,omitempty"`
	ExpiresAt string        `json:"expiresAt,omitempty"`
	Roles     []interface{} `json:"roles,omitempty"`
}

AuthResponse is the response from auth token acquisition endpoint.

type Badge

type Badge struct {
	// Type of the Badge
	Type string `json:"type,omitempty"`
	// Color of the Badge as determined by the system
	Color string `json:"color,omitempty"`
	// Score (value) associated with the Badge. This number represents the
	// absolute value of the Badge. Typically the value is between 0-100
	// but this is not the case all the time.
	Score float64 `json:"score,omitempty"`
}

Badge is a major or minor badge.

type Client

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

Client is an instance of Proofpoint API client.

func NewClient

func NewClient(opts map[string]interface{}) (*Client, error)

NewClient returns an instance of Client.

func (*Client) Close

func (c *Client) Close()

Close performs a cleanup associated with Client..

func (*Client) GetVirtualMachines

func (c *Client) GetVirtualMachines(opts map[string]interface{}) ([]*VirtualMachine, error)

GetVirtualMachines returns a list of VirtualMachine instances.

func (*Client) Info

func (c *Client) Info()

Info sends information about Client to the configured logger.

func (*Client) SetHost

func (c *Client) SetHost(s string) error

SetHost sets the target host for the API calls.

func (*Client) SetPassword

func (c *Client) SetPassword(s string) error

SetPassword sets API password.

func (*Client) SetPort

func (c *Client) SetPort(p int) error

SetPort sets the port number for the API calls.

func (*Client) SetProtocol

func (c *Client) SetProtocol(s string) error

SetProtocol sets the protocol for the API calls.

func (*Client) SetUsername

func (c *Client) SetUsername(s string) error

SetUsername sets API username

func (*Client) SetValidateServerCertificate

func (c *Client) SetValidateServerCertificate() error

SetValidateServerCertificate instructs the client to enforce the validation of certificates and check certificate errors.

type GeoLocation

type GeoLocation struct {
	// Latitude of the location.
	Latitude float64 `json:"latitude,omitempty"`
	// Longitude of the location.
	Longitude float64 `json:"longitude,omitempty"`
}

GeoLocation is geographical location.

type Link struct {
	// 	The url part of this tag. Note that the href can be absolute or relative to the current url.
	// If the href begins with '/', then its absolute.
	// If the href begins with the protocol element(http, https), its absolute
	// Otherwise its relative.
	Href string `json:"href,omitempty"`
	Name string `json:"name,omitempty"`
	// NEXT: Used to represent the next page accessible using this url
	// PREVIOUS: Used to represent the previous page accessible using this url
	// START: Used to represent the first page accessible using this url
	// END: Used to represent the last page accessible using this url
	// RELATED: Used to represent that this link points to an object related to the link's parent
	// SELF: Used to represent that this link points to more information of the link's parent tag/object
	Relation string `json:"rel,omitempty"`
}

Link is a reference to an object.

type PageInfo

type PageInfo struct {
	// Total number of results.
	Total int `json:"totalCount,omitempty"`
	// The current page number.
	ID int `json:"page,omitempty"`
	// Number of entries allowed in a page.
	Size int `json:"pageSize,omitempty"`
	// A CSV list of field names. Usually found in an enumeration, for example
	SortBy string `json:"sortBy,omitempty"`
	// A CSV list of values. If not specified or if list shorter than sortFields then SortOrder.ASCENDING is assumed.
	SortOrder string `json:"sortOrder,omitempty"`
}

PageInfo is paging reference.

type Resource

type Resource struct {
	// Identifier of the Resource (typically a UUID).
	ID string `json:"identifier,omitempty"`
	// Description of the Resource
	Description string `json:"description,omitempty"`
	// Time the Resource was created in the system.
	CreationTime time.Time `json:"creationTime,omitempty"`
	// Resource key of the Resource.
	Key *ResourceKey `json:"resourceKey,omitempty"`
	// Credential instance identifier assigned to this Resource
	CredentialInstanceID string `json:"credentialInstanceId,omitempty"`
	// Geographical location of the resource.
	GeoLocation *GeoLocation `json:"geoLocation,omitempty"`
	// The resource status and resource state for this resource
	// as reported by one or more adapter instances
	StatusStates []*ResourceStatusState `json:"resourceStatusStates,omitempty"`
	// Health of the Resource.
	Health string `json:"resourceHealth,omitempty"`
	// Resource Health Score.
	HealthValue float64 `json:"resourceHealthValue,omitempty"`
	// DT calculation enabled or not. By default DT calculation for
	// a resource is enabled (during its creation).
	DynamicThresholdEnabled bool `json:"dtEnabled,omitempty"`
	// The Monitoring Interval (in minutes) the Resource was configured with
	MonitoringInterval float64 `json:"monitoringInterval,omitempty"`
	// The various major and minor badges and their values for a Resource.
	Badges []*Badge `json:"badges,omitempty"`
	// Collection of related resource identifiers.
	RelatedResources []interface{} `json:"relatedResources,omitempty"`
	// Extension values that were added to the given object by third-party.
	Extension interface{} `json:"extension,omitempty"`
	// Set of useful links related to the current object.
	Links []*Link `json:"links,omitempty"`
}

Resource is a resource record.

type ResourceIdentifier

type ResourceIdentifier struct {
	Key   string `json:"key,omitempty"`
	Value string `json:"value,omitempty"`
}

ResourceIdentifier is a reference to an object.

type ResourceKey

type ResourceKey struct {
	// Name of the Resource
	Name string `json:"name,omitempty"`
	// Adapter Kind to which the resource belongs to
	AdapterKindKey string `json:"adapterKindKey,omitempty"`
	// Resource Kind to which the resource belongs to
	ResourceKindKey string `json:"resourceKindKey,omitempty"`
	// A collection of Resource Identifiers. A Resource Identifier is a
	// key-value pair that encapsulates the identity of the resource
	ResourceIdentifiers []*ResourceIdentifier `json:"resourceIdentifiers,omitempty"`
	// Set of useful links related to the current object.
	Links []*Link `json:"links,omitempty"`
	// Extension values that were added to the given object by third-party.
	Extension interface{} `json:"extension,omitempty"`
}

ResourceKey is a key of the Resource.

type ResourceStatusState

type ResourceStatusState struct {
	// The Adapter Instance identifier associated with the status and state
	AdapterInstanceID string `json:"adapterInstanceId,omitempty"`
	// A human readable status message
	Message string `json:"statusMessage,omitempty"`
	// The resource state.
	// STOPPED: Resource is not collecting
	// NOT_EXISTING: Non-existing resource
	// NONE: Resource not associated with an adapter instance.
	// UNKNOWN: Serves as a means to ensure older clients can talk to newer servers
	State string `json:"resourceState,omitempty"`
	// The resource data collection status
	// NONE: initial status of resource.
	// ERROR: error happened while collecting data
	// UNKNOWN: resource status is unknown.
	// DOWN: resource is down
	// DATA_RECEIVING: data receiving
	// OLD_DATA_RECEIVING: old data receiving
	// NO_DATA_RECEIVING: no data receiving
	// NO_PARENT_MONITORING: no parent adapter instance resource is monitoring
	// COLLECTOR_DOWN: collector is down
	Status string `json:"resourceStatus,omitempty"`
}

ResourceStatusState is paging reference.

type VirtualMachine

type VirtualMachine struct {
	ID                         string            `json:"id,omitempty"`
	Name                       string            `json:"name,omitempty"`
	VMEntityInstanceUUID       string            `json:"vm_entity_instance_uuid,omitempty"`
	VMEntityName               string            `json:"vm_entity_name,omitempty"`
	VMEntityObjectID           string            `json:"vm_entity_object_id,omitempty"`
	VMEntityVCID               string            `json:"vm_entity_vcid,omitempty"`
	VMServiceMonitoringEnabled bool              `json:"vm_service_monitoring_enabled,omitempty"`
	CreatedAt                  time.Time         `json:"created_at,omitempty"`
	LastSeenAt                 time.Time         `json:"last_seen_at,omitempty"`
	Properties                 map[string]string `json:"properties,omitempty"`
	Errors                     []string          `json:"errors,omitempty"`
}

VirtualMachine is a virtual machine.

func (*VirtualMachine) GetProperties

func (m *VirtualMachine) GetProperties(c *Client) error

GetProperties fetches latest properties of VirtualMachine.

func (*VirtualMachine) ToJSONString

func (m *VirtualMachine) ToJSONString() (string, error)

ToJSONString serializes VirtualMachine to a string.

type VirtualMachineResourcesResponse

type VirtualMachineResourcesResponse struct {
	Page      *PageInfo   `json:"pageInfo,omitempty"`
	Links     []*Link     `json:"links,omitempty"`
	Resources []*Resource `json:"resourceList,omitempty"`
}

VirtualMachineResourcesResponse is a response with VirtualMachine resources.

func (*VirtualMachineResourcesResponse) UnmarshalJSON

func (c *VirtualMachineResourcesResponse) UnmarshalJSON(b []byte) error

UnmarshalJSON unpacks byte array into VirtualMachineResourcesResponse.

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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