Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrorClientNotFound is returned when the client is not found in the cache ErrorClientNotFound = errors.New("client not found in client cache") // ErrorPrismAddressNotSet is returned when the address is not set for Nutanix Prism Central ErrorPrismAddressNotSet = errors.New("address not set for Nutanix Prism Central") // ErrorPrismPortNotSet is returned when the port is not set for Nutanix Prism Central ErrorPrismPortNotSet = errors.New("port not set for Nutanix Prism Central") // ErrorPrismUsernameNotSet is returned when the username is not set for Nutanix Prism Central ErrorPrismUsernameNotSet = errors.New("username not set for Nutanix Prism Central") // ErrorPrismPasswordNotSet is returned when the password is not set for Nutanix Prism Central ErrorPrismPasswordNotSet = errors.New("password not set for Nutanix Prism Central") )
Functions ¶
This section is empty.
Types ¶
type CacheOpts ¶ added in v0.5.0
type CacheOpts func(*ClientCache)
CacheOpts is a functional option for the ClientCache
func WithSessionAuth ¶ added in v0.5.0
WithSessionAuth sets the session auth for the ClientCache If sessionAuth is true, the client will use session auth instead of basic auth for authentication of requests If sessionAuth is false, the client will use basic auth for authentication of requests
type CachedClientParams ¶ added in v0.5.0
type CachedClientParams interface { // ManagementEndpoint returns the struct containing all information needed to construct a new client // and is used to calculate the validation hash for the client for the purpose of cache invalidation. // The validation hash is calculated based on the serialized version of the ManagementEndpoint. ManagementEndpoint() types.ManagementEndpoint // Key returns a unique key for the client that is used to store the client in the cache Key() string }
CachedClientParams define the interface that needs to be implemented by an object that will be used to create a cached client.
type Client ¶
type Client struct { CategoriesApiInstance *prismApi.CategoriesApi ClustersApiInstance *clusterApi.ClustersApi ImagesApiInstance *vmApi.ImagesApi StorageContainerAPI *storageApi.StorageContainerApi SubnetsApiInstance *networkingApi.SubnetsApi SubnetIPReservationApi *networkingApi.SubnetIPReservationApi TasksApiInstance *prismApi.TasksApi VolumeGroupsApiInstance *volumesApi.VolumeGroupsApi VmApiInstance *vmApi.VmApi }
Client manages the V4 API
func NewV4Client ¶
func NewV4Client(credentials prismgoclient.Credentials, opts ...ClientOption) (*Client, error)
NewV4Client return an internal to operate V4 resources
type ClientCache ¶ added in v0.5.0
type ClientCache struct {
// contains filtered or unexported fields
}
ClientCache is a cache for prism clients
func NewClientCache ¶ added in v0.5.0
func NewClientCache(opts ...CacheOpts) *ClientCache
NewClientCache returns a new ClientCache
func (*ClientCache) Delete ¶ added in v0.5.0
func (c *ClientCache) Delete(params CachedClientParams)
Delete removes the client from the cache
func (*ClientCache) GetOrCreate ¶ added in v0.5.0
func (c *ClientCache) GetOrCreate(cachedClientParams CachedClientParams, opts ...ClientOption) (*Client, error)
GetOrCreate returns the client for the given client name and endpoint. - If the client is not found in the cache, it creates a new client, adds it to the cache, and returns it - If the client is found in the cache, it validates whether the client is still valid by comparing validation hashes - If the client is found in the cache and the validation hash is the same, it returns the client - If the client is found in the cache and the validation hash is different, it regenerates the client, updates the cache, and returns the client func (c *ClientCache) GetOrCreate(clientName string, endpoint types.ManagementEndpoint, opts ...ClientOption) (*Client, error) {
type ClientOption ¶ added in v0.5.0
ClientOption is a functional option for the Client