Documentation
¶
Overview ¶
Package appsignal is a client for AppSignal's public GraphQL API.
It wraps the API's organizations, apps, log sources, log views and log triggers in typed methods on Client, and exposes Client.Query and Client.Mutate for anything the typed methods do not cover yet.
Authentication ¶
Every request is authenticated with an AppSignal personal API token, which you can create under Personal settings in the AppSignal dashboard. Pass it to NewClient and it is sent as a "token" query parameter on each request:
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
viewer, err := client.GetViewer(context.Background())
Base URL ¶
An empty host means the public endpoint, HostURL:
client := appsignal.NewClient("", token)
Pass a host to send requests somewhere else.
HTTP client ¶
Requests go through http.DefaultClient unless you replace Client.HTTPClient, which is where you configure timeouts, proxies or a transport that retries:
client := appsignal.NewClient("", token)
client.HTTPClient = &http.Client{Timeout: 10 * time.Second}
Every method takes a context.Context as well, so individual calls can carry their own deadline or be cancelled.
Errors ¶
The API answers with HTTP 200 and an "errors" array when a request is well formed but wrong, for example when an app ID does not exist. Those come back as Errors. Responses with any other status come back as HTTPError. Use errors.As to tell them apart:
_, err := client.GetApp(ctx, "does-not-exist")
var gqlErrs appsignal.Errors
var httpErr *appsignal.HTTPError
switch {
case errors.As(err, &gqlErrs):
fmt.Println("api error:", gqlErrs)
case errors.As(err, &httpErr):
fmt.Println("http status:", httpErr.StatusCode)
}
Lookups of a single object return a nil pointer and a nil error when nothing matches, so check both.
Index ¶
- Constants
- type App
- type Client
- func (c *Client) CreateApp(ctx context.Context, input CreateAppInput) (*App, error)
- func (c *Client) CreateAppLogSource(ctx context.Context, input CreateAppLogSourceInput) (*LogSource, error)
- func (c *Client) CreateAppLogTrigger(ctx context.Context, input CreateAppLogTriggerInput) (*LogTrigger, error)
- func (c *Client) CreateAppLogView(ctx context.Context, input CreateAppLogViewInput) (*LogView, error)
- func (c *Client) DeleteApp(ctx context.Context, appID string) (*App, error)
- func (c *Client) DeleteAppLogSource(ctx context.Context, input DeleteAppLogSourceInput) (*LogSource, error)
- func (c *Client) DeleteAppLogTrigger(ctx context.Context, input DeleteAppLogTriggerInput) (*LogTrigger, error)
- func (c *Client) DeleteAppLogView(ctx context.Context, input DeleteAppLogViewInput) (*LogView, error)
- func (c *Client) GetApp(ctx context.Context, id string) (*App, error)
- func (c *Client) GetAppLogSource(ctx context.Context, appID string, logSourceID string) (*LogSource, error)
- func (c *Client) GetAppLogSources(ctx context.Context, appID string) ([]LogSource, error)
- func (c *Client) GetAppLogTriggers(ctx context.Context, appID string) ([]LogTrigger, error)
- func (c *Client) GetAppLogView(ctx context.Context, appID string, logViewID string) (*LogView, error)
- func (c *Client) GetAppLogViews(ctx context.Context, appID string) ([]LogView, error)
- func (c *Client) GetAppNotifiers(ctx context.Context, appID string) ([]Notifier, error)
- func (c *Client) GetOrganization(ctx context.Context, slug string) (*Organization, error)
- func (c *Client) GetOrganizationApps(ctx context.Context, slug string) ([]App, error)
- func (c *Client) GetViewer(ctx context.Context) (*Viewer, error)
- func (c *Client) Mutate(ctx context.Context, mutation string, variables map[string]any, out any) error
- func (c *Client) Query(ctx context.Context, query string, variables map[string]any, out any) error
- func (c *Client) UpdateAppLogSource(ctx context.Context, input UpdateAppLogSourceInput) (*LogSource, error)
- func (c *Client) UpdateAppLogTrigger(ctx context.Context, input UpdateAppLogTriggerInput) (*LogTrigger, error)
- func (c *Client) UpdateAppLogView(ctx context.Context, input UpdateAppLogViewInput) (*LogView, error)
- type CreateAppInput
- type CreateAppLogSourceInput
- type CreateAppLogTriggerInput
- type CreateAppLogViewInput
- type DeleteAppLogSourceInput
- type DeleteAppLogTriggerInput
- type DeleteAppLogViewInput
- type Error
- type Errors
- type HTTPError
- type LogSource
- type LogSourceFormat
- type LogTrigger
- type LogTriggerActionType
- type LogTriggerNotificationOption
- type LogView
- type Notifier
- type Organization
- type UpdateAppLogSourceInput
- type UpdateAppLogTriggerInput
- type UpdateAppLogViewInput
- type Viewer
Examples ¶
- Client.CreateApp
- Client.CreateAppLogSource
- Client.CreateAppLogTrigger
- Client.CreateAppLogView
- Client.DeleteApp
- Client.DeleteAppLogSource
- Client.DeleteAppLogTrigger
- Client.DeleteAppLogView
- Client.GetApp
- Client.GetAppLogSource
- Client.GetAppLogSources
- Client.GetAppLogTriggers
- Client.GetAppLogView
- Client.GetAppLogViews
- Client.GetAppNotifiers
- Client.GetOrganization
- Client.GetOrganizationApps
- Client.GetViewer
- Client.Mutate
- Client.Query
- Client.UpdateAppLogSource
- Client.UpdateAppLogTrigger
- Client.UpdateAppLogView
- Errors.Error
- HTTPError.Error
- NewClient
Constants ¶
const HostURL string = "https://appsignal.com/graphql"
const Version = "0.2.0" // x-release-please-version
Version is the semantic version of this client library. The trailing comment lets release-please rewrite the literal when it cuts a release; keep it.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
func NewClient ¶
NewClient returns a client that talks to the AppSignal GraphQL API using the given personal API token. Pass an empty host to use the default endpoint.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
// An empty host means the public endpoint, appsignal.HostURL. Pass a real
// host to point the client at a test server instead.
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
viewer, err := client.GetViewer(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Println(viewer.Email)
}
Output:
func (*Client) CreateApp ¶
CreateApp adds a new app to an organization and returns the created app.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
app, err := client.CreateApp(context.Background(), appsignal.CreateAppInput{
OrganizationSlug: "my-organization",
Name: "my-app",
Environment: "production",
})
if err != nil {
log.Fatal(err)
}
fmt.Println(app.ID)
}
Output:
func (*Client) CreateAppLogSource ¶
func (c *Client) CreateAppLogSource(ctx context.Context, input CreateAppLogSourceInput) (*LogSource, error)
CreateAppLogSource adds a new log source to an app and returns the created log source, including the key used to ship logs to it.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
source, err := client.CreateAppLogSource(context.Background(), appsignal.CreateAppLogSourceInput{
AppID: "6aad24d1ba6bc351255e7cb5",
Name: "my-log-source",
Type: "custom",
Fmt: appsignal.LogSourceFormatJSON,
})
if err != nil {
log.Fatal(err)
}
// The key is what you ship log lines with.
fmt.Println(source.ID, source.Key)
}
Output:
func (*Client) CreateAppLogTrigger ¶
func (c *Client) CreateAppLogTrigger(ctx context.Context, input CreateAppLogTriggerInput) (*LogTrigger, error)
CreateAppLogTrigger adds a new log trigger to an app and returns the created log trigger. Leave the optional input fields nil to let the API pick defaults.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
// The optional fields are pointers and slices; leave them nil to let the
// API pick its own defaults.
description := "Alert when the error log fills up"
notificationOptions := appsignal.NotificationOptionNthInHour
notificationTriggerValue := int32(10)
trigger, err := client.CreateAppLogTrigger(context.Background(), appsignal.CreateAppLogTriggerInput{
AppID: "6aad24d1ba6bc351255e7cb5",
Name: "Too many errors",
Query: "level:error",
Description: &description,
NotificationOptions: ¬ificationOptions,
NotificationTriggerValue: ¬ificationTriggerValue,
SourceIDs: []string{"6aad24d1ba6bc351255e7cba"},
NotifierIDs: []string{"6aad24d1ba6bc351255e7cbd"},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(trigger.ID)
}
Output:
func (*Client) CreateAppLogView ¶
func (c *Client) CreateAppLogView(ctx context.Context, input CreateAppLogViewInput) (*LogView, error)
CreateAppLogView adds a new log view to an app and returns the created log view. Leave the optional input fields nil to let the API pick defaults.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
// The optional fields are pointers and slices; leave them nil to let the
// API pick its own defaults.
query := "level:error"
view, err := client.CreateAppLogView(context.Background(), appsignal.CreateAppLogViewInput{
AppID: "6aad24d1ba6bc351255e7cb5",
Name: "Errors",
Query: &query,
SourceIDs: []string{"6aad24d1ba6bc351255e7cba"},
})
if err != nil {
log.Fatal(err)
}
fmt.Println(view.ID)
}
Output:
func (*Client) DeleteApp ¶
DeleteApp removes an app and returns the app as it was just before deletion.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
// The returned app is the one that was just deleted.
app, err := client.DeleteApp(context.Background(), "6aad24d1ba6bc351255e7cb5")
if err != nil {
log.Fatal(err)
}
fmt.Println("deleted", app.Name)
}
Output:
func (*Client) DeleteAppLogSource ¶
func (c *Client) DeleteAppLogSource(ctx context.Context, input DeleteAppLogSourceInput) (*LogSource, error)
DeleteAppLogSource removes a log source from an app and returns the log source as it was just before deletion.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
source, err := client.DeleteAppLogSource(context.Background(), appsignal.DeleteAppLogSourceInput{
AppID: "6aad24d1ba6bc351255e7cb5",
LogSourceID: "6aad24d1ba6bc351255e7cba",
})
if err != nil {
log.Fatal(err)
}
fmt.Println("deleted", source.Name)
}
Output:
func (*Client) DeleteAppLogTrigger ¶
func (c *Client) DeleteAppLogTrigger(ctx context.Context, input DeleteAppLogTriggerInput) (*LogTrigger, error)
DeleteAppLogTrigger removes a log trigger from an app and returns the log trigger as it was just before deletion.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
trigger, err := client.DeleteAppLogTrigger(context.Background(), appsignal.DeleteAppLogTriggerInput{
AppID: "6aad24d1ba6bc351255e7cb5",
LogTriggerID: "6aad24d1ba6bc351255e7cbc",
})
if err != nil {
log.Fatal(err)
}
fmt.Println("deleted", trigger.Name)
}
Output:
func (*Client) DeleteAppLogView ¶
func (c *Client) DeleteAppLogView(ctx context.Context, input DeleteAppLogViewInput) (*LogView, error)
DeleteAppLogView removes a log view from an app and returns the log view as it was just before deletion.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
view, err := client.DeleteAppLogView(context.Background(), appsignal.DeleteAppLogViewInput{
AppID: "6aad24d1ba6bc351255e7cb5",
LogViewID: "6aad24d1ba6bc351255e7cbb",
})
if err != nil {
log.Fatal(err)
}
fmt.Println("deleted", view.Name)
}
Output:
func (*Client) GetApp ¶
GetApp looks up a single app by its ID. It returns a nil app when no app with that ID exists.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
app, err := client.GetApp(context.Background(), "6aad24d1ba6bc351255e7cb5")
if err != nil {
log.Fatal(err)
}
if app == nil {
log.Fatal("no app with that ID")
}
fmt.Println(app.Name, app.Environment)
}
Output:
func (*Client) GetAppLogSource ¶
func (c *Client) GetAppLogSource(ctx context.Context, appID string, logSourceID string) (*LogSource, error)
GetAppLogSource looks up a single log source of an app by its ID. It returns a nil log source when the app has no log source with that ID.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
source, err := client.GetAppLogSource(context.Background(),
"6aad24d1ba6bc351255e7cb5", "6aad24d1ba6bc351255e7cba")
if err != nil {
log.Fatal(err)
}
if source == nil {
log.Fatal("no log source with that ID")
}
fmt.Println(source.Name, source.Fmt)
}
Output:
func (*Client) GetAppLogSources ¶
GetAppLogSources lists every log source of an app.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
sources, err := client.GetAppLogSources(context.Background(), "6aad24d1ba6bc351255e7cb5")
if err != nil {
log.Fatal(err)
}
for _, source := range sources {
fmt.Println(source.ID, source.Name, source.Fmt)
}
}
Output:
func (*Client) GetAppLogTriggers ¶
GetAppLogTriggers lists every log trigger of an app.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
triggers, err := client.GetAppLogTriggers(context.Background(), "6aad24d1ba6bc351255e7cb5")
if err != nil {
log.Fatal(err)
}
for _, trigger := range triggers {
fmt.Println(trigger.ID, trigger.Name, trigger.Query)
}
}
Output:
func (*Client) GetAppLogView ¶
func (c *Client) GetAppLogView(ctx context.Context, appID string, logViewID string) (*LogView, error)
GetAppLogView looks up a single log view of an app by its ID. It returns a nil log view when the app has no log view with that ID.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
view, err := client.GetAppLogView(context.Background(),
"6aad24d1ba6bc351255e7cb5", "6aad24d1ba6bc351255e7cbb")
if err != nil {
log.Fatal(err)
}
if view == nil {
log.Fatal("no log view with that ID")
}
fmt.Println(view.Name, view.Query)
}
Output:
func (*Client) GetAppLogViews ¶
GetAppLogViews lists every log view of an app.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
views, err := client.GetAppLogViews(context.Background(), "6aad24d1ba6bc351255e7cb5")
if err != nil {
log.Fatal(err)
}
for _, view := range views {
fmt.Println(view.ID, view.Name, view.Query)
}
}
Output:
func (*Client) GetAppNotifiers ¶
GetAppNotifiers lists the notifiers configured for an app. Their IDs are what you pass when attaching notifiers to a log trigger.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
notifiers, err := client.GetAppNotifiers(context.Background(), "6aad24d1ba6bc351255e7cb5")
if err != nil {
log.Fatal(err)
}
// These IDs are what you pass as NotifierIDs on a log trigger.
for _, notifier := range notifiers {
fmt.Println(notifier.ID, notifier.Name)
}
}
Output:
func (*Client) GetOrganization ¶
GetOrganization looks up a single organization by its slug. It returns a nil organization when no organization with that slug exists.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
organization, err := client.GetOrganization(context.Background(), "my-organization")
if err != nil {
log.Fatal(err)
}
if organization == nil {
log.Fatal("no organization with that slug")
}
fmt.Println(organization.ID, organization.Name)
}
Output:
func (*Client) GetOrganizationApps ¶
GetOrganizationApps lists every app belonging to the organization with the given slug.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
apps, err := client.GetOrganizationApps(context.Background(), "my-organization")
if err != nil {
log.Fatal(err)
}
for _, app := range apps {
fmt.Println(app.ID, app.Name, app.Environment)
}
}
Output:
func (*Client) GetViewer ¶
GetViewer returns the user that the client's API token belongs to. It is a handy way to check that a token works.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
// A quick way to check that a token is valid.
viewer, err := client.GetViewer(context.Background())
if err != nil {
log.Fatal(err)
}
if viewer == nil {
log.Fatal("token does not belong to a user")
}
fmt.Println(viewer.Name, viewer.Email)
}
Output:
func (*Client) Mutate ¶
func (c *Client) Mutate(ctx context.Context, mutation string, variables map[string]any, out any) error
Mutate sends a GraphQL mutation to the API. It behaves exactly like Query and exists to make calling code read more clearly.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
const mutation = `
mutation CreateApp($organizationSlug: String!, $name: String!, $environment: String!) {
createApp(organizationSlug: $organizationSlug, name: $name, environment: $environment) {
id
}
}
`
var out struct {
App struct {
ID string `json:"id"`
} `json:"createApp"`
}
variables := map[string]any{
"organizationSlug": "my-organization",
"name": "my-app",
"environment": "production",
}
if err := client.Mutate(context.Background(), mutation, variables, &out); err != nil {
log.Fatal(err)
}
fmt.Println(out.App.ID)
}
Output:
func (*Client) Query ¶
Query sends a GraphQL query to the API and decodes the "data" field of the response into out. Pass nil for out to ignore the response body. It returns an *HTTPError for non-200 responses without GraphQL errors, and Errors when the API reports GraphQL errors.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
// Any query the typed helpers do not cover can be sent by hand.
const query = `
query GetAppName($id: String!) {
app(id: $id) {
name
}
}
`
var out struct {
App struct {
Name string `json:"name"`
} `json:"app"`
}
variables := map[string]any{"id": "6aad24d1ba6bc351255e7cb5"}
if err := client.Query(context.Background(), query, variables, &out); err != nil {
log.Fatal(err)
}
fmt.Println(out.App.Name)
}
Output:
func (*Client) UpdateAppLogSource ¶
func (c *Client) UpdateAppLogSource(ctx context.Context, input UpdateAppLogSourceInput) (*LogSource, error)
UpdateAppLogSource changes the name and format of an existing log source and returns the updated log source. Both fields are required, so pass the current value for anything you do not want to change.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
// Name and Fmt are both required, so pass the current value for whichever
// one you are not changing.
source, err := client.UpdateAppLogSource(context.Background(), appsignal.UpdateAppLogSourceInput{
AppID: "6aad24d1ba6bc351255e7cb5",
LogSourceID: "6aad24d1ba6bc351255e7cba",
Name: "my-renamed-log-source",
Fmt: appsignal.LogSourceFormatLogfmt,
})
if err != nil {
log.Fatal(err)
}
fmt.Println(source.Name, source.Fmt)
}
Output:
func (*Client) UpdateAppLogTrigger ¶
func (c *Client) UpdateAppLogTrigger(ctx context.Context, input UpdateAppLogTriggerInput) (*LogTrigger, error)
UpdateAppLogTrigger changes an existing log trigger and returns the updated log trigger. Only the fields you set on the input are sent; the rest stay as they are.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
// Only the fields that are set get sent, so this widens the query and
// leaves the name and notifiers alone.
query := "level:error OR level:fatal"
trigger, err := client.UpdateAppLogTrigger(context.Background(), appsignal.UpdateAppLogTriggerInput{
AppID: "6aad24d1ba6bc351255e7cb5",
LogTriggerID: "6aad24d1ba6bc351255e7cbc",
Query: &query,
})
if err != nil {
log.Fatal(err)
}
fmt.Println(trigger.Query)
}
Output:
func (*Client) UpdateAppLogView ¶
func (c *Client) UpdateAppLogView(ctx context.Context, input UpdateAppLogViewInput) (*LogView, error)
UpdateAppLogView changes an existing log view and returns the updated log view. Only the fields you set on the input are sent; the rest stay as they are.
Example ¶
package main
import (
"context"
"fmt"
"log"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
// Only the fields that are set get sent, so this renames the view and
// leaves its query and columns alone.
name := "Errors and worse"
view, err := client.UpdateAppLogView(context.Background(), appsignal.UpdateAppLogViewInput{
AppID: "6aad24d1ba6bc351255e7cb5",
LogViewID: "6aad24d1ba6bc351255e7cbb",
Name: &name,
})
if err != nil {
log.Fatal(err)
}
fmt.Println(view.Name)
}
Output:
type CreateAppInput ¶
type CreateAppLogSourceInput ¶
type CreateAppLogSourceInput struct {
AppID string `json:"appId"`
Fmt LogSourceFormat `json:"fmt"`
Name string `json:"name"`
Type string `json:"type"`
}
type CreateAppLogTriggerInput ¶
type CreateAppLogTriggerInput struct {
AppID string `json:"appId"`
Name string `json:"name"`
Query string `json:"query"`
Description *string `json:"description,omitempty"`
NotificationOptions *LogTriggerNotificationOption `json:"notificationOptions,omitempty"`
NotificationTriggerValue *int32 `json:"notificationTriggerValue,omitempty"`
SourceIDs []string `json:"sourceIds,omitempty"`
NotifierIDs []string `json:"notifierIds,omitempty"`
}
type CreateAppLogViewInput ¶
type DeleteAppLogSourceInput ¶
type DeleteAppLogViewInput ¶
type Errors ¶
type Errors []Error
func (Errors) Error ¶
Error joins all GraphQL error messages into a single semicolon-separated string.
Example ¶
package main
import (
"context"
"errors"
"fmt"
"os"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", os.Getenv("APPSIGNAL_API_TOKEN"))
_, err := client.GetApp(context.Background(), "not-a-valid-id")
// The API answers with 200 and a list of GraphQL errors.
var gqlErrs appsignal.Errors
if errors.As(err, &gqlErrs) {
// Error() joins every message with "; ".
fmt.Println(gqlErrs.Error())
for _, gqlErr := range gqlErrs {
fmt.Println(gqlErr.Message)
}
}
}
Output:
type HTTPError ¶
func (*HTTPError) Error ¶
Error describes the unexpected HTTP status, including the response body when there is one.
Example ¶
package main
import (
"context"
"errors"
"fmt"
appsignal "github.com/Drieam/appsignal-client-go"
)
func main() {
client := appsignal.NewClient("", "not-a-real-token")
_, err := client.GetViewer(context.Background())
// A bad token gets a non-200 response with no GraphQL errors in it.
var httpErr *appsignal.HTTPError
if errors.As(err, &httpErr) {
// The message carries the status and the response body.
fmt.Println(httpErr.Error())
fmt.Println(httpErr.StatusCode)
}
}
Output:
type LogSource ¶
type LogSource struct {
ID string `json:"id"`
Name string `json:"name"`
Key string `json:"key"`
Type string `json:"type"`
Fmt LogSourceFormat `json:"fmt"`
}
type LogSourceFormat ¶
type LogSourceFormat string
LogSourceFormat is the log line format of a log source. It maps onto the SourceFormatEnum GraphQL enum.
const ( LogSourceFormatPlaintext LogSourceFormat = "PLAINTEXT" LogSourceFormatLogfmt LogSourceFormat = "LOGFMT" LogSourceFormatJSON LogSourceFormat = "JSON" LogSourceFormatAutodetect LogSourceFormat = "AUTODETECT" )
type LogTrigger ¶
type LogTrigger struct {
ID string `json:"id"`
Name string `json:"name"`
Query string `json:"query"`
SourceIDs []string `json:"sourceIds"`
ActionType LogTriggerActionType `json:"actionType"`
Description string `json:"description"`
NotificationOptions LogTriggerNotificationOption `json:"notificationOptions"`
NotificationTriggerValue int32 `json:"notificationTriggerValue"`
Order int32 `json:"order"`
Notifiers []Notifier `json:"notifiers"`
}
func (*LogTrigger) UnmarshalJSON ¶
func (t *LogTrigger) UnmarshalJSON(data []byte) error
UnmarshalJSON decodes a log trigger, turning nulls from the API into zero values and empty slices.
type LogTriggerActionType ¶
type LogTriggerActionType string
LogTriggerActionType is the action a log trigger performs when it matches.
const ( ActionTypeTrigger LogTriggerActionType = "TRIGGER" ActionTypeFilter LogTriggerActionType = "FILTER" ActionTypeMetrics LogTriggerActionType = "METRICS" )
type LogTriggerNotificationOption ¶
type LogTriggerNotificationOption string
LogTriggerNotificationOption controls how often a log trigger notifies.
const ( NotificationOptionAlways LogTriggerNotificationOption = "ALWAYS" NotificationOptionNever LogTriggerNotificationOption = "NEVER" NotificationOptionFirstInDeploy LogTriggerNotificationOption = "FIRST_IN_DEPLOY" NotificationOptionFirstAfterClose LogTriggerNotificationOption = "FIRST_AFTER_CLOSE" NotificationOptionNthInHour LogTriggerNotificationOption = "NTH_IN_HOUR" NotificationOptionNthInDay LogTriggerNotificationOption = "NTH_IN_DAY" )
type LogView ¶
type LogView struct {
ID string `json:"id"`
Name string `json:"name"`
Query string `json:"query"`
Columns []string `json:"columns"`
LineHeight string `json:"lineHeight"`
SourceIDs []string `json:"sourceIds"`
}
func (*LogView) UnmarshalJSON ¶
UnmarshalJSON decodes a log view, turning nulls from the API into empty strings and empty slices.
type Organization ¶
type UpdateAppLogSourceInput ¶
type UpdateAppLogSourceInput struct {
AppID string `json:"appId"`
Fmt LogSourceFormat `json:"fmt"`
LogSourceID string `json:"logSourceId"`
Name string `json:"name"`
}
type UpdateAppLogTriggerInput ¶
type UpdateAppLogTriggerInput struct {
AppID string `json:"appId"`
LogTriggerID string `json:"logTriggerId"`
Name *string `json:"name,omitempty"`
Query *string `json:"query,omitempty"`
Description *string `json:"description,omitempty"`
NotificationOptions *LogTriggerNotificationOption `json:"notificationOptions,omitempty"`
NotificationTriggerValue *int32 `json:"notificationTriggerValue,omitempty"`
SourceIDs []string `json:"sourceIds,omitempty"`
NotifierIDs []string `json:"notifierIds,omitempty"`
}
type UpdateAppLogViewInput ¶
type UpdateAppLogViewInput struct {
AppID string `json:"appId"`
LogViewID string `json:"logViewId"`
Name *string `json:"name,omitempty"`
Query *string `json:"query,omitempty"`
Columns []string `json:"columns,omitempty"`
LineHeight *string `json:"lineHeight,omitempty"`
SourceIDs []string `json:"sourceIds,omitempty"`
}