# README
Go API client for alerting
OpenAPI schema for alerting endpoints
Overview
This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.
- API version: 0.2
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.GoClientCodegen
Installation
Install the following dependencies:
go get github.com/stretchr/testify/assert
go get golang.org/x/net/context
Put the package under your project folder and add the following in import:
import alerting "github.com/elastic/terraform-provider-elasticstack/alerting"
To use a proxy, set the environment variable HTTP_PROXY
:
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
Configuration of Server URL
Default configuration comes with Servers
field that contains server objects as defined in the OpenAPI specification.
Select Server Configuration
For using other server than the one defined on index 0 set context value sw.ContextServerIndex
of type int
.
ctx := context.WithValue(context.Background(), alerting.ContextServerIndex, 1)
Templated Server URL
Templated server URL is formatted using default variables from configuration or from context value sw.ContextServerVariables
of type map[string]string
.
ctx := context.WithValue(context.Background(), alerting.ContextServerVariables, map[string]string{
"basePath": "v2",
})
Note, enum values are always validated and all unused variables are silently ignored.
URLs Configuration per Operation
Each operation can use different server URL defined using OperationServers
map in the Configuration
.
An operation is uniquely identified by "{classname}Service.{nickname}"
string.
Similar rules for overriding default operation server index and variables applies by using sw.ContextOperationServerIndices
and sw.ContextOperationServerVariables
context maps.
ctx := context.WithValue(context.Background(), alerting.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), alerting.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
Documentation for API Endpoints
All URIs are relative to http://localhost
Class | Method | HTTP request | Description |
---|---|---|---|
AlertingAPI | CreateRule | Post /s/{spaceId}/api/alerting/rule | Creates a rule with a randomly generated rule identifier. |
AlertingAPI | CreateRuleId | Post /s/{spaceId}/api/alerting/rule/{ruleId} | Creates a rule with a specific rule identifier. |
AlertingAPI | DeleteRule | Delete /s/{spaceId}/api/alerting/rule/{ruleId} | Deletes a rule. |
AlertingAPI | DisableRule | Post /s/{spaceId}/api/alerting/rule/{ruleId}/_disable | Disables a rule. |
AlertingAPI | EnableRule | Post /s/{spaceId}/api/alerting/rule/{ruleId}/_enable | Enables a rule. |
AlertingAPI | FindRules | Get /s/{spaceId}/api/alerting/rules/_find | Retrieves information about rules. |
AlertingAPI | GetAlertingHealth | Get /s/{spaceId}/api/alerting/_health | Retrieves the health status of the alerting framework. |
AlertingAPI | GetRule | Get /s/{spaceId}/api/alerting/rule/{ruleId} | Retrieves a rule by its identifier. |
AlertingAPI | GetRuleTypes | Get /s/{spaceId}/api/alerting/rule_types | Retrieves a list of rule types. |
AlertingAPI | LegacyCreateAlert | Post /s/{spaceId}/api/alerts/alert/{alertId} | Create an alert. |
AlertingAPI | LegacyDisableAlert | Post /s/{spaceId}/api/alerts/alert/{alertId}/_disable | Disables an alert. |
AlertingAPI | LegacyEnableAlert | Post /s/{spaceId}/api/alerts/alert/{alertId}/_enable | Enables an alert. |
AlertingAPI | LegacyFindAlerts | Get /s/{spaceId}/api/alerts/alerts/_find | Retrieves a paginated set of alerts. |
AlertingAPI | LegacyGetAlert | Get /s/{spaceId}/api/alerts/alert/{alertId} | Retrieves an alert by its identifier. |
AlertingAPI | LegacyGetAlertTypes | Get /s/{spaceId}/api/alerts/alerts/list_alert_types | Retrieves a list of alert types. |
AlertingAPI | LegacyGetAlertingHealth | Get /s/{spaceId}/api/alerts/alerts/_health | Retrieves the health status of the alerting framework. |
AlertingAPI | LegacyMuteAlertInstance | Post /s/{spaceId}/api/alerts/alert/{alertId}/alert_instance/{alertInstanceId}/_mute | Mutes an alert instance. |
AlertingAPI | LegacyMuteAllAlertInstances | Post /s/{spaceId}/api/alerts/alert/{alertId}/_mute_all | Mutes all alert instances. |
AlertingAPI | LegacyUnmuteAlertInstance | Post /s/{spaceId}/api/alerts/alert/{alertId}/alert_instance/{alertInstanceId}/_unmute | Unmutes an alert instance. |
AlertingAPI | LegacyUnmuteAllAlertInstances | Post /s/{spaceId}/api/alerts/alert/{alertId}/_unmute_all | Unmutes all alert instances. |
AlertingAPI | LegacyUpdateAlert | Put /s/{spaceId}/api/alerts/alert/{alertId} | Updates the attributes for an alert. |
AlertingAPI | LegaryDeleteAlert | Delete /s/{spaceId}/api/alerts/alert/{alertId} | Permanently removes an alert. |
AlertingAPI | MuteAlert | Post /s/{spaceId}/api/alerting/rule/{ruleId}/alert/{alertId}/_mute | Mutes an alert. |
AlertingAPI | MuteAllAlerts | Post /s/{spaceId}/api/alerting/rule/{ruleId}/_mute_all | Mutes all alerts. |
AlertingAPI | UnmuteAlert | Post /s/{spaceId}/api/alerting/rule/{ruleId}/alert/{alertId}/_unmute | Unmutes an alert. |
AlertingAPI | UnmuteAllAlerts | Post /s/{spaceId}/api/alerting/rule/{ruleId}/_unmute_all | Unmutes all alerts. |
AlertingAPI | UpdateRule | Put /s/{spaceId}/api/alerting/rule/{ruleId} | Updates the attributes for a rule. |
AlertingAPI | UpdateRuleAPIKey | Post /s/{spaceId}/api/alerting/rule/{ruleId}/_update_api_key | Updates the API key for a rule. |
Documentation For Models
- ActionsInner
- ActionsInnerAlertsFilter
- ActionsInnerAlertsFilterQuery
- ActionsInnerAlertsFilterTimeframe
- ActionsInnerAlertsFilterTimeframeHours
- ActionsInnerFrequency
- AlertDelay
- AlertResponseProperties
- AlertResponsePropertiesExecutionStatus
- AlertResponsePropertiesSchedule
- CreateRuleRequest
- FieldmapProperties
- FieldmapPropertiesPropertiesValue
- Filter
- FilterMeta
- FindRules200Response
- FindRulesHasReferenceParameter
- GetAlertingHealth200Response
- GetAlertingHealth200ResponseAlertingFrameworkHealth
- GetAlertingHealth200ResponseAlertingFrameworkHealthDecryptionHealth
- GetAlertingHealth200ResponseAlertingFrameworkHealthExecutionHealth
- GetAlertingHealth200ResponseAlertingFrameworkHealthReadHealth
- GetRuleTypes200ResponseInner
- GetRuleTypes200ResponseInnerActionGroupsInner
- GetRuleTypes200ResponseInnerActionVariables
- GetRuleTypes200ResponseInnerActionVariablesContextInner
- GetRuleTypes200ResponseInnerActionVariablesParamsInner
- GetRuleTypes200ResponseInnerActionVariablesStateInner
- GetRuleTypes200ResponseInnerAlerts
- GetRuleTypes200ResponseInnerAlertsMappings
- GetRuleTypes200ResponseInnerAuthorizedConsumers
- GetRuleTypes200ResponseInnerAuthorizedConsumersAlerts
- GetRuleTypes200ResponseInnerRecoveryActionGroup
- LegacyCreateAlertRequestProperties
- LegacyFindAlerts200Response
- LegacyFindAlertsHasReferenceParameter
- LegacyGetAlertTypes200ResponseInner
- LegacyGetAlertTypes200ResponseInnerActionGroupsInner
- LegacyGetAlertTypes200ResponseInnerActionVariables
- LegacyGetAlertTypes200ResponseInnerRecoveryActionGroup
- LegacyGetAlertingHealth200Response
- LegacyGetAlertingHealth200ResponseAlertingFrameworkHealth
- LegacyGetAlertingHealth200ResponseAlertingFrameworkHealthDecryptionHealth
- LegacyGetAlertingHealth200ResponseAlertingFrameworkHealthExecutionHealth
- LegacyGetAlertingHealth200ResponseAlertingFrameworkHealthReadHealth
- LegacyUpdateAlertRequestProperties
- LegacyUpdateAlertRequestPropertiesActionsInner
- LegacyUpdateAlertRequestPropertiesSchedule
- Model400Response
- Model401Response
- Model404Response
- NotifyWhen
- RuleResponseProperties
- RuleResponsePropertiesExecutionStatus
- RuleResponsePropertiesLastRun
- RuleResponsePropertiesLastRunAlertsCount
- Schedule
- UpdateRuleRequest
Documentation For Authorization
Authentication schemes defined for the API:
basicAuth
- Type: HTTP basic authentication
Example
auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
UserName: "username",
Password: "password",
})
r, err := client.Service.Operation(auth, args)
apiKeyAuth
- Type: API key
- API key parameter name: Authorization
- Location: HTTP header
Note, each API key must be added to a map of map[string]APIKey
where the key is: Authorization and passed in as the auth context for each request.
Example
auth := context.WithValue(
context.Background(),
sw.ContextAPIKeys,
map[string]sw.APIKey{
"Authorization": {Key: "API_KEY_STRING"},
},
)
r, err := client.Service.Operation(auth, args)
Documentation for Utility Methods
Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:
PtrBool
PtrInt
PtrInt32
PtrInt64
PtrFloat
PtrFloat32
PtrFloat64
PtrString
PtrTime