Skip to content

Commit

Permalink
Add deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
SaaldjorMike committed Nov 15, 2024
1 parent 99b3928 commit 3021a73
Show file tree
Hide file tree
Showing 26 changed files with 325 additions and 26 deletions.
44 changes: 36 additions & 8 deletions api/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,77 +2,97 @@ package api

import (
"fmt"
graphql "github.com/cli/shurcooL-graphql"
"reflect"

graphql "github.com/cli/shurcooL-graphql"
)

const (
ActionTypeEmail string = "EmailAction"
ActionTypeHumioRepo string = "HumioRepoAction"
ActionTypeOpsGenie string = "OpsGenieAction"
ActionTypePagerDuty string = "PagerDutyAction"
ActionTypeSlack string = "SlackAction"
// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
ActionTypeEmail string = "EmailAction"
// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
ActionTypeHumioRepo string = "HumioRepoAction"
// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
ActionTypeOpsGenie string = "OpsGenieAction"
// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
ActionTypePagerDuty string = "PagerDutyAction"
// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
ActionTypeSlack string = "SlackAction"
// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
ActionTypeSlackPostMessage string = "SlackPostMessageAction"
ActionTypeVictorOps string = "VictorOpsAction"
ActionTypeWebhook string = "WebhookAction"
// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
ActionTypeVictorOps string = "VictorOpsAction"
// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
ActionTypeWebhook string = "WebhookAction"
)

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
type Actions struct {
client *Client
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
type EmailAction struct {
Recipients []string `graphql:"emailRecipients: recipients" yaml:"recipients,omitempty" json:"recipients,omitempty"`
SubjectTemplate string `graphql:"emailSubjectTemplate: subjectTemplate" yaml:"subjectTemplate,omitempty" json:"subjectTemplate,omitempty"`
BodyTemplate string `graphql:"emailBodyTemplate: bodyTemplate" yaml:"bodyTemplate,omitempty" json:"bodyTemplate,omitempty"`
UseProxy bool `graphql:"emailUseProxy: useProxy" yaml:"useProxy,omitempty" json:"useProxy,omitempty"`
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
type HumioRepoAction struct {
IngestToken string `graphql:"humioRepoIngestToken: ingestToken" yaml:"ingestToken,omitempty" json:"ingestToken,omitempty"`
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
type OpsGenieAction struct {
ApiUrl string `graphql:"opsGenieApiUrl: apiUrl" yaml:"apiUrl,omitempty" json:"apiUrl,omitempty"`
GenieKey string `graphql:"opsGenieGenieKey: genieKey" yaml:"genieKey,omitempty" json:"genieKey,omitempty"`
UseProxy bool `graphql:"opsGenieUseProxy: useProxy" yaml:"useProxy,omitempty" json:"useProxy,omitempty"`
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
type PagerDutyAction struct {
Severity string `graphql:"pagerDutySeverity: severity" yaml:"severity,omitempty" json:"severity,omitempty"`
RoutingKey string `graphql:"pagerDutyRoutingKey: routingKey" yaml:"routingKey,omitempty" json:"routingKey,omitempty"`
UseProxy bool `graphql:"pagerDutyUseProxy: useProxy" yaml:"useProxy,omitempty" json:"useProxy,omitempty"`
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
type SlackFieldEntryInput struct {
FieldName string `graphql:"fieldName" yaml:"fieldName" json:"fieldName"`
Value string `graphql:"value" yaml:"value" json:"value"`
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
type SlackAction struct {
Url string `graphql:"slackUrl: url" yaml:"url,omitempty" json:"url,omitempty"`
Fields []SlackFieldEntryInput `graphql:"slackFields: fields" yaml:"fields,omitempty" json:"fields,omitempty"`
UseProxy bool `graphql:"slackUseProxy: useProxy" yaml:"useProxy,omitempty" json:"useProxy,omitempty"`
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
type SlackPostMessageAction struct {
ApiToken string `graphql:"slackPostMessageApiToken: apiToken" yaml:"apiToken,omitempty" json:"apiToken,omitempty"`
Channels []string `graphql:"slackPostMessageChannels: channels" yaml:"channels,omitempty" json:"channels,omitempty"`
Fields []SlackFieldEntryInput `graphql:"slackPostMessageFields: fields" yaml:"fields,omitempty" json:"fields,omitempty"`
UseProxy bool `graphql:"slackPostMessageUseProxy: useProxy" yaml:"useProxy,omitempty" json:"useProxy,omitempty"`
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
type VictorOpsAction struct {
MessageType string `graphql:"victorOpsMessageType: messageType" yaml:"messageType,omitempty" json:"messageType,omitempty"`
NotifyUrl string `graphql:"victorOpsNotifyUrl: notifyUrl" yaml:"notifyUrl,omitempty" json:"notifyUrl,omitempty"`
UseProxy bool `graphql:"victorOpsUseProxy: useProxy" yaml:"useProxy,omitempty" json:"useProxy,omitempty"`
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
type HttpHeaderEntryInput struct {
Header string `graphql:"header" yaml:"header" json:"header"`
Value string `graphql:"value" yaml:"value" json:"value"`
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
type WebhookAction struct {
Method string `graphql:"webhookMethod: method" yaml:"method,omitempty" json:"method,omitempty"`
Url string `graphql:"webhookUrl: url" yaml:"url,omitempty" json:"url,omitempty"`
Expand All @@ -82,6 +102,7 @@ type WebhookAction struct {
UseProxy bool `graphql:"webhookUseProxy: useProxy" yaml:"useProxy,omitempty" json:"useProxy,omitempty"`
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
type Action struct {
Type string `graphql:"__typename" yaml:"type" json:"type"`
ID string `graphql:"id" yaml:"-" json:"id"`
Expand All @@ -97,8 +118,10 @@ type Action struct {
WebhookAction WebhookAction `graphql:"... on WebhookAction" yaml:"webhookAction,omitempty" json:"webhookAction,omitempty"`
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
func (c *Client) Actions() *Actions { return &Actions{client: c} }

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
func (n *Actions) List(viewName string) ([]Action, error) {
var query struct {
SearchDomain struct {
Expand All @@ -114,6 +137,7 @@ func (n *Actions) List(viewName string) ([]Action, error) {
return query.SearchDomain.Actions, err
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
func (n *Actions) Update(viewName string, newAction *Action) (*Action, error) {
if newAction == nil {
return nil, fmt.Errorf("action must not be nil")
Expand Down Expand Up @@ -454,6 +478,7 @@ func (n *Actions) Update(viewName string, newAction *Action) (*Action, error) {
return nil, fmt.Errorf("no action details specified or unsupported action type used")
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
func (n *Actions) Add(viewName string, newAction *Action) (*Action, error) {
if newAction == nil {
return nil, fmt.Errorf("action must not be nil")
Expand Down Expand Up @@ -781,6 +806,7 @@ func (n *Actions) Add(viewName string, newAction *Action) (*Action, error) {
return nil, fmt.Errorf("no action details specified or unsupported action type used")
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
func (n *Actions) Get(viewName, actionName string) (*Action, error) {
actions, err := n.List(viewName)
if err != nil {
Expand All @@ -795,6 +821,7 @@ func (n *Actions) Get(viewName, actionName string) (*Action, error) {
return nil, ActionNotFound(actionName)
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
func (n *Actions) GetByID(viewName, actionID string) (*Action, error) {
var query struct {
SearchDomain struct {
Expand All @@ -819,6 +846,7 @@ func (n *Actions) GetByID(viewName, actionID string) (*Action, error) {
return query.SearchDomain.Action, err
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
func (n *Actions) Delete(viewName, actionName string) error {
actions, err := n.List(viewName)
if err != nil {
Expand Down
9 changes: 9 additions & 0 deletions api/aggregate-alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package api

import (
"fmt"

graphql "github.com/cli/shurcooL-graphql"
"github.com/humio/cli/api/internal/humiographql"
)

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
type AggregateAlert struct {
ID string `graphql:"id" yaml:"-" json:"id"`
Name string `graphql:"name" yaml:"name" json:"name"`
Expand All @@ -23,12 +25,15 @@ type AggregateAlert struct {
RunAsUserID string `graphql:"runAsUserId" yaml:"runAsUserId,omitempty" json:"runAsUserId,omitempty"`
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
type AggregateAlerts struct {
client *Client
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
func (c *Client) AggregateAlerts() *AggregateAlerts { return &AggregateAlerts{client: c} }

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
func (a *AggregateAlerts) List(viewName string) ([]*AggregateAlert, error) {
if viewName == "" {
return nil, fmt.Errorf("viewName must not be empty")
Expand Down Expand Up @@ -58,6 +63,7 @@ func (a *AggregateAlerts) List(viewName string) ([]*AggregateAlert, error) {
return aggregateAlerts, nil
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
func (a *AggregateAlerts) Update(viewName string, updatedAggregateAlert *AggregateAlert) (*AggregateAlert, error) {
if viewName == "" {
return nil, fmt.Errorf("viewName must not be empty")
Expand Down Expand Up @@ -117,6 +123,7 @@ func (a *AggregateAlerts) Update(viewName string, updatedAggregateAlert *Aggrega
return &aggregateAlert, nil
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
func (a *AggregateAlerts) Create(viewName string, newAggregateAlert *AggregateAlert) (*AggregateAlert, error) {
if viewName == "" {
return nil, fmt.Errorf("viewName must not be empty")
Expand Down Expand Up @@ -171,6 +178,7 @@ func (a *AggregateAlerts) Create(viewName string, newAggregateAlert *AggregateAl
return &aggregateAlert, nil
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
func (a *AggregateAlerts) Delete(viewName, aggregateAlertID string) error {
if viewName == "" {
return fmt.Errorf("viewName must not be empty")
Expand Down Expand Up @@ -198,6 +206,7 @@ func (a *AggregateAlerts) Delete(viewName, aggregateAlertID string) error {
return err
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
func (a *AggregateAlerts) Get(viewName string, aggregateAlertID string) (*AggregateAlert, error) {
var query struct {
SearchDomain struct {
Expand Down
13 changes: 12 additions & 1 deletion api/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package api

import (
"fmt"

graphql "github.com/cli/shurcooL-graphql"
"github.com/humio/cli/api/internal/humiographql"
)

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
type Alert struct {
ID string `graphql:"id" yaml:"-" json:"id"`
Name string `graphql:"name" yaml:"name" json:"name"`
Expand All @@ -25,16 +27,21 @@ type Alert struct {
}

const (
QueryOwnershipTypeUser string = "User"
// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
QueryOwnershipTypeUser string = "User"
// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
QueryOwnershipTypeOrganization string = "Organization"
)

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
type Alerts struct {
client *Client
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
func (c *Client) Alerts() *Alerts { return &Alerts{client: c} }

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
func (a *Alerts) List(viewName string) ([]Alert, error) {
var query struct {
SearchDomain struct {
Expand All @@ -55,6 +62,7 @@ func (a *Alerts) List(viewName string) ([]Alert, error) {
return alerts, err
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
func (a *Alerts) Update(viewName string, newAlert *Alert) (*Alert, error) {
if newAlert == nil {
return nil, fmt.Errorf("newAlert must not be nil")
Expand Down Expand Up @@ -108,6 +116,7 @@ func (a *Alerts) Update(viewName string, newAlert *Alert) (*Alert, error) {
return &alert, nil
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
func (a *Alerts) Add(viewName string, newAlert *Alert) (*Alert, error) {
if newAlert == nil {
return nil, fmt.Errorf("newAlert must not be nil")
Expand Down Expand Up @@ -155,6 +164,7 @@ func (a *Alerts) Add(viewName string, newAlert *Alert) (*Alert, error) {
return &alert, nil
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
func (a *Alerts) Get(viewName, alertName string) (*Alert, error) {
alerts, err := a.List(viewName)
if err != nil {
Expand All @@ -169,6 +179,7 @@ func (a *Alerts) Get(viewName, alertName string) (*Alert, error) {
return nil, AlertNotFound(alertName)
}

// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example
func (a *Alerts) Delete(viewName, alertName string) error {
actions, err := a.List(viewName)
if err != nil {
Expand Down
Loading

0 comments on commit 3021a73

Please sign in to comment.