Skip to content

Commit 2092363

Browse files
committed
feat: OrganizationIntegration endpoints use json.RawMessage
1 parent b33f9fa commit 2092363

File tree

2 files changed

+29
-28
lines changed

2 files changed

+29
-28
lines changed

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)

0 commit comments

Comments
 (0)