Files
sdk/api_webhook.go

975 lines
34 KiB
Go

/*
Hanzo Cloud API
The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
API version: v1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hanzoai
import (
"bytes"
"context"
"io"
"net/http"
"net/url"
"strings"
)
// WebhookAPIService WebhookAPI service
type WebhookAPIService service
type WebhookAPIDeleteWebhookByIdRequest struct {
ctx context.Context
ApiService *WebhookAPIService
id string
}
func (r WebhookAPIDeleteWebhookByIdRequest) Execute() (*http.Response, error) {
return r.ApiService.DeleteWebhookByIdExecute(r)
}
/*
DeleteWebhookById Removes one of the caller org's webhook endpoints and answers 204 with no body.
Removes one of the caller org's webhook endpoints and answers
204 with no body. Delivery stops immediately and the endpoint's signing secret
is gone with it; its recorded delivery history goes too. An id another org owns
reads as not found.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id
@return WebhookAPIDeleteWebhookByIdRequest
*/
func (a *WebhookAPIService) DeleteWebhookById(ctx context.Context, id string) WebhookAPIDeleteWebhookByIdRequest {
return WebhookAPIDeleteWebhookByIdRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
func (a *WebhookAPIService) DeleteWebhookByIdExecute(r WebhookAPIDeleteWebhookByIdRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WebhookAPIService.DeleteWebhookById")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/webhook/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type WebhookAPIGetWebhookRequest struct {
ctx context.Context
ApiService *WebhookAPIService
}
func (r WebhookAPIGetWebhookRequest) Execute() (*WebhookEndpointList, *http.Response, error) {
return r.ApiService.GetWebhookExecute(r)
}
/*
GetWebhook Returns every webhook endpoint the caller's org has registered, newest first, each with its 7-day delivery and failure counts.
Returns every webhook endpoint the caller's org has registered,
newest first, each with its 7-day delivery and failure counts. Signing secrets
are redacted here — a secret leaves the server only on create and on rotate.
The listing is physically org-scoped, so another tenant's endpoints are not
reachable from this route at all.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return WebhookAPIGetWebhookRequest
*/
func (a *WebhookAPIService) GetWebhook(ctx context.Context) WebhookAPIGetWebhookRequest {
return WebhookAPIGetWebhookRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return WebhookEndpointList
func (a *WebhookAPIService) GetWebhookExecute(r WebhookAPIGetWebhookRequest) (*WebhookEndpointList, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *WebhookEndpointList
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WebhookAPIService.GetWebhook")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/webhook"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type WebhookAPIGetWebhookByIdRequest struct {
ctx context.Context
ApiService *WebhookAPIService
id string
}
func (r WebhookAPIGetWebhookByIdRequest) Execute() (*WebhookEndpoint, *http.Response, error) {
return r.ApiService.GetWebhookByIdExecute(r)
}
/*
GetWebhookById Returns one of the caller org's webhook endpoints with its 7-day delivery and failure counts, signing secret redacted.
Returns one of the caller org's webhook endpoints with its 7-day
delivery and failure counts, signing secret redacted. An id another org owns
reads as not found, so the response cannot confirm that it exists.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id
@return WebhookAPIGetWebhookByIdRequest
*/
func (a *WebhookAPIService) GetWebhookById(ctx context.Context, id string) WebhookAPIGetWebhookByIdRequest {
return WebhookAPIGetWebhookByIdRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return WebhookEndpoint
func (a *WebhookAPIService) GetWebhookByIdExecute(r WebhookAPIGetWebhookByIdRequest) (*WebhookEndpoint, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *WebhookEndpoint
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WebhookAPIService.GetWebhookById")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/webhook/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type WebhookAPIGetWebhookByIdDeliveriesRequest struct {
ctx context.Context
ApiService *WebhookAPIService
id string
limit *int64
status *string
}
// Limit caps how many attempts come back: default 50, maximum 200. A value that is not a positive integer reads as the default.
func (r WebhookAPIGetWebhookByIdDeliveriesRequest) Limit(limit int64) WebhookAPIGetWebhookByIdDeliveriesRequest {
r.limit = &limit
return r
}
// Status narrows the log to one outcome: \"ok\", \"retrying\" or \"failed\". Empty returns every attempt.
func (r WebhookAPIGetWebhookByIdDeliveriesRequest) Status(status string) WebhookAPIGetWebhookByIdDeliveriesRequest {
r.status = &status
return r
}
func (r WebhookAPIGetWebhookByIdDeliveriesRequest) Execute() (*WebhookDeliveryList, *http.Response, error) {
return r.ApiService.GetWebhookByIdDeliveriesExecute(r)
}
/*
GetWebhookByIdDeliveries Returns one endpoint's per-attempt delivery log, newest first — the record of what was sent, what the subscriber answered, and how long it took.
Returns one endpoint's per-attempt delivery log, newest first —
the record of what was sent, what the subscriber answered, and how long it
took. One event that retried three times appears as three rows sharing a
delivery id. It is org-scoped exactly like every other route here: the endpoint
lookup only ever finds THIS org's endpoint, so another org's id is a 404 and
never a window onto its logs.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id
@return WebhookAPIGetWebhookByIdDeliveriesRequest
*/
func (a *WebhookAPIService) GetWebhookByIdDeliveries(ctx context.Context, id string) WebhookAPIGetWebhookByIdDeliveriesRequest {
return WebhookAPIGetWebhookByIdDeliveriesRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return WebhookDeliveryList
func (a *WebhookAPIService) GetWebhookByIdDeliveriesExecute(r WebhookAPIGetWebhookByIdDeliveriesRequest) (*WebhookDeliveryList, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *WebhookDeliveryList
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WebhookAPIService.GetWebhookByIdDeliveries")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/webhook/{id}/deliveries"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.limit != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "")
}
if r.status != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "status", r.status, "form", "")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type WebhookAPIPostWebhookRequest struct {
ctx context.Context
ApiService *WebhookAPIService
webhookCreateEndpointIn *WebhookCreateEndpointIn
}
func (r WebhookAPIPostWebhookRequest) WebhookCreateEndpointIn(webhookCreateEndpointIn WebhookCreateEndpointIn) WebhookAPIPostWebhookRequest {
r.webhookCreateEndpointIn = &webhookCreateEndpointIn
return r
}
func (r WebhookAPIPostWebhookRequest) Execute() (*WebhookEndpoint, *http.Response, error) {
return r.ApiService.PostWebhookExecute(r)
}
/*
PostWebhook Registers a new webhook subscription for the caller's org and answers 201 with the endpoint INCLUDING its freshly minted signing secret.
Registers a new webhook subscription for the caller's org and
answers 201 with the endpoint INCLUDING its freshly minted signing secret.
This is one of only two responses that ever carry that secret (the other is
rotate) — store it now, because no later read returns it. The org is stamped by
the server from the validated principal, so a body can never register an
endpoint in another tenant.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return WebhookAPIPostWebhookRequest
*/
func (a *WebhookAPIService) PostWebhook(ctx context.Context) WebhookAPIPostWebhookRequest {
return WebhookAPIPostWebhookRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return WebhookEndpoint
func (a *WebhookAPIService) PostWebhookExecute(r WebhookAPIPostWebhookRequest) (*WebhookEndpoint, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *WebhookEndpoint
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WebhookAPIService.PostWebhook")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/webhook"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.webhookCreateEndpointIn == nil {
return localVarReturnValue, nil, reportError("webhookCreateEndpointIn is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.webhookCreateEndpointIn
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type WebhookAPIPostWebhookByIdSecretRequest struct {
ctx context.Context
ApiService *WebhookAPIService
id string
}
func (r WebhookAPIPostWebhookByIdSecretRequest) Execute() (*WebhookEndpoint, *http.Response, error) {
return r.ApiService.PostWebhookByIdSecretExecute(r)
}
/*
PostWebhookByIdSecret Mints a NEW HMAC signing secret for the endpoint and answers the endpoint WITH it — the only other response besides create that ever carries a secret.
Mints a NEW HMAC signing secret for the endpoint and answers the
endpoint WITH it — the only other response besides create that ever carries a
secret. The old secret stops working the instant this returns: every subsequent
delivery signs with the new one, with no overlap window. Call it when the
subscriber is ready to swap the value on its side, not before.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id
@return WebhookAPIPostWebhookByIdSecretRequest
*/
func (a *WebhookAPIService) PostWebhookByIdSecret(ctx context.Context, id string) WebhookAPIPostWebhookByIdSecretRequest {
return WebhookAPIPostWebhookByIdSecretRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return WebhookEndpoint
func (a *WebhookAPIService) PostWebhookByIdSecretExecute(r WebhookAPIPostWebhookByIdSecretRequest) (*WebhookEndpoint, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *WebhookEndpoint
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WebhookAPIService.PostWebhookByIdSecret")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/webhook/{id}/secret"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type WebhookAPIPostWebhookByIdTestRequest struct {
ctx context.Context
ApiService *WebhookAPIService
id string
}
func (r WebhookAPIPostWebhookByIdTestRequest) Execute() (*WebhookTestResult, *http.Response, error) {
return r.ApiService.PostWebhookByIdTestExecute(r)
}
/*
PostWebhookByIdTest Sends ONE signed test event to the endpoint right now and answers the outcome inline, so the console can show whether the subscriber is reachable without waiting for real traffic.
Sends ONE signed test event to the endpoint right now and answers
the outcome inline, so the console can show whether the subscriber is reachable
without waiting for real traffic. It takes the same attempt path the bus
dispatcher takes — one attempt, 10s timeout, no retry ladder — and records the
result in the endpoint's delivery log. It works on a DISABLED endpoint too:
validating one you have paused is the whole point.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id
@return WebhookAPIPostWebhookByIdTestRequest
*/
func (a *WebhookAPIService) PostWebhookByIdTest(ctx context.Context, id string) WebhookAPIPostWebhookByIdTestRequest {
return WebhookAPIPostWebhookByIdTestRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return WebhookTestResult
func (a *WebhookAPIService) PostWebhookByIdTestExecute(r WebhookAPIPostWebhookByIdTestRequest) (*WebhookTestResult, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *WebhookTestResult
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WebhookAPIService.PostWebhookByIdTest")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/webhook/{id}/test"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}
type WebhookAPIPutWebhookByIdRequest struct {
ctx context.Context
ApiService *WebhookAPIService
id string
webhookUpdateEndpointIn *WebhookUpdateEndpointIn
}
func (r WebhookAPIPutWebhookByIdRequest) WebhookUpdateEndpointIn(webhookUpdateEndpointIn WebhookUpdateEndpointIn) WebhookAPIPutWebhookByIdRequest {
r.webhookUpdateEndpointIn = &webhookUpdateEndpointIn
return r
}
func (r WebhookAPIPutWebhookByIdRequest) Execute() (*WebhookEndpoint, *http.Response, error) {
return r.ApiService.PutWebhookByIdExecute(r)
}
/*
PutWebhookById Replaces the editable fields of one of the caller org's endpoints — url, events, status and description — and answers the stored row with its secret redacted.
Replaces the editable fields of one of the caller org's
endpoints — url, events, status and description — and answers the stored row
with its secret redacted. It is a full replace, not a patch: an omitted field
is written as its empty value, and an omitted or empty events list resubscribes
the endpoint to EVERY event. The signing secret and the creation time are
immutable here; rotate the secret with POST /v1/webhook/{id}/secret.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param id
@return WebhookAPIPutWebhookByIdRequest
*/
func (a *WebhookAPIService) PutWebhookById(ctx context.Context, id string) WebhookAPIPutWebhookByIdRequest {
return WebhookAPIPutWebhookByIdRequest{
ApiService: a,
ctx: ctx,
id: id,
}
}
// Execute executes the request
//
// @return WebhookEndpoint
func (a *WebhookAPIService) PutWebhookByIdExecute(r WebhookAPIPutWebhookByIdRequest) (*WebhookEndpoint, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *WebhookEndpoint
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WebhookAPIService.PutWebhookById")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/webhook/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.webhookUpdateEndpointIn == nil {
return localVarReturnValue, nil, reportError("webhookUpdateEndpointIn is required and must be specified")
}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{"application/json"}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.webhookUpdateEndpointIn
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return localVarReturnValue, nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
var v ProblemDetails
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
newErr.model = v
return localVarReturnValue, localVarHTTPResponse, newErr
}
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}
return localVarReturnValue, localVarHTTPResponse, nil
}