Code Monkey home page Code Monkey logo

go-sentry's Introduction

go-sentry Go Reference

Go library for accessing the Sentry Web API.

Installation

go-sentry is compatible with modern Go releases in module mode, with Go installed:

go get github.com/jianyuan/go-sentry/v2/sentry

Usage

import "github.com/jianyuan/go-sentry/v2/sentry"

Create a new Sentry client. Then, use the various services on the client to access different parts of the Sentry Web API. For example:

client := sentry.NewClient(nil)

// List all organizations
orgs, _, err := client.Organizations.List(ctx, nil)

Authentication

The library does not directly handle authentication. When creating a new client, pass an http.Client that can handle authentication for you. We recommend the oauth2 library. For example:

package main

import (
	"github.com/jianyuan/go-sentry/v2/sentry"
	"golang.org/x/oauth2"
)

func main() {
    ctx := context.Background()
    tokenSrc := oauth2.StaticTokenSource(
        &oauth2.Token{AccessToken: "YOUR-API-KEY"},
    )
    httpClient := oauth2.NewClient(ctx, tokenSrc)
    
    client := sentry.NewClient(httpClient)
    
    // List all organizations
    orgs, _, err := client.Organizations.List(ctx, nil)
}

Code structure

The code structure was inspired by google/go-github.

License

This library is distributed under the MIT License.

go-sentry's People

Contributors

agadzik avatar cameronhall avatar dandorman avatar danielpoonwj avatar emcfarlane avatar eugeniykurasov avatar fa93hws avatar javaadsnappcar avatar jianyuan avatar mced avatar merrington avatar mogagnon avatar mtanda avatar mvantellingen avatar nessex avatar pballandras avatar pondidum avatar qdegraaf avatar rabunkosar-dd avatar rcmachado avatar renovate[bot] avatar sbrudz avatar taj-p avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

go-sentry's Issues

Error: The terraform-provider-sentry_v0.12.3 plugin crashed!

Hello,

Got an error when running terraform plan since last Friday.
I'm getting this error when I try to import resources or data.

│ Error: Plugin did not respond
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin6.(*GRPCProvider).ReadResource call. The plugin logs may contain more
│ details.
╵

Stack trace from the terraform-provider-sentry_v0.12.3 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0xa6163a]

goroutine 56 [running]:
github.com/jianyuan/go-sentry/v2/sentry.CheckResponse(0xce2380?)
	github.com/jianyuan/go-sentry/[email protected]/sentry/sentry.go:355 +0x1a
github.com/jianyuan/terraform-provider-sentry/internal/sentryclient.(*Config).Client.func1(0xf0ce40?, 0x14e2de0?, 0xc000153500?, 0xf07380?)
	github.com/jianyuan/terraform-provider-sentry/internal/sentryclient/sentryclient.go:35 +0x2a
github.com/hashicorp/go-retryablehttp.(*Client).Do(0xc0004447e0, 0xc000420780)
	github.com/hashicorp/[email protected]/client.go:705 +0xcfc
github.com/hashicorp/go-retryablehttp.(*RoundTripper).RoundTrip(0xc00049a4b0, 0xc0003cc6c8?)
	github.com/hashicorp/[email protected]/roundtripper.go:47 +0x72
github.com/jianyuan/terraform-provider-sentry/internal/sentryclient.(*semaphoreTransport).RoundTrip(0xc000594240, 0xc000546000)
	github.com/jianyuan/terraform-provider-sentry/internal/sentryclient/sentryclient.go:79 +0x1f8
net/http.send(0xc000546000, {0xf07440, 0xc000594240}, {0x418401?, 0x0?, 0x0?})
	net/http/client.go:260 +0x606
net/http.(*Client).send(0xc000594270, 0xc000546000, {0x40fcde?, 0x7f308fa32cc0?, 0x0?})
	net/http/client.go:181 +0x98
net/http.(*Client).do(0xc000594270, 0xc000546000)
	net/http/client.go:724 +0x912
net/http.(*Client).Do(...)
	net/http/client.go:590
github.com/jianyuan/go-sentry/v2/sentry.(*Client).BareDo(0xa?, {0xf0cf20, 0xc0004b2620}, 0xc000546000?)
	github.com/jianyuan/go-sentry/[email protected]/sentry/sentry.go:254 +0x3e
github.com/jianyuan/go-sentry/v2/sentry.(*Client).Do(0xc0004389c0?, {0xf0cf20?, 0xc0004b2620?}, 0xc00003a258?, {0xc3ab60?, 0xc0000805a0})
	github.com/jianyuan/go-sentry/[email protected]/sentry/sentry.go:272 +0x68
github.com/jianyuan/go-sentry/v2/sentry.(*TeamsService).Get(0xc0004389e0, {0xf0cf20, 0xc0004b2620}, {0xc00025a1c0?, 0xc0003cce98?}, {0xc00025a0ca, 0x3})
	github.com/jianyuan/go-sentry/[email protected]/sentry/teams.go:63 +0x11d
github.com/jianyuan/terraform-provider-sentry/sentry.resourceSentryTeamRead({0xf0cf20, 0xc0004b2620}, 0xc000140400, {0xccbca0?, 0xc0004389c0})
	github.com/jianyuan/terraform-provider-sentry/sentry/resource_sentry_team.go:98 +0x32c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc0000dfa40, {0xf0ce78, 0xc0003883f0}, 0xd?, {0xccbca0, 0xc0004389c0})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:795 +0x11b
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0000dfa40, {0xf0ce78, 0xc0003883f0}, 0xc0002dde10, {0xccbca0, 0xc0004389c0})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:1089 +0x552
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc000011758, {0xf0ce78?, 0xc0003882a0?}, 0xc0004b0140)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:667 +0x48a
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ReadResource({{0xf13a40?, 0xc000011758?}}, {0xf0ce78?, 0xc0003882a0?}, 0xc0003b9300?)
	github.com/hashicorp/[email protected]/tf5to6server/tf5to6server.go:215 +0x225
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ReadResource(0xf0ceb0?, {0xf0ce78?, 0xc00011bd10?}, 0xc0003b9300)
	github.com/hashicorp/[email protected]/tf6muxserver/mux_server_ReadResource.go:35 +0x193
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ReadResource(0xc000269a40, {0xf0ce78?, 0xc00011a930?}, 0xc0002f0f00)
	github.com/hashicorp/[email protected]/tfprotov6/tf6server/server.go:776 +0x4c3
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadResource_Handler({0xd86200?, 0xc000269a40}, {0xf0ce78, 0xc00011a930}, 0xc0003d0980, 0x0)
	github.com/hashicorp/[email protected]/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:482 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000c1a00, {0xf0ce78, 0xc00011a8a0}, {0xf12500, 0xc000500000}, 0xc0005c0120, 0xc000388d50, 0x14a6788, 0x0)
	google.golang.org/[email protected]/server.go:1369 +0xe23
google.golang.org/grpc.(*Server).handleStream(0xc0000c1a00, {0xf12500, 0xc000500000}, 0xc0005c0120)
	google.golang.org/[email protected]/server.go:1780 +0x1016
google.golang.org/grpc.(*Server).serveStreams.func2.1()
	google.golang.org/[email protected]/server.go:1019 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 35
	google.golang.org/[email protected]/server.go:1030 +0x135

Error: The terraform-provider-sentry_v0.12.3 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

Operation failed: failed running terraform plan (exit 1)

Terraform version: 1.8.1
Sentry provider version: 0.12.3

Thanks for your time!

Metric alert has two types of response

When we create project alerts with integrations (for example slack) we are expected response like MetricAlert
(

type MetricAlert struct {
)

Here is method:

func (s *MetricAlertsService) Update(ctx context.Context, organizationSlug string, projectSlug string, alertRuleID string, params *MetricAlert) (*MetricAlert, *Response, error) {

Here is endpoint from sentry repository.
https://github.com/getsentry/sentry/blob/41f9103679d2669ab5e9b32a8e2b1970578e4f4e/src/sentry/incidents/endpoints/project_alert_rule_index.py#L112

New Major Release

Would it be possible to publish a new release? We are trying to take advantage of 1f63b22, but the last release was cut in October 2018. This release predates this commit, so we currently have to point to the current SHA in master which is non-ideal.

Introduce context.Context argument to all methods

Add context.Context argument to all methods.

Package context defines the Context type, which carries deadlines, cancellation signals, and other request-scoped values across API boundaries and between processes.

As this will be a breaking change, it would be a good idea to bump the major version of this library to v2.


Also, fixes #29

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/go.yaml
  • actions/checkout v4
  • actions/setup-go v5
gomod
go.mod
  • go 1.19
  • github.com/google/go-querystring v1.1.0
  • github.com/peterhellberg/link v1.2.0
  • github.com/stretchr/testify v1.9.0

  • Check this box to trigger a request for Renovate to run again on this repository

Support EventFrequencyCondition

Example rule condition for use with terraform-provider-sentry:

{
  id        = "sentry.rules.conditions.event_frequency.EventFrequencyCondition",
  interval  = "1h",
  value     = "10"
}

The interval and value parameters are currently ignored so Sentry errors out.

// RuleCondition represents the conditions for each rule.
// https://github.com/getsentry/sentry/blob/9.0.0/src/sentry/api/serializers/models/rule.py
type RuleCondition struct {
ID string `json:"id"`
Name string `json:"name"`
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.