Skip to content

Commit 0c54a08

Browse files
committed
Merge remote-tracking branch 'upstream/main' into marten-2024-06-sync-with-upstream
2 parents 163f36c + 954549e commit 0c54a08

12 files changed

+372
-93
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.19
55
require (
66
github.com/google/go-querystring v1.1.0
77
github.com/peterhellberg/link v1.2.0
8-
github.com/stretchr/testify v1.8.4
8+
github.com/stretchr/testify v1.9.0
99
)
1010

1111
require (

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
1010
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
1111
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
1212
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
13+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
14+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
1315
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
1416
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
1517
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

sentry/metric_alerts.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type MetricAlert struct {
2020
TimeWindow *float64 `json:"timeWindow,omitempty"`
2121
ThresholdType *int `json:"thresholdType,omitempty"`
2222
ResolveThreshold *float64 `json:"resolveThreshold,omitempty"`
23+
ComparisonDelta *float64 `json:"comparisonDelta,omitempty"`
2324
Triggers []*MetricAlertTrigger `json:"triggers,omitempty"`
2425
Projects []string `json:"projects,omitempty"`
2526
Owner *string `json:"owner,omitempty"`

sentry/organization_integrations.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package sentry
22

33
import (
44
"context"
5+
"encoding/json"
56
"fmt"
67
"time"
78
)
@@ -17,7 +18,7 @@ type OrganizationIntegrationProvider struct {
1718
}
1819

1920
// IntegrationConfigData for defining integration-specific configuration data.
20-
type IntegrationConfigData map[string]interface{}
21+
type IntegrationConfigData map[string]json.RawMessage
2122

2223
// OrganizationIntegration represents an integration added for the organization.
2324
// https://github.com/getsentry/sentry/blob/22.7.0/src/sentry/api/serializers/models/integration.py#L93
@@ -33,11 +34,11 @@ type OrganizationIntegration struct {
3334
Provider OrganizationIntegrationProvider `json:"provider"`
3435

3536
// https://github.com/getsentry/sentry/blob/22.7.0/src/sentry/api/serializers/models/integration.py#L138
36-
ConfigData *IntegrationConfigData `json:"configData"`
37-
ExternalId string `json:"externalId"`
38-
OrganizationId int `json:"organizationId"`
39-
OrganizationIntegrationStatus string `json:"organizationIntegrationStatus"`
40-
GracePeriodEnd *time.Time `json:"gracePeriodEnd"`
37+
ConfigData json.RawMessage `json:"configData"`
38+
ExternalId string `json:"externalId"`
39+
OrganizationId int `json:"organizationId"`
40+
OrganizationIntegrationStatus string `json:"organizationIntegrationStatus"`
41+
GracePeriodEnd *time.Time `json:"gracePeriodEnd"`
4142
}
4243

4344
// OrganizationIntegrationsService provides methods for accessing Sentry organization integrations API endpoints.
@@ -88,7 +89,7 @@ func (s *OrganizationIntegrationsService) Get(ctx context.Context, organizationS
8889
return integration, resp, nil
8990
}
9091

91-
type UpdateConfigOrganizationIntegrationsParams = IntegrationConfigData
92+
type UpdateConfigOrganizationIntegrationsParams = json.RawMessage
9293

9394
// UpdateConfig - update configData for organization integration.
9495
// https://github.com/getsentry/sentry/blob/22.7.0/src/sentry/api/endpoints/integrations/organization_integrations/details.py#L94-L102

sentry/organization_integrations_test.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func TestOrganizationIntegrationsService_List(t *testing.T) {
8181
"stacktrace-link",
8282
},
8383
},
84-
ConfigData: &IntegrationConfigData{},
84+
ConfigData: json.RawMessage("{}"),
8585
ExternalId: "87654321",
8686
OrganizationId: 2,
8787
OrganizationIntegrationStatus: "active",
@@ -181,15 +181,15 @@ func TestOrganizationIntegrationsService_Get(t *testing.T) {
181181
"incident-management",
182182
},
183183
},
184-
ConfigData: &IntegrationConfigData{
185-
"service_table": []interface{}{
186-
map[string]interface{}{
187-
"service": "testing123",
188-
"integration_key": "abc123xyz",
189-
"id": json.Number("22222"),
190-
},
191-
},
192-
},
184+
ConfigData: json.RawMessage(`{
185+
"service_table": [
186+
{
187+
"service": "testing123",
188+
"integration_key": "abc123xyz",
189+
"id": 22222
190+
}
191+
]
192+
}`),
193193
ExternalId: "999999",
194194
OrganizationId: 2,
195195
OrganizationIntegrationStatus: "active",
@@ -207,20 +207,20 @@ func TestOrganizationIntegrationsService_UpdateConfig(t *testing.T) {
207207
w.Header().Set("Content-Type", "application/json")
208208
})
209209

210-
updateConfigOrganizationIntegrationsParams := UpdateConfigOrganizationIntegrationsParams{
211-
"service_table": []interface{}{
212-
map[string]interface{}{
213-
"service": "testing123",
210+
updateConfigOrganizationIntegrationsParams := UpdateConfigOrganizationIntegrationsParams(`{
211+
"service_table": [
212+
{
213+
"service": "testing123",
214214
"integration_key": "abc123xyz",
215-
"id": json.Number("22222"),
215+
"id": 22222
216216
},
217-
map[string]interface{}{
218-
"service": "testing456",
217+
{
218+
"service": "testing456",
219219
"integration_key": "efg456lmn",
220-
"id": "",
221-
},
222-
},
223-
}
220+
"id": ""
221+
}
222+
]
223+
}`)
224224
ctx := context.Background()
225225
resp, err := client.OrganizationIntegrations.UpdateConfig(ctx, "the-interstellar-jurisdiction", "456789", &updateConfigOrganizationIntegrationsParams)
226226
assert.NoError(t, err)

sentry/organization_projects.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package sentry
2+
3+
import (
4+
"context"
5+
"fmt"
6+
)
7+
8+
type OrganizationProjectsService service
9+
10+
type ListOrganizationProjectsParams struct {
11+
ListCursorParams
12+
13+
Options string `url:"options,omitempty"`
14+
Query string `url:"query,omitempty"`
15+
}
16+
17+
// List an Organization's Projects
18+
// https://docs.sentry.io/api/organizations/list-an-organizations-projects/
19+
func (s *OrganizationProjectsService) List(ctx context.Context, organizationSlug string, params *ListOrganizationProjectsParams) ([]*Project, *Response, error) {
20+
u := fmt.Sprintf("0/organizations/%v/projects/", organizationSlug)
21+
u, err := addQuery(u, params)
22+
if err != nil {
23+
return nil, nil, err
24+
}
25+
26+
req, err := s.client.NewRequest("GET", u, nil)
27+
if err != nil {
28+
return nil, nil, err
29+
}
30+
31+
projects := []*Project{}
32+
resp, err := s.client.Do(ctx, req, &projects)
33+
if err != nil {
34+
return nil, resp, err
35+
}
36+
return projects, resp, nil
37+
}

sentry/project_keys.go

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,49 @@ type ProjectKeyDSN struct {
2020
CSP string `json:"csp"`
2121
Security string `json:"security"`
2222
Minidump string `json:"minidump"`
23+
NEL string `json:"nel"`
24+
Unreal string `json:"unreal"`
2325
CDN string `json:"cdn"`
26+
Crons string `json:"crons"`
27+
}
28+
29+
type ProjectKeyDynamicSDKLoaderOptions struct {
30+
HasReplay bool `json:"hasReplay"`
31+
HasPerformance bool `json:"hasPerformance"`
32+
HasDebugFiles bool `json:"hasDebug"`
2433
}
2534

2635
// ProjectKey represents a client key bound to a project.
2736
// https://github.com/getsentry/sentry/blob/9.0.0/src/sentry/api/serializers/models/project_key.py
2837
type ProjectKey struct {
29-
ID string `json:"id"`
30-
Name string `json:"name"`
31-
Label string `json:"label"`
32-
Public string `json:"public"`
33-
Secret string `json:"secret"`
34-
ProjectID json.Number `json:"projectId"`
35-
IsActive bool `json:"isActive"`
36-
RateLimit *ProjectKeyRateLimit `json:"rateLimit"`
37-
DSN ProjectKeyDSN `json:"dsn"`
38-
DateCreated time.Time `json:"dateCreated"`
38+
ID string `json:"id"`
39+
Name string `json:"name"`
40+
Label string `json:"label"`
41+
Public string `json:"public"`
42+
Secret string `json:"secret"`
43+
ProjectID json.Number `json:"projectId"`
44+
IsActive bool `json:"isActive"`
45+
RateLimit *ProjectKeyRateLimit `json:"rateLimit"`
46+
DSN ProjectKeyDSN `json:"dsn"`
47+
BrowserSDKVersion string `json:"browserSdkVersion"`
48+
DateCreated time.Time `json:"dateCreated"`
49+
DynamicSDKLoaderOptions ProjectKeyDynamicSDKLoaderOptions `json:"dynamicSdkLoaderOptions"`
3950
}
4051

4152
// ProjectKeysService provides methods for accessing Sentry project
4253
// client key API endpoints.
4354
// https://docs.sentry.io/api/projects/
4455
type ProjectKeysService service
4556

57+
type ListProjectKeysParams struct {
58+
ListCursorParams
59+
60+
Status *string `url:"status,omitempty"`
61+
}
62+
4663
// List client keys bound to a project.
4764
// https://docs.sentry.io/api/projects/get-project-keys/
48-
func (s *ProjectKeysService) List(ctx context.Context, organizationSlug string, projectSlug string, params *ListCursorParams) ([]*ProjectKey, *Response, error) {
65+
func (s *ProjectKeysService) List(ctx context.Context, organizationSlug string, projectSlug string, params *ListProjectKeysParams) ([]*ProjectKey, *Response, error) {
4966
u := fmt.Sprintf("0/projects/%v/%v/keys/", organizationSlug, projectSlug)
5067
u, err := addQuery(u, params)
5168
if err != nil {
@@ -65,6 +82,23 @@ func (s *ProjectKeysService) List(ctx context.Context, organizationSlug string,
6582
return projectKeys, resp, nil
6683
}
6784

85+
// Get details of a client key.
86+
// https://docs.sentry.io/api/projects/retrieve-a-client-key/
87+
func (s *ProjectKeysService) Get(ctx context.Context, organizationSlug string, projectSlug string, id string) (*ProjectKey, *Response, error) {
88+
u := fmt.Sprintf("0/projects/%v/%v/keys/%v/", organizationSlug, projectSlug, id)
89+
req, err := s.client.NewRequest("GET", u, nil)
90+
if err != nil {
91+
return nil, nil, err
92+
}
93+
94+
projectKey := new(ProjectKey)
95+
resp, err := s.client.Do(ctx, req, projectKey)
96+
if err != nil {
97+
return nil, resp, err
98+
}
99+
return projectKey, resp, nil
100+
}
101+
68102
// CreateProjectKeyParams are the parameters for ProjectKeyService.Create.
69103
type CreateProjectKeyParams struct {
70104
Name string `json:"name,omitempty"`

0 commit comments

Comments
 (0)