From f678bf80d9f43731aab81b709440f5b4ec07bdb9 Mon Sep 17 00:00:00 2001 From: Martin Divis Date: Wed, 4 Sep 2024 09:58:27 +0200 Subject: [PATCH] added app and hr api calls --- application.go | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++ healthRule.go | 55 ++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) diff --git a/application.go b/application.go index 5eb7bbd..7be55f4 100644 --- a/application.go +++ b/application.go @@ -2,6 +2,7 @@ MIT License Copyright (c) 2023 David Lopes +Copyright (c) 2024 Cisco Systems, Inc. and its affiliates Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -69,6 +70,65 @@ type Application struct { } `json:"applicationTypeInfo"` } +// DANGER ZONE +// following types are used for UNPUBLISHED api call and it may change in the future +type AllInternalApplications struct { + ApmApplications []GenericApplication `json:"apmApplications"` + EumWebApplications []GenericApplication `json:"eumWebApplications"` + DbMonApplication GenericApplication `json:"dbMonApplication"` + OverageMonitoringApplication GenericApplication `json:"overageMonitoringApplication"` + SimApplication GenericApplication `json:"simApplication"` + AnalyticsApplication GenericApplication `json:"analyticsApplication"` + MobileAppContainers []GenericApplication `json:"mobileAppContainers"` + IotApplications []GenericApplication `json:"iotApplications"` + CloudMonitoringApplication GenericApplication `json:"cloudMonitoringApplication"` + APIMonitoringApplications []GenericApplication `json:"apiMonitoringApplications"` + CoreWebVitalsApplication GenericApplication `json:"coreWebVitalsApplication"` +} +type GenericApplication struct { + ID int `json:"id"` + Version int `json:"version"` + Name string `json:"name"` + NameUnique bool `json:"nameUnique"` + BuiltIn bool `json:"builtIn"` + CreatedBy string `json:"createdBy"` + CreatedOn int64 `json:"createdOn"` + ModifiedBy string `json:"modifiedBy"` + ModifiedOn int64 `json:"modifiedOn"` + Description string `json:"description"` + Template bool `json:"template"` + Active bool `json:"active"` + Running bool `json:"running"` + RunningSince any `json:"runningSince"` + DeployWorkflowID int `json:"deployWorkflowId"` + UndeployWorkflowID int `json:"undeployWorkflowId"` + Visualization any `json:"visualization"` + EnvironmentProperties []EnvironmentProperties `json:"environmentProperties"` + EumAppName string `json:"eumAppName"` + AccountGUID string `json:"accountGuid"` + ApplicationTypeInfo ApplicationTypeInfo `json:"applicationTypeInfo"` +} +type ApplicationTypeInfo struct { + ApplicationTypes []string `json:"applicationTypes"` + EumEnabled bool `json:"eumEnabled"` + EumWebEnabled bool `json:"eumWebEnabled"` + EumMobileEnabled bool `json:"eumMobileEnabled"` + EumIotEnabled bool `json:"eumIotEnabled"` + EumAPIMonitoringEnabled bool `json:"eumApiMonitoringEnabled"` + HasEumWebEntities bool `json:"hasEumWebEntities"` + HasMobileApps bool `json:"hasMobileApps"` + HasTiers bool `json:"hasTiers"` + NumberOfMobileApps int `json:"numberOfMobileApps"` +} +type EnvironmentProperties struct { + ID int `json:"id"` + Version int `json:"version"` + Name string `json:"name"` + Value string `json:"value"` +} + +// DANGER ZONE END + // ApplicationService intermediates Application requests type ApplicationService service @@ -126,3 +186,20 @@ func (s *ApplicationService) ExportApplicationConfig(appID int) ([]byte, error) } return body, nil } + +// DANGER ZONE +// this is an UNPUBLISHED API call - it may change in the future +func (s *ApplicationService) GetAllInternalApplications() (*AllInternalApplications, error) { + + url := "/controller/restui/applicationManagerUiBean/getApplicationsAllTypes" + + apps := AllInternalApplications{} + err := s.client.Rest("GET", url, &apps, nil) + if err != nil { + return nil, err + } + + return &apps, nil +} + +// DANGER ZONE END diff --git a/healthRule.go b/healthRule.go index 685ca2f..45104fd 100644 --- a/healthRule.go +++ b/healthRule.go @@ -96,6 +96,43 @@ type HealthRuleDetail struct { EvalCriterias *EvalCriteriasSet `json:"evalCriterias"` } +// DANGER ZONE +// this is an UNPUBLISHED API call - it may change in the future +type HealthRuleEvaluationResponse []struct { + AffectedEntity HealthRuleAffectedEntity `json:"affectedEntity"` + Health string `json:"health"` + EvaluationStatus string `json:"evaluationStatus"` + AggregationScopesStates []HealthRuleAggregationScopesStates `json:"aggregationScopesStates"` + Name string `json:"name"` + TierName any `json:"tierName"` +} +type HealthRuleAffectedEntity struct { + ID int `json:"id"` + Version int `json:"version"` + EntityType string `json:"entityType"` + EntityID int `json:"entityId"` + PrettyToString any `json:"prettyToString"` +} +type HealthRuleAggregationScope struct { + ID int `json:"id"` + Version int `json:"version"` + EntityType string `json:"entityType"` + EntityID int `json:"entityId"` + PrettyToString any `json:"prettyToString"` +} +type HealthRuleState struct { + Result string `json:"result"` + Severity string `json:"severity"` + TriggeredConditions []any `json:"triggeredConditions"` +} +type HealthRuleAggregationScopesStates struct { + AggregationScope HealthRuleAggregationScope `json:"aggregationScope"` + JmxAggregationScope any `json:"jmxAggregationScope"` + State HealthRuleState `json:"state"` +} + +// DANGER ZONE END + // HealthRuleService intermediates Health Rules requests type HealthRuleService service @@ -201,3 +238,21 @@ func (s *HealthRuleService) DeleteHealthRule(appID int, ruleID int) error { return nil } + +// DANGER ZONE +// this is an UNPUBLISHED API call - it may change in the future +// GET /controller/restui/healthRules/getHealthRuleCurrentEvaluationStatus/app/3503/healthRuleID/22196 +func (s *HealthRuleService) GetHealthRuleEvaluationState(appID int, ruleID int) (*HealthRuleEvaluationResponse, error) { + + url := "controller/restui/healthRules/getHealthRuleCurrentEvaluationStatus/app/" + strconv.Itoa(appID) + "/healthRuleID/" + strconv.Itoa(ruleID) + + hr := HealthRuleEvaluationResponse{} + err := s.client.Rest("GET", url, &hr, nil) + if err != nil { + return nil, err + } + + return &hr, nil +} + +// DANGER ZONE END