diff --git a/api/actions.go b/api/actions.go index 95c7129..817158c 100644 --- a/api/actions.go +++ b/api/actions.go @@ -2,25 +2,36 @@ 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"` @@ -28,33 +39,39 @@ type EmailAction struct { 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"` @@ -62,17 +79,20 @@ type SlackPostMessageAction struct { 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"` @@ -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"` @@ -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 { @@ -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") @@ -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") @@ -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 { @@ -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 { @@ -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 { diff --git a/api/aggregate-alerts.go b/api/aggregate-alerts.go index 0ab409e..5dfdef1 100644 --- a/api/aggregate-alerts.go +++ b/api/aggregate-alerts.go @@ -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"` @@ -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") @@ -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") @@ -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") @@ -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") @@ -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 { diff --git a/api/alerts.go b/api/alerts.go index 95dd423..5e6a894 100644 --- a/api/alerts.go +++ b/api/alerts.go @@ -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"` @@ -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 { @@ -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") @@ -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") @@ -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 { @@ -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 { diff --git a/api/client.go b/api/client.go index ee2f11a..063c1ba 100644 --- a/api/client.go +++ b/api/client.go @@ -4,21 +4,24 @@ import ( "bytes" "context" "fmt" - graphql "github.com/cli/shurcooL-graphql" "io" "net" "net/http" "net/url" "strings" + + graphql "github.com/cli/shurcooL-graphql" ) const defaultUserAgent = "Humio-go-client/unknown" +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Client struct { config Config httpTransport *http.Transport } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Config struct { Address *url.URL UserAgent string @@ -29,37 +32,45 @@ type Config struct { DialContext func(ctx context.Context, network, addr string) (net.Conn, error) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func DefaultConfig() Config { config := Config{} return config } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Address() *url.URL { return c.config.Address } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Token() string { return c.config.Token } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) CACertificate() string { return c.config.CACertificatePEM } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Insecure() bool { return c.config.Insecure } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Config() Config { return c.config } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func NewClient(config Config) *Client { httpTransport := NewHttpTransport(config) return NewClientWithTransport(config, httpTransport) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func NewClientWithTransport(config Config, httpTransport *http.Transport) *Client { if config.Address != nil && !strings.HasSuffix(config.Address.Path, "/") { config.Address.Path = config.Address.Path + "/" @@ -75,6 +86,7 @@ func NewClientWithTransport(config Config, httpTransport *http.Transport) *Clien } } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) headers() map[string]string { headers := map[string]string{} @@ -93,6 +105,7 @@ func (c *Client) headers() map[string]string { return headers } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) newGraphQLClient() (*graphql.Client, error) { httpClient := c.newHTTPClientWithHeaders(c.headers()) graphqlURL, err := c.Address().Parse("graphql") @@ -102,6 +115,7 @@ func (c *Client) newGraphQLClient() (*graphql.Client, error) { return graphql.NewClient(graphqlURL.String(), httpClient), nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Query(query interface{}, variables map[string]interface{}) error { client, err := c.newGraphQLClient() if err != nil { @@ -110,6 +124,7 @@ func (c *Client) Query(query interface{}, variables map[string]interface{}) erro return client.Query(context.Background(), query, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Mutate(mutation interface{}, variables map[string]interface{}) error { client, err := c.newGraphQLClient() if err != nil { @@ -119,13 +134,18 @@ func (c *Client) Mutate(mutation interface{}, variables map[string]interface{}) } // JSONContentType is "application/json" +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example const JSONContentType string = "application/json" + +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example const ZIPContentType string = "application/zip" +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) HTTPRequest(httpMethod string, path string, body io.Reader) (*http.Response, error) { return c.HTTPRequestContext(context.Background(), httpMethod, path, body, JSONContentType) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) HTTPRequestContext(ctx context.Context, httpMethod string, path string, body io.Reader, contentType string) (*http.Response, error) { if body == nil { body = bytes.NewReader(nil) diff --git a/api/cluster.go b/api/cluster.go index c5f4271..7823eec 100644 --- a/api/cluster.go +++ b/api/cluster.go @@ -2,14 +2,17 @@ package api import ( "fmt" - graphql "github.com/cli/shurcooL-graphql" "math" + + graphql "github.com/cli/shurcooL-graphql" ) +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Clusters struct { client *Client } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type ClusterNode struct { Id int Name string @@ -35,11 +38,13 @@ type ClusterNode struct { Zone string } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type IngestPartition struct { Id int NodeIds []int } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Cluster struct { Nodes []ClusterNode ClusterInfoAgeSeconds float64 @@ -54,8 +59,10 @@ type Cluster struct { IngestPartitions []IngestPartition } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Clusters() *Clusters { return &Clusters{client: c} } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Clusters) Get() (Cluster, error) { var query struct { Cluster Cluster @@ -65,12 +72,15 @@ func (c *Clusters) Get() (Cluster, error) { return query.Cluster, err } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type ClusterNodes struct { client *Client } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) ClusterNodes() *ClusterNodes { return &ClusterNodes{client: c} } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (n *ClusterNodes) List() ([]ClusterNode, error) { var query struct { Cluster struct { @@ -82,6 +92,7 @@ func (n *ClusterNodes) List() ([]ClusterNode, error) { return query.Cluster.Nodes, err } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (n *ClusterNodes) Get(nodeID int) (ClusterNode, error) { var query struct { Cluster struct { @@ -103,6 +114,7 @@ func (n *ClusterNodes) Get(nodeID int) (ClusterNode, error) { return ClusterNode{}, fmt.Errorf("node id not found in cluster") } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (n *ClusterNodes) Unregister(nodeID int, force bool) error { if nodeID > math.MaxInt32 { return fmt.Errorf("node id too large") diff --git a/api/error.go b/api/error.go index 9a78cb3..a2bd54b 100644 --- a/api/error.go +++ b/api/error.go @@ -4,42 +4,59 @@ import ( "fmt" ) +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type EntityType string const ( - EntityTypeSearchDomain EntityType = "search-domain" - EntityTypeRepository EntityType = "repository" - EntityTypeView EntityType = "view" - EntityTypeIngestToken EntityType = "ingest-token" - EntityTypeParser EntityType = "parser" - EntityTypeAction EntityType = "action" - EntityTypeAlert EntityType = "alert" - EntityTypeFilterAlert EntityType = "filter-alert" + // Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example + EntityTypeSearchDomain EntityType = "search-domain" + // Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example + EntityTypeRepository EntityType = "repository" + // Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example + EntityTypeView EntityType = "view" + // Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example + EntityTypeIngestToken EntityType = "ingest-token" + // Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example + EntityTypeParser EntityType = "parser" + // Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example + EntityTypeAction EntityType = "action" + // Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example + EntityTypeAlert EntityType = "alert" + // Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example + EntityTypeFilterAlert EntityType = "filter-alert" + // Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example EntityTypeScheduledSearch EntityType = "scheduled-search" - EntityTypeAggregateAlert EntityType = "aggregate-alert" + // Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example + EntityTypeAggregateAlert EntityType = "aggregate-alert" ) +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (e EntityType) String() string { return string(e) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type EntityNotFound struct { entityType EntityType key string } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (e EntityNotFound) EntityType() EntityType { return e.entityType } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (e EntityNotFound) Key() string { return e.key } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (e EntityNotFound) Error() string { return fmt.Sprintf("%s %q not found", e.entityType.String(), e.key) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func SearchDomainNotFound(name string) error { return EntityNotFound{ entityType: EntityTypeSearchDomain, @@ -47,6 +64,7 @@ func SearchDomainNotFound(name string) error { } } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func RepositoryNotFound(name string) error { return EntityNotFound{ entityType: EntityTypeRepository, @@ -54,6 +72,7 @@ func RepositoryNotFound(name string) error { } } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func ViewNotFound(name string) error { return EntityNotFound{ entityType: EntityTypeView, @@ -61,6 +80,7 @@ func ViewNotFound(name string) error { } } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func IngestTokenNotFound(name string) error { return EntityNotFound{ entityType: EntityTypeIngestToken, @@ -68,6 +88,7 @@ func IngestTokenNotFound(name string) error { } } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func ParserNotFound(name string) error { return EntityNotFound{ entityType: EntityTypeParser, @@ -75,6 +96,7 @@ func ParserNotFound(name string) error { } } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func ActionNotFound(name string) error { return EntityNotFound{ entityType: EntityTypeAction, @@ -82,6 +104,7 @@ func ActionNotFound(name string) error { } } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func AlertNotFound(name string) error { return EntityNotFound{ entityType: EntityTypeAlert, @@ -89,6 +112,7 @@ func AlertNotFound(name string) error { } } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func FilterAlertNotFound(name string) error { return EntityNotFound{ entityType: EntityTypeFilterAlert, @@ -96,6 +120,7 @@ func FilterAlertNotFound(name string) error { } } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func ScheduledSearchNotFound(name string) error { return EntityNotFound{ entityType: EntityTypeScheduledSearch, @@ -103,6 +128,7 @@ func ScheduledSearchNotFound(name string) error { } } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func AggregateAlertNotFound(name string) error { return EntityNotFound{ entityType: EntityTypeAggregateAlert, diff --git a/api/featureflag.go b/api/featureflag.go index 35ae741..713b205 100644 --- a/api/featureflag.go +++ b/api/featureflag.go @@ -2,16 +2,20 @@ package api import graphql "github.com/cli/shurcooL-graphql" +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type FeatureFlag string +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type FeatureFlags struct { c *Client } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) FeatureFlags() *FeatureFlags { return &FeatureFlags{c: c} } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (f *FeatureFlags) SupportedFlags() ([]FeatureFlag, error) { var query struct { Type struct { @@ -34,6 +38,7 @@ func (f *FeatureFlags) SupportedFlags() ([]FeatureFlag, error) { return result, nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (f *FeatureFlags) EnableGlobally(flag FeatureFlag) error { var mutation struct { EnableFeature bool `graphql:"enableFeature(feature: $feature)"` @@ -46,6 +51,7 @@ func (f *FeatureFlags) EnableGlobally(flag FeatureFlag) error { return f.c.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (f *FeatureFlags) DisableGlobally(flag FeatureFlag) error { var mutation struct { DisableFeature bool `graphql:"disableFeature(feature: $feature)"` @@ -58,6 +64,7 @@ func (f *FeatureFlags) DisableGlobally(flag FeatureFlag) error { return f.c.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (f *FeatureFlags) EnableForOrganization(organizationID string, flag FeatureFlag) error { var mutation struct { EnableFeature bool `graphql:"enableFeatureForOrg(feature: $feature, orgId: $orgId)"` @@ -71,6 +78,7 @@ func (f *FeatureFlags) EnableForOrganization(organizationID string, flag Feature return f.c.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (f *FeatureFlags) DisableForOrganization(organizationID string, flag FeatureFlag) error { var mutation struct { DisableFeature bool `graphql:"disableFeatureForOrg(feature: $feature, orgId: $orgId)"` @@ -84,6 +92,7 @@ func (f *FeatureFlags) DisableForOrganization(organizationID string, flag Featur return f.c.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (f *FeatureFlags) EnableForUser(userID string, flag FeatureFlag) error { var mutation struct { EnableFeature bool `graphql:"enableFeatureForUser(feature: $feature, userId: $userId)"` @@ -97,6 +106,7 @@ func (f *FeatureFlags) EnableForUser(userID string, flag FeatureFlag) error { return f.c.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (f *FeatureFlags) DisableForUser(userID string, flag FeatureFlag) error { var mutation struct { DisableFeature bool `graphql:"disableFeatureForUser(feature: $feature, userId: $userId)"` diff --git a/api/files.go b/api/files.go index 6ca6b73..005db5a 100644 --- a/api/files.go +++ b/api/files.go @@ -3,27 +3,32 @@ package api import ( "context" "fmt" - graphql "github.com/cli/shurcooL-graphql" "io" "mime/multipart" "net/http" "net/url" + graphql "github.com/cli/shurcooL-graphql" + "golang.org/x/sync/errgroup" ) +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Files struct { client *Client } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type File struct { ID string Name string ContentHash string } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Files() *Files { return &Files{client: c} } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (f *Files) List(viewName string) ([]File, error) { var query struct { SearchDomain struct { @@ -39,6 +44,7 @@ func (f *Files) List(viewName string) ([]File, error) { return query.SearchDomain.Files, err } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (f *Files) Delete(viewName string, fileName string) error { var query struct { RemoveFile struct { @@ -55,6 +61,7 @@ func (f *Files) Delete(viewName string, fileName string) error { return f.client.Mutate(&query, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (f *Files) Upload(viewName string, fileName string, reader io.Reader) error { pr, pw := io.Pipe() @@ -98,6 +105,7 @@ func (f *Files) Upload(viewName string, fileName string, reader io.Reader) error return nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (f *Files) Download(viewName string, fileName string) (io.Reader, error) { resp, err := f.client.HTTPRequest(http.MethodGet, fmt.Sprintf("api/v1/dataspaces/%s/files/%s", url.PathEscape(viewName), url.PathEscape(fileName)), nil) if err != nil { diff --git a/api/filter-alerts.go b/api/filter-alerts.go index 7378192..3990ecc 100644 --- a/api/filter-alerts.go +++ b/api/filter-alerts.go @@ -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 FilterAlert struct { ID string `graphql:"id" yaml:"-" json:"id"` Name string `graphql:"name" yaml:"name" json:"name"` @@ -20,12 +22,15 @@ type FilterAlert 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 FilterAlerts struct { client *Client } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) FilterAlerts() *FilterAlerts { return &FilterAlerts{client: c} } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (fa *FilterAlerts) List(viewName string) ([]FilterAlert, error) { var query struct { SearchDomain struct { @@ -50,6 +55,7 @@ func (fa *FilterAlerts) List(viewName string) ([]FilterAlert, error) { return filterAlerts, err } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (fa *FilterAlerts) Update(viewName string, updatedFilterAlert *FilterAlert) (*FilterAlert, error) { if updatedFilterAlert == nil { return nil, fmt.Errorf("updatedFilterAlert must not be nil") @@ -102,6 +108,7 @@ func (fa *FilterAlerts) Update(viewName string, updatedFilterAlert *FilterAlert) return &filterAlert, nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (fa *FilterAlerts) Create(viewName string, newFilterAlert *FilterAlert) (*FilterAlert, error) { if newFilterAlert == nil { return nil, fmt.Errorf("newFilterAlert must not be nil") @@ -149,6 +156,7 @@ func (fa *FilterAlerts) Create(viewName string, newFilterAlert *FilterAlert) (*F return &filterAlert, nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (fa *FilterAlerts) Delete(viewName, filterAlertID string) error { if filterAlertID == "" { return fmt.Errorf("filterAlertID is empty") @@ -172,6 +180,7 @@ func (fa *FilterAlerts) Delete(viewName, filterAlertID string) error { return err } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (fa *FilterAlerts) Get(viewName string, filterAlertID string) (*FilterAlert, error) { var query struct { SearchDomain struct { diff --git a/api/groups.go b/api/groups.go index 30c676f..240a5b9 100644 --- a/api/groups.go +++ b/api/groups.go @@ -2,22 +2,28 @@ package api import ( "errors" + graphql "github.com/cli/shurcooL-graphql" ) +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Groups struct { client *Client } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Group struct { ID string DisplayName string } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Groups() *Groups { return &Groups{client: c} } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example var ErrUserNotFound = errors.New("user not found") +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (g *Groups) List() ([]Group, error) { var query struct { Page struct { @@ -33,6 +39,7 @@ func (g *Groups) List() ([]Group, error) { return query.Page.Groups, nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (g *Groups) AddUserToGroup(groupID string, userID string) error { var mutation struct { AddUsersToGroup struct { @@ -69,6 +76,7 @@ func (g *Groups) AddUserToGroup(groupID string, userID string) error { return nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (g *Groups) RemoveUserFromGroup(groupID string, userID string) error { var mutation struct { RemoveUsersFromGroup struct { diff --git a/api/health.go b/api/health.go index 52f936e..854fc2b 100644 --- a/api/health.go +++ b/api/health.go @@ -8,14 +8,19 @@ import ( "net/http" ) +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type StatusValue string const ( - StatusOK StatusValue = "OK" + // Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example + StatusOK StatusValue = "OK" + // Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example StatusWarn StatusValue = "WARN" + // Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example StatusDown StatusValue = "DOWN" ) +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type HealthCheck struct { Name string `json:"name"` Status StatusValue `json:"status"` @@ -23,6 +28,7 @@ type HealthCheck struct { Fields map[string]interface{} `json:"fields"` } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Health struct { Status StatusValue `json:"status"` StatusMessage string `json:"statusMessage"` @@ -34,6 +40,7 @@ type Health struct { rawJson []byte } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) HealthString() (string, error) { resp, err := c.HTTPRequest(http.MethodGet, "api/v1/health", nil) if err != nil { @@ -48,6 +55,7 @@ func (c *Client) HealthString() (string, error) { return string(bytes), nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Health() (Health, error) { resp, err := c.HTTPRequest(http.MethodGet, "api/v1/health-json", nil) if err != nil { @@ -80,6 +88,7 @@ func (c *Client) Health() (Health, error) { return health, err } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (h *Health) ChecksMap() map[string]HealthCheck { m := map[string]HealthCheck{} @@ -92,6 +101,7 @@ func (h *Health) ChecksMap() map[string]HealthCheck { return m } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (h *Health) Json() []byte { return h.rawJson } diff --git a/api/httpclient.go b/api/httpclient.go index b0cbcad..4012091 100644 --- a/api/httpclient.go +++ b/api/httpclient.go @@ -16,6 +16,7 @@ type headerTransport struct { headers map[string]string } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func NewHttpTransport(config Config) *http.Transport { dialContext := config.DialContext if dialContext == nil { @@ -86,6 +87,7 @@ func (c *Client) newHTTPClientWithHeaders(headers map[string]string) *http.Clien } } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (h *headerTransport) RoundTrip(req *http.Request) (*http.Response, error) { req2 := CloneRequest(req) for key, val := range h.headers { @@ -97,6 +99,7 @@ func (h *headerTransport) RoundTrip(req *http.Request) (*http.Response, error) { // CloneRequest and CloneHeader copied from https://github.com/kubernetes/apimachinery/blob/a76b7114b20a2e56fd698bba815b1e2c82ec4bff/pkg/util/net/http.go#L469-L491 // CloneRequest creates a shallow copy of the request along with a deep copy of the Headers. +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func CloneRequest(req *http.Request) *http.Request { r := new(http.Request) @@ -110,6 +113,7 @@ func CloneRequest(req *http.Request) *http.Request { } // CloneHeader creates a deep copy of an http.Header. +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func CloneHeader(in http.Header) http.Header { out := make(http.Header, len(in)) for key, values := range in { diff --git a/api/ingest-tokens.go b/api/ingest-tokens.go index 28da72a..9296495 100644 --- a/api/ingest-tokens.go +++ b/api/ingest-tokens.go @@ -4,16 +4,19 @@ import ( graphql "github.com/cli/shurcooL-graphql" ) +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type IngestTokens struct { client *Client } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type IngestToken struct { Name string `json:"name"` Token string `json:"token"` AssignedParser string `json:"parser"` } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) IngestTokens() *IngestTokens { return &IngestTokens{client: c} } type ingestTokenData struct { @@ -24,6 +27,7 @@ type ingestTokenData struct { } } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (i *IngestTokens) List(repo string) ([]IngestToken, error) { var query struct { Result struct { @@ -48,6 +52,7 @@ func (i *IngestTokens) List(repo string) ([]IngestToken, error) { return tokens, nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (i *IngestTokens) Get(repoName, tokenName string) (*IngestToken, error) { tokensInRepo, err := i.List(repoName) if err != nil { @@ -76,6 +81,7 @@ func toIngestToken(data ingestTokenData) *IngestToken { } } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (i *IngestTokens) Add(repositoryName string, tokenName string, parser string) (*IngestToken, error) { variables := map[string]interface{}{ "tokenName": graphql.String(tokenName), @@ -111,6 +117,7 @@ func (i *IngestTokens) Add(repositoryName string, tokenName string, parser strin return &ingestToken, nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (i *IngestTokens) Update(repositoryName string, tokenName string, parser string) (*IngestToken, error) { if parser == "" { var mutation struct { @@ -152,6 +159,7 @@ func (i *IngestTokens) Update(repositoryName string, tokenName string, parser st return i.Get(repositoryName, tokenName) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (i *IngestTokens) Remove(repositoryName string, tokenName string) error { var mutation struct { Result struct { diff --git a/api/license.go b/api/license.go index 7fbad22..1193cd2 100644 --- a/api/license.go +++ b/api/license.go @@ -2,15 +2,18 @@ package api import graphql "github.com/cli/shurcooL-graphql" +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Licenses struct { client *Client } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type License interface { ExpiresAt() string IssuedAt() string } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type OnPremLicense struct { ID string ExpiresAtVal string @@ -19,16 +22,20 @@ type OnPremLicense struct { NumberOfSeats int } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (l OnPremLicense) IssuedAt() string { return l.IssuedAtVal } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (l OnPremLicense) ExpiresAt() string { return l.ExpiresAtVal } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Licenses() *Licenses { return &Licenses{client: c} } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (l *Licenses) Install(license string) error { var mutation struct { @@ -44,6 +51,7 @@ func (l *Licenses) Install(license string) error { return l.client.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (l *Licenses) Get() (License, error) { var query struct { InstalledLicense struct { diff --git a/api/organizations.go b/api/organizations.go index 0632fb7..e8ec4ae 100644 --- a/api/organizations.go +++ b/api/organizations.go @@ -2,18 +2,22 @@ package api import graphql "github.com/cli/shurcooL-graphql" +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Organizations struct { client *Client } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Organization struct { ID string Name string Description *string } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Organizations() *Organizations { return &Organizations{client: c} } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (o *Organizations) CreateOrganization(name string) (Organization, error) { var mutation struct { CreateOrganization Organization `graphql:"createEmptyOrganization(name: $name)"` diff --git a/api/packages.go b/api/packages.go index fd31a3e..ed33836 100644 --- a/api/packages.go +++ b/api/packages.go @@ -5,7 +5,6 @@ import ( "context" "encoding/json" "fmt" - graphql "github.com/cli/shurcooL-graphql" "io" "net/http" "net/url" @@ -13,28 +12,35 @@ import ( "path" "path/filepath" "strings" + + graphql "github.com/cli/shurcooL-graphql" ) // Packages is a API client for working with Humio packages. +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Packages struct { client *Client } // Packages constructs a Packages API client. +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Packages() *Packages { return &Packages{client: c} } // ValidationResponse contain the results of a package validation. +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type ValidationResponse struct { InstallationErrors []string `json:"installationErrors"` ParseErrors []string `json:"parseErrors"` } // IsValid returns true if there are no errors in the package +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (resp *ValidationResponse) IsValid() bool { return (len(resp.InstallationErrors) == 0) && (len(resp.ParseErrors) == 0) } // InstalledPackage contain the details of an installed package +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type InstalledPackage struct { ID string InstalledBy *struct { @@ -59,6 +65,7 @@ func isDirectory(path string) (bool, error) { // Validate checks a package declaration validity against a Humio // server. +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (p *Packages) Validate(viewName string, absPath string) (*ValidationResponse, error) { var zipFilePath string var err error @@ -106,6 +113,7 @@ func (p *Packages) Validate(viewName string, absPath string) (*ValidationRespons } // ListInstalled returns a list of installed packages +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (p *Packages) ListInstalled(viewName string) ([]InstalledPackage, error) { var query struct { Repository struct { @@ -122,6 +130,7 @@ func (p *Packages) ListInstalled(viewName string) ([]InstalledPackage, error) { } // InstallArchive installs a local package (zip file). +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (p *Packages) InstallArchive(viewName string, pathToZip string) (*ValidationResponse, error) { // #nosec G304 fileReader, err := os.Open(pathToZip) @@ -175,6 +184,7 @@ func detailedInstallationError(response *http.Response) error { return fmt.Errorf("%s", strings.Join(formattedErrors, "")) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type InstallationErrors struct { InstallationErrors []string `json:"installationErrors"` ParseErrors []string `json:"parseErrors"` @@ -183,12 +193,15 @@ type InstallationErrors struct { type ( // VersionedPackageSpecifier is the ID and version of a package, e.g foo/bar@2.0.1 + // Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example VersionedPackageSpecifier string // UnversionedPackageSpecifier is the ID of a package, e.g foo/bar + // Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example UnversionedPackageSpecifier string ) // UninstallPackage uninstalls a package by name. +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (p *Packages) UninstallPackage(viewName string, packageID string) error { var mutation struct { @@ -207,6 +220,7 @@ func (p *Packages) UninstallPackage(viewName string, packageID string) error { } // CreateArchive creates a archive by bundling the files in packageDirPath in a zip file. +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (p *Packages) CreateArchive(packageDirPath string, targetFileName string) error { // #nosec G304 outFile, err := os.Create(targetFileName) @@ -220,6 +234,7 @@ func (p *Packages) CreateArchive(packageDirPath string, targetFileName string) e } // InstallFromDirectory installs a package from a directory containing the package files. +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (p *Packages) InstallFromDirectory(packageDirPath string, targetRepoOrView string) (*ValidationResponse, error) { zipFilePath, err := createTempZipFromFolder(packageDirPath) if err != nil { diff --git a/api/parsers.go b/api/parsers.go index b74560e..c2c92f8 100644 --- a/api/parsers.go +++ b/api/parsers.go @@ -2,27 +2,33 @@ 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 const LogScaleVersionWithParserAPIv2 = "1.129.0" +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type ParserTestEvent struct { RawString string `json:"rawString" yaml:"rawString"` } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type ParserTestCaseAssertions struct { OutputEventIndex int `json:"outputEventIndex" yaml:"outputEventIndex"` FieldsNotPresent []string `json:"fieldsNotPresent" yaml:"fieldsNotPresent"` FieldsHaveValues map[string]string `json:"fieldsHaveValues" yaml:"fieldsHaveValues"` } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type ParserTestCase struct { Event ParserTestEvent `json:"event" yaml:"event"` Assertions []ParserTestCaseAssertions `json:"assertions" yaml:"assertions"` } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Parser struct { ID string Name string @@ -32,18 +38,22 @@ type Parser struct { FieldsToBeRemovedBeforeParsing []string `json:"fieldsToBeRemovedBeforeParsing,omitempty" yaml:"fieldsToBeRemovedBeforeParsing"` } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Parsers struct { client *Client } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Parsers() *Parsers { return &Parsers{client: c} } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type ParserListItem struct { ID string Name string IsBuiltIn bool } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (p *Parsers) List(repositoryName string) ([]ParserListItem, error) { var query struct { Repository struct { @@ -63,6 +73,7 @@ func (p *Parsers) List(repositoryName string) ([]ParserListItem, error) { return parsers, err } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (p *Parsers) Delete(repositoryName string, parserName string) error { status, err := p.client.Status() if err != nil { @@ -114,6 +125,7 @@ func (p *Parsers) Delete(repositoryName string, parserName string) error { return p.client.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (p *Parsers) Add(repositoryName string, newParser *Parser, allowOverwritingExistingParser bool) (*Parser, error) { if newParser == nil { return nil, fmt.Errorf("newFilterAlert must not be nil") @@ -233,6 +245,7 @@ func mapParserTestCaseToInput(p ParserTestCase) humiographql.ParserTestCaseInput } } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (p *Parsers) Get(repositoryName string, parserName string) (*Parser, error) { status, err := p.client.Status() if err != nil { @@ -322,6 +335,7 @@ func (p *Parsers) Get(repositoryName string, parserName string) (*Parser, error) return &parser, nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (p *Parsers) Export(repositoryName string, parserName string) (string, error) { var query struct { diff --git a/api/repositories.go b/api/repositories.go index 753107b..beeba6d 100644 --- a/api/repositories.go +++ b/api/repositories.go @@ -8,10 +8,12 @@ import ( "github.com/humio/cli/api/internal/humiographql" ) +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Repositories struct { client *Client } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Repository struct { ID string Name string @@ -24,8 +26,10 @@ type Repository struct { AutomaticSearch bool `graphql:"automaticSearch"` } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Repositories() *Repositories { return &Repositories{client: c} } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (r *Repositories) Get(name string) (Repository, error) { var query struct { Repository Repository `graphql:"repository(name: $name)"` @@ -44,12 +48,14 @@ func (r *Repositories) Get(name string) (Repository, error) { return query.Repository, nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type RepoListItem struct { ID string Name string SpaceUsed int64 `graphql:"compressedByteSize"` } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (r *Repositories) List() ([]RepoListItem, error) { var query struct { Repositories []RepoListItem `graphql:"repositories"` @@ -59,6 +65,7 @@ func (r *Repositories) List() ([]RepoListItem, error) { return query.Repositories, err } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (r *Repositories) Create(name string) error { var mutation struct { CreateRepository struct { @@ -79,6 +86,7 @@ func (r *Repositories) Create(name string) error { return nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (r *Repositories) Delete(name, reason string, allowDataDeletion bool) error { _, err := r.Get(name) if err != nil { @@ -103,18 +111,24 @@ func (r *Repositories) Delete(name, reason string, allowDataDeletion bool) error return r.client.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type DefaultGroupEnum string const ( - DefaultGroupEnumMember DefaultGroupEnum = "Member" - DefaultGroupEnumAdmin DefaultGroupEnum = "Admin" + // Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example + DefaultGroupEnumMember DefaultGroupEnum = "Member" + // Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example + DefaultGroupEnumAdmin DefaultGroupEnum = "Admin" + // Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example DefaultGroupEnumEliminator DefaultGroupEnum = "Eliminator" ) +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (e DefaultGroupEnum) String() string { return string(e) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (e *DefaultGroupEnum) ParseString(s string) bool { switch strings.ToLower(s) { case "member": @@ -131,6 +145,7 @@ func (e *DefaultGroupEnum) ParseString(s string) bool { } } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (r *Repositories) UpdateUserGroup(name, username string, groups ...DefaultGroupEnum) error { if len(groups) == 0 { return fmt.Errorf("at least one group must be defined") @@ -151,6 +166,7 @@ func (r *Repositories) UpdateUserGroup(name, username string, groups ...DefaultG return r.client.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (r *Repositories) UpdateTimeBasedRetention(name string, retentionInDays float64, allowDataDeletion bool) error { existingRepo, err := r.Get(name) if err != nil { @@ -179,6 +195,7 @@ func (r *Repositories) UpdateTimeBasedRetention(name string, retentionInDays flo return r.client.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (r *Repositories) UpdateStorageBasedRetention(name string, storageInGB float64, allowDataDeletion bool) error { existingRepo, err := r.Get(name) if err != nil { @@ -207,6 +224,7 @@ func (r *Repositories) UpdateStorageBasedRetention(name string, storageInGB floa return r.client.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (r *Repositories) UpdateIngestBasedRetention(name string, ingestInGB float64, allowDataDeletion bool) error { existingRepo, err := r.Get(name) if err != nil { @@ -235,6 +253,7 @@ func (r *Repositories) UpdateIngestBasedRetention(name string, ingestInGB float6 return r.client.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (r *Repositories) UpdateDescription(name, description string) error { _, err := r.Get(name) if err != nil { @@ -256,6 +275,7 @@ func (r *Repositories) UpdateDescription(name, description string) error { return r.client.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (r *Repositories) EnableS3Archiving(name string) error { existingRepo, err := r.Get(name) if err != nil { @@ -280,6 +300,7 @@ func (r *Repositories) EnableS3Archiving(name string) error { return r.client.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (r *Repositories) DisableS3Archiving(name string) error { existingRepo, err := r.Get(name) if err != nil { @@ -304,6 +325,7 @@ func (r *Repositories) DisableS3Archiving(name string) error { return r.client.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (r *Repositories) UpdateS3ArchivingConfiguration(name string, bucket string, region string, format string) error { _, err := r.Get(name) if err != nil { @@ -340,6 +362,7 @@ func (r *Repositories) UpdateS3ArchivingConfiguration(name string, bucket string return r.client.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (r *Repositories) UpdateAutomaticSearch(name string, automaticSearch bool) error { _, err := r.Get(name) if err != nil { diff --git a/api/roles.go b/api/roles.go index 6979aad..1ce8014 100644 --- a/api/roles.go +++ b/api/roles.go @@ -2,13 +2,16 @@ package api import ( "fmt" + graphql "github.com/cli/shurcooL-graphql" ) +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Roles struct { client *Client } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Role struct { ID string `graphql:"id"` DisplayName string `graphql:"displayName"` @@ -19,8 +22,10 @@ type Role struct { OrgPermissions []string `graphql:"organizationPermissions"` } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Roles() *Roles { return &Roles{client: c} } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (r *Roles) List() ([]Role, error) { var query struct { Roles struct { @@ -38,6 +43,7 @@ func (r *Roles) List() ([]Role, error) { return RolesList, nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (r *Roles) Create(role *Role) error { var mutation struct { Role `graphql:"createRole(input: {displayName: $displayName, viewPermissions: $permissions, color: $color, systemPermissions: $systemPermissions, organizationPermissions: $orgPermissions})"` @@ -70,6 +76,7 @@ func (r *Roles) Create(role *Role) error { return r.client.Mutate(mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (r *Roles) Update(rolename string, newRole *Role) error { roleId, err := r.GetRoleID(rolename) if roleId == "" || err != nil { @@ -112,6 +119,7 @@ func (r *Roles) Update(rolename string, newRole *Role) error { return r.client.Mutate(mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (r *Roles) RemoveRole(rolename string) error { var mutation struct { RemoveRole struct { @@ -132,6 +140,7 @@ func (r *Roles) RemoveRole(rolename string) error { return r.client.Mutate(mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (r *Roles) Get(rolename string) (*Role, error) { roleId, err := r.GetRoleID(rolename) if roleId == "" || err != nil { @@ -154,6 +163,7 @@ func (r *Roles) Get(rolename string) (*Role, error) { return &query.Role, nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (r *Roles) GetRoleID(rolename string) (string, error) { roles, err := r.List() if err != nil { diff --git a/api/scheduled-search.go b/api/scheduled-search.go index cba1ade..d0cae80 100644 --- a/api/scheduled-search.go +++ b/api/scheduled-search.go @@ -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 ScheduledSearch struct { ID string `graphql:"id" yaml:"-" json:"id"` Name string `graphql:"name" yaml:"name" json:"name"` @@ -23,12 +25,15 @@ type ScheduledSearch struct { QueryOwnershipType string `graphql:"queryOwnership" yaml:"queryOwnershipType" json:"queryOwnershipType"` } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type ScheduledSearches struct { client *Client } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) ScheduledSearches() *ScheduledSearches { return &ScheduledSearches{client: c} } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (a *ScheduledSearches) List(viewName string) ([]ScheduledSearch, error) { var query struct { SearchDomain struct { @@ -53,6 +58,7 @@ func (a *ScheduledSearches) List(viewName string) ([]ScheduledSearch, error) { return scheduledSearches, err } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (a *ScheduledSearches) Update(viewName string, updateScheduledSearch *ScheduledSearch) (*ScheduledSearch, error) { if updateScheduledSearch == nil { return nil, fmt.Errorf("updateScheduledSearch must not be nil") @@ -108,6 +114,7 @@ func (a *ScheduledSearches) Update(viewName string, updateScheduledSearch *Sched return &scheduledSearch, nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (a *ScheduledSearches) Create(viewName string, newScheduledSearch *ScheduledSearch) (*ScheduledSearch, error) { if newScheduledSearch == nil { return nil, fmt.Errorf("newScheduledSearch must not be nil") @@ -158,6 +165,7 @@ func (a *ScheduledSearches) Create(viewName string, newScheduledSearch *Schedule return &scheduledSearch, nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (a *ScheduledSearches) Delete(viewName, scheduledSearchID string) error { if scheduledSearchID == "" { return fmt.Errorf("scheduledSearchID is empty") @@ -181,6 +189,7 @@ func (a *ScheduledSearches) Delete(viewName, scheduledSearchID string) error { return err } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (a *ScheduledSearches) Get(viewName string, scheduledSearchId string) (*ScheduledSearch, error) { var query struct { SearchDomain struct { diff --git a/api/search.go b/api/search.go index 35536af..4bf1e01 100644 --- a/api/search.go +++ b/api/search.go @@ -10,12 +10,15 @@ import ( "net/url" ) +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type QueryJobs struct { client *Client } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) QueryJobs() *QueryJobs { return &QueryJobs{client: c} } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Query struct { QueryString string `json:"queryString"` Start string `json:"start,omitempty"` @@ -26,6 +29,7 @@ type Query struct { ShowQueryEventDistribution bool `json:"showQueryEventDistribution,omitempty"` } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type QueryResultMetadata struct { EventCount uint64 `json:"eventCount"` ExtraData map[string]interface{} `json:"extraData"` @@ -42,6 +46,7 @@ type QueryResultMetadata struct { WorkDone uint64 `json:"workDone"` } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type QueryResult struct { Cancelled bool `json:"cancelled"` Done bool `json:"done"` @@ -49,14 +54,17 @@ type QueryResult struct { Metadata QueryResultMetadata `json:"metaData"` } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type QueryError struct { error string } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (e QueryError) Error() string { return e.error } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (q QueryJobs) Create(repository string, query Query) (string, error) { var buf bytes.Buffer err := json.NewEncoder(&buf).Encode(query) @@ -96,10 +104,12 @@ func (q QueryJobs) Create(repository string, query Query) (string, error) { return jsonResponse.ID, nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (q *QueryJobs) Poll(repository string, id string) (QueryResult, error) { return q.PollContext(context.Background(), repository, id) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (q *QueryJobs) PollContext(ctx context.Context, repository string, id string) (QueryResult, error) { resp, err := q.client.HTTPRequestContext(ctx, http.MethodGet, "api/v1/repositories/"+url.QueryEscape(repository)+"/queryjobs/"+id, nil, JSONContentType) @@ -118,6 +128,7 @@ func (q *QueryJobs) PollContext(ctx context.Context, repository string, id strin return result, err } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (q *QueryJobs) Delete(repository string, id string) error { _, err := q.client.HTTPRequest(http.MethodDelete, "api/v1/repositories/"+url.QueryEscape(repository)+"/queryjobs/"+id, nil) return err diff --git a/api/searchdomains.go b/api/searchdomains.go index 2dcb8e1..f659a97 100644 --- a/api/searchdomains.go +++ b/api/searchdomains.go @@ -7,10 +7,12 @@ import ( graphql "github.com/cli/shurcooL-graphql" ) +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type SearchDomains struct { client *Client } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type SearchDomainsQueryData struct { Name string Description string @@ -18,14 +20,17 @@ type SearchDomainsQueryData struct { Typename graphql.String `graphql:"__typename"` } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type SearchDomain struct { Name string Description string AutomaticSearch bool } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (s *Client) SearchDomains() *SearchDomains { return &SearchDomains{client: s} } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (s *SearchDomains) Get(name string) (*SearchDomain, error) { var query struct { Result SearchDomainsQueryData `graphql:"searchDomain(name: $name)"` @@ -49,12 +54,14 @@ func (s *SearchDomains) Get(name string) (*SearchDomain, error) { return &searchDomain, nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type SearchDomainListItem struct { Name string Typename string `graphql:"__typename"` AutomaticSearch bool } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (s *SearchDomains) List() ([]SearchDomainListItem, error) { var query struct { SearchDomain []SearchDomainListItem `graphql:"searchDomains"` diff --git a/api/status.go b/api/status.go index 3b1eb97..24bee3c 100644 --- a/api/status.go +++ b/api/status.go @@ -10,15 +10,18 @@ import ( "github.com/Masterminds/semver/v3" ) +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type StatusResponse struct { Status string Version string } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (s StatusResponse) IsDown() bool { return s.Status != "OK" && s.Status != "WARN" } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (s StatusResponse) AtLeast(ver string) (bool, error) { assumeLatest := true version := strings.Split(s.Version, "-") @@ -34,6 +37,7 @@ func (s StatusResponse) AtLeast(ver string) (bool, error) { return constraint.Check(semverVersion), nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Status() (*StatusResponse, error) { resp, err := c.HTTPRequest(http.MethodGet, "api/v1/status", nil) diff --git a/api/users.go b/api/users.go index 152f413..c525f6c 100644 --- a/api/users.go +++ b/api/users.go @@ -2,13 +2,16 @@ package api import ( "errors" + graphql "github.com/cli/shurcooL-graphql" ) +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Users struct { client *Client } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type User struct { ID string Username string @@ -21,6 +24,7 @@ type User struct { CreatedAt string } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type UserChangeSet struct { IsRoot *bool FullName *string @@ -30,8 +34,10 @@ type UserChangeSet struct { Email *string } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Users() *Users { return &Users{client: c} } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (u *Users) List() ([]User, error) { var query struct { Users []User `graphql:"users"` @@ -41,6 +47,7 @@ func (u *Users) List() ([]User, error) { return query.Users, err } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (u *Users) Get(username string) (User, error) { var query struct { Users []User `graphql:"users(search: $username)"` @@ -64,6 +71,7 @@ func (u *Users) Get(username string) (User, error) { return User{}, errors.New("user not found") } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (u *Users) Update(username string, changeset UserChangeSet) (User, error) { var mutation struct { Result struct{ User User } `graphql:"updateUser(input: {username: $username, company: $company, isRoot: $isRoot, fullName: $fullName, picture: $picture, email: $email, countryCode: $countryCode})"` @@ -73,6 +81,7 @@ func (u *Users) Update(username string, changeset UserChangeSet) (User, error) { return mutation.Result.User, err } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (u *Users) Add(username string, changeset UserChangeSet) (User, error) { var mutation struct { Result struct { @@ -89,6 +98,7 @@ func (u *Users) Add(username string, changeset UserChangeSet) (User, error) { return u.Get(username) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (u *Users) Remove(username string) (User, error) { var mutation struct { Result struct { @@ -104,6 +114,7 @@ func (u *Users) Remove(username string) (User, error) { return mutation.Result.User, err } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (u *Users) RotateToken(userID string) (string, error) { var mutation struct { Token string `graphql:"rotateToken(input:{id:$id})"` @@ -121,6 +132,7 @@ func (u *Users) RotateToken(userID string) (string, error) { return mutation.Token, nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func userChangesetToVars(username string, changeset UserChangeSet) map[string]interface{} { return map[string]interface{}{ "username": graphql.String(username), diff --git a/api/viewer.go b/api/viewer.go index f08c1f3..bfdd178 100644 --- a/api/viewer.go +++ b/api/viewer.go @@ -1,12 +1,15 @@ package api +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Viewer struct { client *Client } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Viewer() *Viewer { return &Viewer{client: c} } // Username fetches the username associated with the API Token in use. +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Viewer) Username() (string, error) { var query struct { Viewer struct { @@ -19,6 +22,7 @@ func (c *Viewer) Username() (string, error) { } // ApiToken fetches the api token for the user who is currently authenticated. +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Viewer) ApiToken() (string, error) { var query struct { Viewer struct { diff --git a/api/views.go b/api/views.go index 6a9c5ed..814b6ca 100644 --- a/api/views.go +++ b/api/views.go @@ -1,22 +1,26 @@ package api import ( - "github.com/humio/cli/api/internal/humiographql" "sort" "strings" + "github.com/humio/cli/api/internal/humiographql" + graphql "github.com/cli/shurcooL-graphql" ) +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type Views struct { client *Client } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type ViewConnection struct { RepoName string Filter string } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type ViewQueryData struct { Name string Description string @@ -30,6 +34,7 @@ type ViewQueryData struct { Typename graphql.String `graphql:"__typename"` } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type View struct { Name string Description string @@ -37,8 +42,10 @@ type View struct { AutomaticSearch bool } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Client) Views() *Views { return &Views{client: c} } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Views) Get(name string) (*View, error) { var query struct { Result ViewQueryData `graphql:"searchDomain(name: $name)"` @@ -74,12 +81,14 @@ func (c *Views) Get(name string) (*View, error) { return &view, nil } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type ViewListItem struct { Name string Typename string `graphql:"__typename"` AutomaticSearch bool } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Views) List() ([]ViewListItem, error) { var query struct { View []ViewListItem `graphql:"searchDomains"` @@ -101,11 +110,13 @@ func (c *Views) List() ([]ViewListItem, error) { return viewsList, err } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example type ViewConnectionInput struct { RepositoryName graphql.String `json:"repositoryName"` Filter graphql.String `json:"filter"` } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Views) Create(name, description string, connections []ViewConnectionInput) error { var mutation struct { CreateView struct { @@ -123,6 +134,7 @@ func (c *Views) Create(name, description string, connections []ViewConnectionInp return c.client.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Views) Delete(name, reason string) error { _, err := c.Get(name) if err != nil { @@ -143,6 +155,7 @@ func (c *Views) Delete(name, reason string) error { return c.client.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Views) UpdateConnections(name string, connections []ViewConnectionInput) error { var mutation struct { View struct { @@ -158,6 +171,7 @@ func (c *Views) UpdateConnections(name string, connections []ViewConnectionInput return c.client.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Views) UpdateDescription(name string, description string) error { _, err := c.Get(name) if err != nil { @@ -179,6 +193,7 @@ func (c *Views) UpdateDescription(name string, description string) error { return c.client.Mutate(&mutation, variables) } +// Deprecated: Should no longer be used. https://github.com/CrowdStrike/logscale-go-api-client-example func (c *Views) UpdateAutomaticSearch(name string, automaticSearch bool) error { _, err := c.Get(name) if err != nil {