Skip to content

Commit

Permalink
Merge pull request #42 from atlassian/cwood/cleanup
Browse files Browse the repository at this point in the history
Cleanup and fix badge
  • Loading branch information
cwood authored Sep 19, 2024
2 parents 3bb2fb7 + 6659374 commit 596f30f
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 40 deletions.
5 changes: 3 additions & 2 deletions README.mkd
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Go Sentry API
[![godoc](https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f676f6c616e672f6764646f3f7374617475732e737667 "Go Doc Reference")](https://godoc.org/github.com/atlassian/go-sentry-api) [![Build Status](https://travis-ci.org/atlassian/go-sentry-api.svg?branch=master)](https://travis-ci.org/atlassian/go-sentry-api)
[![Go Reference](https://pkg.go.dev/badge/github.com/atlassian/go-sentry-api.svg)](https://pkg.go.dev/github.com/atlassian/go-sentry-api)


This is a library that implements a client in go for the [sentry api](http://www.sentry.io/api/). It supports all the endpoints and can do a good bit. For a full reference you can check the godoc link above.

## Usage

### Initialization and Create New DSN Key
```go
import (
Expand Down Expand Up @@ -40,7 +41,7 @@ fmt.Printf(key.DSN.Secret)
go get github.com/atlassian/go-sentry-api
```
## Documentation
[![godoc](https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f676f6c616e672f6764646f3f7374617475732e737667 "Go Doc Reference")](https://godoc.org/github.com/atlassian/go-sentry-api)
[![Go Reference](https://pkg.go.dev/badge/github.com/atlassian/go-sentry-api.svg)](https://pkg.go.dev/github.com/atlassian/go-sentry-api)

## Tests
To run tests you can setup a local sentry instance via docker. There is a
Expand Down
10 changes: 5 additions & 5 deletions bulk.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/url"
)

//IssueBulkRequest is what should be used when bulk mutate issue
// IssueBulkRequest is what should be used when bulk mutate issue
type IssueBulkRequest struct {
Status *Status `json:"status,omitempty"`
IgnoreDuration *int `json:"ignoreDuration,omitempty"`
Expand All @@ -15,14 +15,14 @@ type IssueBulkRequest struct {
IsBookmarked *bool `json:"isBookmarked,omitempty"`
}

//IssueBulkResponse is what is returned when your mutation is done
// IssueBulkResponse is what is returned when your mutation is done
type IssueBulkResponse struct {
Status *Status `json:"status,omitempty"`
IsPublic *bool `json:"isPublic,omitempty"`
StatusDetails *map[string]string `json:"statusDetails,omitempty"`
}

//issueMutateArgs
// issueMutateArgs
type issueMutateArgs struct {
ID *[]string
Status *Status
Expand All @@ -41,7 +41,7 @@ func (i *issueMutateArgs) ToQueryString() string {
return query.Encode()
}

//BulkMutateIssues takes a list of ids and optional status to filter through
// BulkMutateIssues takes a list of ids and optional status to filter through
func (c *Client) BulkMutateIssues(o Organization, p Project, req IssueBulkRequest, issues *[]string, status *Status) (IssueBulkResponse, error) {
var issueBulkResponse IssueBulkResponse

Expand All @@ -56,7 +56,7 @@ func (c *Client) BulkMutateIssues(o Organization, p Project, req IssueBulkReques
return issueBulkResponse, err
}

//BulkDeleteIssues takes a list of IDs and will delete them
// BulkDeleteIssues takes a list of IDs and will delete them
func (c *Client) BulkDeleteIssues(o Organization, p Project, issues []string) error {
mutateQuery := &issueMutateArgs{
ID: &issues,
Expand Down
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (c *Client) doWithPagination(method, endpoint string, out, in interface{})
return c.sendGetLink(request, out)
}

//rawWithPagination is used when we need to get a raw URL vs a url we combine and comb with newrequest
// rawWithPagination is used when we need to get a raw URL vs a url we combine and comb with newrequest
func (c *Client) rawWithPagination(method, endpoint string, out, in interface{}) (*Link, error) {
request, err := c.rawRequest(method, endpoint, in)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Tag struct {
Key *string `json:"key,omitempty"`
}

//User is the user that was affected
// User is the user that was affected
type User struct {
Username *string `json:"username,omitempty"`
Email *string `json:"email,omitempty"`
Expand All @@ -31,7 +31,7 @@ type Entry struct {
Data json.RawMessage `json:"data,omitempty"`
}

//GetInterface will convert the entry into a go interface
// GetInterface will convert the entry into a go interface
func (e *Entry) GetInterface() (string, interface{}, error) {
var destination interface{}

Expand Down Expand Up @@ -90,14 +90,14 @@ func (c *Client) GetProjectEvent(o Organization, p Project, eventID string) (Eve
return event, err
}

//GetLatestEvent will fetch the latest event for a issue
// GetLatestEvent will fetch the latest event for a issue
func (c *Client) GetLatestEvent(i Issue) (Event, error) {
var event Event
err := c.do("GET", fmt.Sprintf("issues/%s/events/latest", *i.ID), &event, nil)
return event, err
}

//GetOldestEvent will fetch the latest event for a issue
// GetOldestEvent will fetch the latest event for a issue
func (c *Client) GetOldestEvent(i Issue) (Event, error) {
var event Event
err := c.do("GET", fmt.Sprintf("issues/%s/events/oldest", *i.ID), &event, nil)
Expand Down
10 changes: 5 additions & 5 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"
)

//File is used to create a new file for a release
// File is used to create a new file for a release
type File struct {
SHA1 string `json:"sha1,omitempty"`
Name string `json:"name,omitempty"`
Expand All @@ -20,7 +20,7 @@ type File struct {
Size int `json:"size,omitempty"`
}

//UploadReleaseFile will upload a file to release
// UploadReleaseFile will upload a file to release
func (c *Client) UploadReleaseFile(o Organization, p Project, r Release,
name string, buffer io.Reader, header string) (File, error) {
var file File
Expand Down Expand Up @@ -69,19 +69,19 @@ func (c *Client) DeleteReleaseFile(o Organization, p Project, r Release, f File)
nil, nil)
}

//UpdateReleaseFile will update just the name of the release file
// UpdateReleaseFile will update just the name of the release file
func (c *Client) UpdateReleaseFile(o Organization, p Project, r Release, f File) error {
return c.do("PUT", fmt.Sprintf("projects/%s/%s/releases/%s/files/%s", *o.Slug, *p.Slug, r.Version, f.ID), &f, &f)
}

//GetReleaseFiles will fetch all files in a release
// GetReleaseFiles will fetch all files in a release
func (c *Client) GetReleaseFiles(o Organization, p Project, r Release) ([]File, error) {
var files []File
err := c.do("GET", fmt.Sprintf("projects/%s/%s/releases/%s/files", *o.Slug, *p.Slug, r.Version), &files, nil)
return files, err
}

//GetReleaseFile will get the release file
// GetReleaseFile will get the release file
func (c *Client) GetReleaseFile(o Organization, p Project, r Release, id string) (File, error) {
var file File
err := c.do("GET", fmt.Sprintf("projects/%s/%s/releases/%s/files/%s", *o.Slug, *p.Slug, r.Version, id), &file, nil)
Expand Down
26 changes: 13 additions & 13 deletions issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type IssueStats struct {
ThirtyDays *[]Stat `json:"30d,omitempty"`
}

//IssueTagValue represents a tags value
// IssueTagValue represents a tags value
type IssueTagValue struct {
Count *int64 `json:"count,omitempty"`
FirstSeen *time.Time `json:"firstSeen,omitempty"`
Expand All @@ -51,13 +51,13 @@ type IssueTag struct {
TopValues []IssueTagValue `json:"topValues,omitempty"`
}

//Avatar is used for a users avatar
// Avatar is used for a users avatar
type Avatar struct {
AvatarType *string `json:"avatarType,omitempty"`
AvatarUUID *string `json:"avatarUuid,omitempty"`
}

//InternalUser is a user on sentry and not a external customer
// InternalUser is a user on sentry and not a external customer
type InternalUser struct {
AvatarURL *string `json:"avatarUrl,omitempty"`
DateJoined *time.Time `json:"dateJoined,omitempty"`
Expand All @@ -71,7 +71,7 @@ type InternalUser struct {
Username *string `json:"username,omitempty"`
}

//Activity is what current activity has happend on a issue
// Activity is what current activity has happend on a issue
type Activity struct {
Data *map[string]interface{} `json:"data,omitempty"`
DateCreated *time.Time `json:"dateCreated,omitempty"`
Expand Down Expand Up @@ -134,7 +134,7 @@ func (i *issueQuery) ToQueryString() string {
return query.Encode()
}

//GetIssues will fetch all issues for organization and project
// GetIssues will fetch all issues for organization and project
func (c *Client) GetIssues(o Organization, p Project, StatsPeriod *string, ShortIDLookup *bool, query *string) ([]Issue, *Link, error) {
var issues []Issue

Expand All @@ -149,54 +149,54 @@ func (c *Client) GetIssues(o Organization, p Project, StatsPeriod *string, Short
return issues, link, err
}

//GetIssue will fetch a issue by its ID as a string
// GetIssue will fetch a issue by its ID as a string
func (c *Client) GetIssue(id string) (Issue, error) {
var issue Issue
err := c.do("GET", fmt.Sprintf("issues/%s", id), &issue, nil)
return issue, err
}

//GetIssueHashes will fetch all hashes for a issue
// GetIssueHashes will fetch all hashes for a issue
func (c *Client) GetIssueHashes(i Issue) ([]Hash, *Link, error) {
var hashes []Hash
link, err := c.doWithPagination("GET", fmt.Sprintf("issues/%s/hashes", *i.ID), &hashes, nil)
return hashes, link, err
}

//GetIssueTags will fetch all tags for a issue
// GetIssueTags will fetch all tags for a issue
func (c *Client) GetIssueTags(i Issue) ([]IssueTag, *Link, error) {
var tags []IssueTag
link, err := c.doWithPagination("GET", fmt.Sprintf("issues/%s/tags", *i.ID), &tags, nil)
return tags, link, err
}

//GetIssueTag will fetch a tag used in a issue. Eg; environment, release, server
// GetIssueTag will fetch a tag used in a issue. Eg; environment, release, server
func (c *Client) GetIssueTag(i Issue, tagname string) (IssueTag, error) {
var tag IssueTag
err := c.do("GET", fmt.Sprintf("issues/%s/tags/%s", *i.ID, tagname), &tag, nil)
return tag, err
}

//GetIssueTagValues will fetch all values for a issues tag
// GetIssueTagValues will fetch all values for a issues tag
func (c *Client) GetIssueTagValues(i Issue, tag IssueTag) ([]IssueTagValue, *Link, error) {
var values []IssueTagValue
link, err := c.doWithPagination("GET", fmt.Sprintf("issues/%s/tags/%s/values", *i.ID, tag.Key), &values, nil)
return values, link, err
}

//GetIssueEvents will fetch all events for a issue
// GetIssueEvents will fetch all events for a issue
func (c *Client) GetIssueEvents(i Issue) ([]Event, *Link, error) {
var events []Event
link, err := c.doWithPagination("GET", fmt.Sprintf("issues/%s/events", *i.ID), &events, nil)
return events, link, err
}

//UpdateIssue will update status, assign to, hasseen, isbookmarked and issubscribed
// UpdateIssue will update status, assign to, hasseen, isbookmarked and issubscribed
func (c *Client) UpdateIssue(i Issue) error {
return c.do("PUT", fmt.Sprintf("issues/%s", *i.ID), &i, &i)
}

//DeleteIssue will delete an issue
// DeleteIssue will delete an issue
func (c *Client) DeleteIssue(i Issue) error {
return c.do("DELETE", fmt.Sprintf("issues/%s", *i.ID), nil, nil)
}
8 changes: 4 additions & 4 deletions keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type nameReq struct {
Name string `json:"name"`
}

//CreateClientKey creates a new client key for a project and org
// CreateClientKey creates a new client key for a project and org
func (c *Client) CreateClientKey(o Organization, p Project, name string) (Key, error) {
var key Key
req := &nameReq{
Expand All @@ -43,12 +43,12 @@ func (c *Client) CreateClientKey(o Organization, p Project, name string) (Key, e
return key, err
}

//DeleteClientKey deletes a client key for a project and org
// DeleteClientKey deletes a client key for a project and org
func (c *Client) DeleteClientKey(o Organization, p Project, k Key) error {
return c.do("DELETE", fmt.Sprintf("projects/%s/%s/keys/%s", *o.Slug, *p.Slug, k.ID), nil, nil)
}

//UpdateClientKey updates the name only of a key
// UpdateClientKey updates the name only of a key
func (c *Client) UpdateClientKey(o Organization, p Project, k Key, name string) (Key, error) {
var key Key
req := &nameReq{
Expand All @@ -58,7 +58,7 @@ func (c *Client) UpdateClientKey(o Organization, p Project, k Key, name string)
return key, err
}

//GetClientKeys fetches all client keys of the given project
// GetClientKeys fetches all client keys of the given project
func (c *Client) GetClientKeys(o Organization, p Project) ([]Key, error) {
var keys []Key
err := c.do("GET", fmt.Sprintf("projects/%s/%s/keys", *o.Slug, *p.Slug), &keys, nil)
Expand Down
8 changes: 4 additions & 4 deletions release.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,20 @@ func (c *Client) GetReleases(o Organization, p Project) ([]Release, *Link, error
return rel, link, err
}

//CreateRelease will create a new release for a project in a org
// CreateRelease will create a new release for a project in a org
func (c *Client) CreateRelease(o Organization, p Project, r NewRelease) (Release, error) {
var rel Release
err := c.do("POST", fmt.Sprintf("projects/%s/%s/releases", *o.Slug, *p.Slug), &rel, &r)
return rel, err
}

//UpdateRelease will update ref, url, started, released for a release.
//Version should not change.
// UpdateRelease will update ref, url, started, released for a release.
// Version should not change.
func (c *Client) UpdateRelease(o Organization, p Project, r Release) error {
return c.do("PUT", fmt.Sprintf("projects/%s/%s/releases/%s", *o.Slug, *p.Slug, r.Version), &r, &r)
}

//DeleteRelease will delete the release from your project
// DeleteRelease will delete the release from your project
func (c *Client) DeleteRelease(o Organization, p Project, r Release) error {
return c.do("DELETE", fmt.Sprintf("projects/%s/%s/releases/%s", *o.Slug, *p.Slug, r.Version), nil, nil)
}
4 changes: 2 additions & 2 deletions userfeedback.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ func NewUserFeedback(name, comments, email, eventID string) UserFeedback {
}
}

//SubmitUserFeedback is used when you want to submit feedback to a organizations project
// SubmitUserFeedback is used when you want to submit feedback to a organizations project
func (c *Client) SubmitUserFeedback(o Organization, p Project, u *UserFeedback) error {
return c.do("POST", fmt.Sprintf("projects/%s/%s/user-feedback", *o.Slug, *p.Slug), &u, &u)
}

//GetProjectUserFeedback is used to fetch all feedback given for a certain project
// GetProjectUserFeedback is used to fetch all feedback given for a certain project
func (c *Client) GetProjectUserFeedback(o Organization, p Project) ([]UserFeedback, *Link, error) {
var feedback []UserFeedback
link, err := c.doWithPagination("GET", fmt.Sprintf("projects/%s/%s/user-feedback", *o.Slug, *p.Slug), &feedback, nil)
Expand Down

0 comments on commit 596f30f

Please sign in to comment.