Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions automations.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 0 additions & 36 deletions automations_fire.go

This file was deleted.

121 changes: 0 additions & 121 deletions automations_fire_test.go

This file was deleted.

14 changes: 0 additions & 14 deletions channels.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 4 additions & 21 deletions flashduty.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,14 @@ type pageMeta struct {
// parameter and JSON-encoding body when non-nil. Most Flashduty endpoints are
// POST actions; a handful are GET with query parameters.
func (c *Client) newRequest(ctx context.Context, method, path string, body any) (*http.Request, error) {
return c.newRequestWithAppKey(ctx, method, path, body, true)
}

func (c *Client) newRequestWithAppKey(ctx context.Context, method, path string, body any, withAppKey bool) (*http.Request, error) {
rel, err := url.Parse(strings.TrimPrefix(path, "/"))
if err != nil {
return nil, fmt.Errorf("flashduty: invalid path %q: %w", path, err)
}
u := c.BaseURL.ResolveReference(rel)
if withAppKey {
q := u.Query()
q.Set("app_key", c.appKey)
u.RawQuery = q.Encode()
}
q := u.Query()
q.Set("app_key", c.appKey)
u.RawQuery = q.Encode()

var buf io.Reader
var rawBody []byte
Expand Down Expand Up @@ -170,21 +164,10 @@ func (c *Client) doGet(ctx context.Context, path string, opt, out any) (*Respons
// (when non-nil), and returns a Response. A non-nil envelope error or a non-2xx
// status yields an *ErrorResponse (or *RateLimitError on 429).
func (c *Client) doMethod(ctx context.Context, method, path string, body, out any) (*Response, error) {
return c.doMethodWithAppKey(ctx, method, path, body, out, true, nil)
}

func (c *Client) doMethodWithoutAppKey(ctx context.Context, method, path string, body, out any, configure func(*http.Request)) (*Response, error) {
return c.doMethodWithAppKey(ctx, method, path, body, out, false, configure)
}

func (c *Client) doMethodWithAppKey(ctx context.Context, method, path string, body, out any, withAppKey bool, configure func(*http.Request)) (*Response, error) {
req, err := c.newRequestWithAppKey(ctx, method, path, body, withAppKey)
req, err := c.newRequest(ctx, method, path, body)
if err != nil {
return nil, err
}
if configure != nil {
configure(req)
}
httpResp, err := c.client.Do(req)
if err != nil {
return nil, fmt.Errorf("flashduty: request to %s failed: %v", sanitizeURL(req.URL), sanitizeError(err))
Expand Down
22 changes: 0 additions & 22 deletions incident_trigger_subscription_models.go

This file was deleted.

29 changes: 0 additions & 29 deletions incident_trigger_subscription_test.go

This file was deleted.

23 changes: 0 additions & 23 deletions incidents.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions internal/cmd/gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,10 @@ func run() error {
schemas: asMap(asMap(spec["components"])["schemas"]),
emptyTypes: map[string]bool{},
skip: map[string]bool{
"SuccessEnvelope": true,
"ErrorResponse": true,
"DutyError": true,
"AutomationRuleUpdateRequest": true, // hand-written to preserve partial-update pointer semantics.
"IncidentTriggerSubscriptionUpsertRequest": true, // hand-written to preserve enabled=false.
"SuccessEnvelope": true,
"ErrorResponse": true,
"DutyError": true,
"AutomationRuleUpdateRequest": true, // hand-written to preserve partial-update pointer semantics.
},
queued: map[string]bool{},
synth: map[string]any{},
Expand Down
Loading