Skip to content

Commit

Permalink
Release v0.0.25
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Aug 14, 2023
1 parent fe819ae commit a8e22a8
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 2 deletions.
8 changes: 8 additions & 0 deletions connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ type GetConnectionsRequest struct {
Prev *string `json:"-"`
}

type UpdateConnectionRequest struct {
// <span style="white-space: nowrap">`<= 155 characters`</span>
Name *string `json:"name,omitempty"`
// Description for the connection
Description *string `json:"description,omitempty"`
Rules []*Rule `json:"rules,omitempty"`
}

type UpsertConnectionRequest struct {
// A unique name of the connection for the source
Name *string `json:"name,omitempty"`
Expand Down
146 changes: 146 additions & 0 deletions connections/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ type Client interface {
GetConnections(ctx context.Context, request *hookdeckgo.GetConnectionsRequest) (*hookdeckgo.ConnectionPaginatedResult, error)
CreateConnection(ctx context.Context, request *hookdeckgo.CreateConnectionRequest) (*hookdeckgo.Connection, error)
UpsertConnection(ctx context.Context, request *hookdeckgo.UpsertConnectionRequest) (*hookdeckgo.Connection, error)
GetConnection(ctx context.Context, id string) (*hookdeckgo.Connection, error)
UpdateConnection(ctx context.Context, id string, request *hookdeckgo.UpdateConnectionRequest) (*hookdeckgo.Connection, error)
DeleteConnection(ctx context.Context, id string) (*hookdeckgo.DeleteConnectionResponse, error)
ArchiveConnection(ctx context.Context, id string) (*hookdeckgo.Connection, error)
UnarchiveConnection(ctx context.Context, id string) (*hookdeckgo.Connection, error)
PauseConnection(ctx context.Context, id string) (*hookdeckgo.Connection, error)
Expand Down Expand Up @@ -238,6 +241,149 @@ func (c *client) UpsertConnection(ctx context.Context, request *hookdeckgo.Upser
return response, nil
}

func (c *client) GetConnection(ctx context.Context, id string) (*hookdeckgo.Connection, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := fmt.Sprintf(baseURL+"/"+"connections/%v", id)

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
if err != nil {
return err
}
apiError := core.NewAPIError(statusCode, errors.New(string(raw)))
decoder := json.NewDecoder(bytes.NewReader(raw))
switch statusCode {
case 404:
value := new(hookdeckgo.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return err
}
return value
}
return apiError
}

var response *hookdeckgo.Connection
if err := core.DoRequest(
ctx,
c.httpClient,
endpointURL,
http.MethodGet,
nil,
&response,
false,
c.header,
errorDecoder,
); err != nil {
return response, err
}
return response, nil
}

func (c *client) UpdateConnection(ctx context.Context, id string, request *hookdeckgo.UpdateConnectionRequest) (*hookdeckgo.Connection, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := fmt.Sprintf(baseURL+"/"+"connections/%v", id)

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
if err != nil {
return err
}
apiError := core.NewAPIError(statusCode, errors.New(string(raw)))
decoder := json.NewDecoder(bytes.NewReader(raw))
switch statusCode {
case 400:
value := new(hookdeckgo.BadRequestError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return err
}
return value
case 404:
value := new(hookdeckgo.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return err
}
return value
case 422:
value := new(hookdeckgo.UnprocessableEntityError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return err
}
return value
}
return apiError
}

var response *hookdeckgo.Connection
if err := core.DoRequest(
ctx,
c.httpClient,
endpointURL,
http.MethodPut,
request,
&response,
false,
c.header,
errorDecoder,
); err != nil {
return response, err
}
return response, nil
}

func (c *client) DeleteConnection(ctx context.Context, id string) (*hookdeckgo.DeleteConnectionResponse, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
baseURL = c.baseURL
}
endpointURL := fmt.Sprintf(baseURL+"/"+"connections/%v", id)

errorDecoder := func(statusCode int, body io.Reader) error {
raw, err := io.ReadAll(body)
if err != nil {
return err
}
apiError := core.NewAPIError(statusCode, errors.New(string(raw)))
decoder := json.NewDecoder(bytes.NewReader(raw))
switch statusCode {
case 404:
value := new(hookdeckgo.NotFoundError)
value.APIError = apiError
if err := decoder.Decode(value); err != nil {
return err
}
return value
}
return apiError
}

var response *hookdeckgo.DeleteConnectionResponse
if err := core.DoRequest(
ctx,
c.httpClient,
endpointURL,
http.MethodDelete,
nil,
&response,
false,
c.header,
errorDecoder,
); err != nil {
return response, err
}
return response, nil
}

func (c *client) ArchiveConnection(ctx context.Context, id string) (*hookdeckgo.Connection, error) {
baseURL := "https://api.hookdeck.com/2023-07-01"
if c.baseURL != "" {
Expand Down
2 changes: 1 addition & 1 deletion core/client_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ func (c *ClientOptions) cloneHeader() http.Header {
headers := c.HTTPHeader.Clone()
headers.Set("X-Fern-Language", "Go")
headers.Set("X-Fern-SDK-Name", "github.com/fern-hookdeck/hookdeck-go")
headers.Set("X-Fern-SDK-Version", "0.0.24")
headers.Set("X-Fern-SDK-Version", "0.0.25")
return headers
}
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file was auto-generated by Fern from our API Definition.

// Issue Triggers lets you setup rules that trigger issues when certain conditions are met.
// A connection lets you route webhooks from a source to a destination, using a ruleset.
package api
5 changes: 5 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3457,6 +3457,11 @@ func (d *DelayRule) MarshalJSON() ([]byte, error) {
return json.Marshal(marshaler)
}

type DeleteConnectionResponse struct {
// ID of the connection
Id string `json:"id"`
}

type DeleteCustomDomainSchema struct {
// The custom hostname ID
Id string `json:"id"`
Expand Down

0 comments on commit a8e22a8

Please sign in to comment.