common

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsInt64

func AsInt64(value interface{}) int64

func CompareMap

func CompareMap(desired map[string]interface{}, actual map[string]interface{}) (bool, error)

func CompareMapKeys

func CompareMapKeys[T1, T2 comparable](desired map[string]T1, actual map[string]T2) bool

func CompareOptional

func CompareOptional[K comparable](desired *K, actual K, defaultValue K) bool

func CompareSlice added in v0.0.4

func CompareSlice(desired []interface{}, actual []interface{}) (bool, error)

func DefaultBool

func DefaultBool(b *bool, def bool) bool

nolint: unparam

func DefaultString

func DefaultString(s *string, def string) string

func JsonDataWithHeaders

func JsonDataWithHeaders(inputJSONData map[string]interface{}, inputSecureJSONData map[string]string, headers map[string]string) (map[string]interface{}, map[string]string)

func SecretToStringMap

func SecretToStringMap(secret *kubeV1.Secret) map[string]string

Types

type ApiError

type ApiError interface {
	error
	IsCode(code int) bool
}

type ApiResponse

type ApiResponse[R interface{}] interface {
	IsCode(code int) bool
	GetPayload() *R
}

type GrafanaAPI

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

func NewGrafanaAPI

func NewGrafanaAPI(service grafana.GrafanaHTTPAPI) GrafanaAPI

func (*GrafanaAPI) AddOrgUser

func (g *GrafanaAPI) AddOrgUser(orgID int64, user *models.AddOrgUserCommand) (*models.SuccessResponseBody, error)

func (*GrafanaAPI) AdminCreateUser

func (*GrafanaAPI) CreateDataSource

func (g *GrafanaAPI) CreateDataSource(orgId int64, command *models.AddDataSourceCommand) (*models.AddDataSourceOKBody, error)

func (*GrafanaAPI) CreateFolder

func (g *GrafanaAPI) CreateFolder(orgId int64, command *models.CreateFolderCommand) (*models.Folder, error)

func (*GrafanaAPI) CreateOrUpdateDashboard

func (g *GrafanaAPI) CreateOrUpdateDashboard(orgId int64, command *models.SaveDashboardCommand) (*models.PostDashboardOKBody, error)

func (*GrafanaAPI) CreateOrg

func (g *GrafanaAPI) CreateOrg(name string) (*models.CreateOrgOKBody, error)

func (*GrafanaAPI) CreateUser

func (g *GrafanaAPI) CreateUser(user string) (int64, error)

func (*GrafanaAPI) DeleteDashboard

func (g *GrafanaAPI) DeleteDashboard(orgId int64, uid string) (*models.DeleteDashboardByUIDOKBody, error)

func (*GrafanaAPI) DeleteDataSource

func (g *GrafanaAPI) DeleteDataSource(orgId int64, id string) (*models.SuccessResponseBody, error)

func (*GrafanaAPI) DeleteFolder

func (g *GrafanaAPI) DeleteFolder(orgId int64, uid string) (*models.DeleteFolderOKBody, error)

func (*GrafanaAPI) DeleteOrgByID

func (g *GrafanaAPI) DeleteOrgByID(orgID int64) (*models.SuccessResponseBody, error)

func (*GrafanaAPI) GetAllOrgs

func (g *GrafanaAPI) GetAllOrgs() ([]*models.OrgDTO, error)

func (*GrafanaAPI) GetAllUsers

func (g *GrafanaAPI) GetAllUsers() ([]*models.UserSearchHitDTO, error)

func (*GrafanaAPI) GetDashboardByName

func (g *GrafanaAPI) GetDashboardByName(orgId int64, name string, folder *string) (*models.DashboardFullWithMeta, error)

func (*GrafanaAPI) GetDashboardByUid

func (g *GrafanaAPI) GetDashboardByUid(orgId int64, uid string) (*models.DashboardFullWithMeta, error)

func (*GrafanaAPI) GetDataSourceById

func (g *GrafanaAPI) GetDataSourceById(orgId int64, id string) (*models.DataSource, error)

func (*GrafanaAPI) GetDataSourceByName

func (g *GrafanaAPI) GetDataSourceByName(orgId int64, name string) (*models.DataSource, error)

func (*GrafanaAPI) GetFolderById

func (g *GrafanaAPI) GetFolderById(orgId int64, id int64) (*models.Folder, error)

func (*GrafanaAPI) GetFolderByName

func (g *GrafanaAPI) GetFolderByName(orgId int64, name string, parentFolder *string) (*models.Folder, error)

func (*GrafanaAPI) GetFolderByUid

func (g *GrafanaAPI) GetFolderByUid(orgId int64, uid string) (*models.Folder, error)

func (*GrafanaAPI) GetOrgById

func (g *GrafanaAPI) GetOrgById(id int64) (*models.OrgDetailsDTO, error)

func (*GrafanaAPI) GetOrgByName

func (g *GrafanaAPI) GetOrgByName(s string) (*models.OrgDetailsDTO, error)

func (*GrafanaAPI) GetOrgUsers

func (g *GrafanaAPI) GetOrgUsers(orgId int64) ([]*models.OrgUserDTO, error)

func (*GrafanaAPI) GetSignedInUser

func (g *GrafanaAPI) GetSignedInUser() (*models.UserProfileDTO, error)

func (*GrafanaAPI) RemoveOrgUser

func (g *GrafanaAPI) RemoveOrgUser(userID int64, orgID int64) (*models.SuccessResponseBody, error)

func (*GrafanaAPI) SwitchToLowestOrgId

func (g *GrafanaAPI) SwitchToLowestOrgId() error

SwitchToLowestOrgId switches the current user's active organization to the one with the lowest ID. It first retrieves all organizations and iterates through them to find the one with the lowest ID. Then, it uses the Grafana API to switch the current user's active organization to the one found. This function is useful in scenarios where the user needs to be in a context that is not the organization being managed, for example, when deleting an organization.

Returns:

error: If an error occurred during the process. It could be due to issues in retrieving all organizations or switching the active organization.

func (*GrafanaAPI) UpdateDataSource

func (g *GrafanaAPI) UpdateDataSource(orgId int64, id string, command *models.UpdateDataSourceCommand) (*models.UpdateDataSourceByIDOKBody, error)

func (*GrafanaAPI) UpdateFolder

func (g *GrafanaAPI) UpdateFolder(orgId int64, uid string, command *models.UpdateFolderCommand) (*models.Folder, error)

func (*GrafanaAPI) UpdateOrgUser

func (g *GrafanaAPI) UpdateOrgUser(orgID int64, userID int64, user *models.UpdateOrgUserCommand) (*models.SuccessResponseBody, error)

func (*GrafanaAPI) UserSetUsingOrg

func (g *GrafanaAPI) UserSetUsingOrg(orgId int64) (*models.SuccessResponseBody, error)

Jump to

Keyboard shortcuts

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