Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: OpenAPI spec update via Stainless API #1527

Merged
merged 1 commit into from
Mar 9, 2024
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
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 1256
configured_endpoints: 1255
55 changes: 28 additions & 27 deletions alerting/v3destinationpagerduty.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (r *V3DestinationPagerdutyService) Delete(ctx context.Context, body V3Desti
}

// Get a list of all configured PagerDuty services.
func (r *V3DestinationPagerdutyService) Get(ctx context.Context, query V3DestinationPagerdutyGetParams, opts ...option.RequestOption) (res *[]AaaPagerduty, err error) {
func (r *V3DestinationPagerdutyService) Get(ctx context.Context, query V3DestinationPagerdutyGetParams, opts ...option.RequestOption) (res *[]V3DestinationPagerdutyGetResponse, err error) {
opts = append(r.Options[:], opts...)
var env V3DestinationPagerdutyGetResponseEnvelope
path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/pagerduty", query.AccountID)
Expand All @@ -86,32 +86,8 @@ func (r *V3DestinationPagerdutyService) Link(ctx context.Context, tokenID string
return
}

type AaaPagerduty struct {
// UUID
ID string `json:"id"`
// The name of the pagerduty service.
Name string `json:"name"`
JSON aaaPagerdutyJSON `json:"-"`
}

// aaaPagerdutyJSON contains the JSON metadata for the struct [AaaPagerduty]
type aaaPagerdutyJSON struct {
ID apijson.Field
Name apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *AaaPagerduty) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r aaaPagerdutyJSON) RawJSON() string {
return r.raw
}

type V3DestinationPagerdutyNewResponse struct {
// UUID
// token in form of UUID
ID string `json:"id"`
JSON v3DestinationPagerdutyNewResponseJSON `json:"-"`
}
Expand Down Expand Up @@ -158,6 +134,31 @@ type V3DestinationPagerdutyDeleteResponseArray []interface{}
func (r V3DestinationPagerdutyDeleteResponseArray) ImplementsAlertingV3DestinationPagerdutyDeleteResponse() {
}

type V3DestinationPagerdutyGetResponse struct {
// UUID
ID string `json:"id"`
// The name of the pagerduty service.
Name string `json:"name"`
JSON v3DestinationPagerdutyGetResponseJSON `json:"-"`
}

// v3DestinationPagerdutyGetResponseJSON contains the JSON metadata for the struct
// [V3DestinationPagerdutyGetResponse]
type v3DestinationPagerdutyGetResponseJSON struct {
ID apijson.Field
Name apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *V3DestinationPagerdutyGetResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r v3DestinationPagerdutyGetResponseJSON) RawJSON() string {
return r.raw
}

type V3DestinationPagerdutyLinkResponse struct {
// UUID
ID string `json:"id"`
Expand Down Expand Up @@ -393,7 +394,7 @@ type V3DestinationPagerdutyGetParams struct {
type V3DestinationPagerdutyGetResponseEnvelope struct {
Errors []V3DestinationPagerdutyGetResponseEnvelopeErrors `json:"errors,required"`
Messages []V3DestinationPagerdutyGetResponseEnvelopeMessages `json:"messages,required"`
Result []AaaPagerduty `json:"result,required,nullable"`
Result []V3DestinationPagerdutyGetResponse `json:"result,required,nullable"`
// Whether the API call was successful
Success V3DestinationPagerdutyGetResponseEnvelopeSuccess `json:"success,required"`
ResultInfo V3DestinationPagerdutyGetResponseEnvelopeResultInfo `json:"result_info"`
Expand Down
178 changes: 118 additions & 60 deletions alerting/v3destinationwebhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (r *V3DestinationWebhookService) Update(ctx context.Context, webhookID stri
}

// Gets a list of all configured webhook destinations.
func (r *V3DestinationWebhookService) List(ctx context.Context, query V3DestinationWebhookListParams, opts ...option.RequestOption) (res *[]AaaWebhooks, err error) {
func (r *V3DestinationWebhookService) List(ctx context.Context, query V3DestinationWebhookListParams, opts ...option.RequestOption) (res *[]V3DestinationWebhookListResponse, err error) {
opts = append(r.Options[:], opts...)
var env V3DestinationWebhookListResponseEnvelope
path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/webhooks", query.AccountID)
Expand All @@ -88,7 +88,7 @@ func (r *V3DestinationWebhookService) Delete(ctx context.Context, webhookID stri
}

// Get details for a single webhooks destination.
func (r *V3DestinationWebhookService) Get(ctx context.Context, webhookID string, query V3DestinationWebhookGetParams, opts ...option.RequestOption) (res *AaaWebhooks, err error) {
func (r *V3DestinationWebhookService) Get(ctx context.Context, webhookID string, query V3DestinationWebhookGetParams, opts ...option.RequestOption) (res *V3DestinationWebhookGetResponse, err error) {
opts = append(r.Options[:], opts...)
var env V3DestinationWebhookGetResponseEnvelope
path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/webhooks/%s", query.AccountID, webhookID)
Expand All @@ -100,62 +100,6 @@ func (r *V3DestinationWebhookService) Get(ctx context.Context, webhookID string,
return
}

type AaaWebhooks struct {
// The unique identifier of a webhook
ID string `json:"id"`
// Timestamp of when the webhook destination was created.
CreatedAt time.Time `json:"created_at" format:"date-time"`
// Timestamp of the last time an attempt to dispatch a notification to this webhook
// failed.
LastFailure time.Time `json:"last_failure" format:"date-time"`
// Timestamp of the last time Cloudflare was able to successfully dispatch a
// notification using this webhook.
LastSuccess time.Time `json:"last_success" format:"date-time"`
// The name of the webhook destination. This will be included in the request body
// when you receive a webhook notification.
Name string `json:"name"`
// Optional secret that will be passed in the `cf-webhook-auth` header when
// dispatching generic webhook notifications or formatted for supported
// destinations. Secrets are not returned in any API response body.
Secret string `json:"secret"`
// Type of webhook endpoint.
Type AaaWebhooksType `json:"type"`
// The POST endpoint to call when dispatching a notification.
URL string `json:"url"`
JSON aaaWebhooksJSON `json:"-"`
}

// aaaWebhooksJSON contains the JSON metadata for the struct [AaaWebhooks]
type aaaWebhooksJSON struct {
ID apijson.Field
CreatedAt apijson.Field
LastFailure apijson.Field
LastSuccess apijson.Field
Name apijson.Field
Secret apijson.Field
Type apijson.Field
URL apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *AaaWebhooks) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r aaaWebhooksJSON) RawJSON() string {
return r.raw
}

// Type of webhook endpoint.
type AaaWebhooksType string

const (
AaaWebhooksTypeSlack AaaWebhooksType = "slack"
AaaWebhooksTypeGeneric AaaWebhooksType = "generic"
AaaWebhooksTypeGchat AaaWebhooksType = "gchat"
)

type V3DestinationWebhookNewResponse struct {
// UUID
ID string `json:"id"`
Expand Down Expand Up @@ -200,6 +144,63 @@ func (r v3DestinationWebhookUpdateResponseJSON) RawJSON() string {
return r.raw
}

type V3DestinationWebhookListResponse struct {
// The unique identifier of a webhook
ID string `json:"id"`
// Timestamp of when the webhook destination was created.
CreatedAt time.Time `json:"created_at" format:"date-time"`
// Timestamp of the last time an attempt to dispatch a notification to this webhook
// failed.
LastFailure time.Time `json:"last_failure" format:"date-time"`
// Timestamp of the last time Cloudflare was able to successfully dispatch a
// notification using this webhook.
LastSuccess time.Time `json:"last_success" format:"date-time"`
// The name of the webhook destination. This will be included in the request body
// when you receive a webhook notification.
Name string `json:"name"`
// Optional secret that will be passed in the `cf-webhook-auth` header when
// dispatching generic webhook notifications or formatted for supported
// destinations. Secrets are not returned in any API response body.
Secret string `json:"secret"`
// Type of webhook endpoint.
Type V3DestinationWebhookListResponseType `json:"type"`
// The POST endpoint to call when dispatching a notification.
URL string `json:"url"`
JSON v3DestinationWebhookListResponseJSON `json:"-"`
}

// v3DestinationWebhookListResponseJSON contains the JSON metadata for the struct
// [V3DestinationWebhookListResponse]
type v3DestinationWebhookListResponseJSON struct {
ID apijson.Field
CreatedAt apijson.Field
LastFailure apijson.Field
LastSuccess apijson.Field
Name apijson.Field
Secret apijson.Field
Type apijson.Field
URL apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *V3DestinationWebhookListResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r v3DestinationWebhookListResponseJSON) RawJSON() string {
return r.raw
}

// Type of webhook endpoint.
type V3DestinationWebhookListResponseType string

const (
V3DestinationWebhookListResponseTypeSlack V3DestinationWebhookListResponseType = "slack"
V3DestinationWebhookListResponseTypeGeneric V3DestinationWebhookListResponseType = "generic"
V3DestinationWebhookListResponseTypeGchat V3DestinationWebhookListResponseType = "gchat"
)

// Union satisfied by [alerting.V3DestinationWebhookDeleteResponseUnknown],
// [alerting.V3DestinationWebhookDeleteResponseArray] or [shared.UnionString].
type V3DestinationWebhookDeleteResponse interface {
Expand All @@ -226,6 +227,63 @@ type V3DestinationWebhookDeleteResponseArray []interface{}
func (r V3DestinationWebhookDeleteResponseArray) ImplementsAlertingV3DestinationWebhookDeleteResponse() {
}

type V3DestinationWebhookGetResponse struct {
// The unique identifier of a webhook
ID string `json:"id"`
// Timestamp of when the webhook destination was created.
CreatedAt time.Time `json:"created_at" format:"date-time"`
// Timestamp of the last time an attempt to dispatch a notification to this webhook
// failed.
LastFailure time.Time `json:"last_failure" format:"date-time"`
// Timestamp of the last time Cloudflare was able to successfully dispatch a
// notification using this webhook.
LastSuccess time.Time `json:"last_success" format:"date-time"`
// The name of the webhook destination. This will be included in the request body
// when you receive a webhook notification.
Name string `json:"name"`
// Optional secret that will be passed in the `cf-webhook-auth` header when
// dispatching generic webhook notifications or formatted for supported
// destinations. Secrets are not returned in any API response body.
Secret string `json:"secret"`
// Type of webhook endpoint.
Type V3DestinationWebhookGetResponseType `json:"type"`
// The POST endpoint to call when dispatching a notification.
URL string `json:"url"`
JSON v3DestinationWebhookGetResponseJSON `json:"-"`
}

// v3DestinationWebhookGetResponseJSON contains the JSON metadata for the struct
// [V3DestinationWebhookGetResponse]
type v3DestinationWebhookGetResponseJSON struct {
ID apijson.Field
CreatedAt apijson.Field
LastFailure apijson.Field
LastSuccess apijson.Field
Name apijson.Field
Secret apijson.Field
Type apijson.Field
URL apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

func (r *V3DestinationWebhookGetResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r v3DestinationWebhookGetResponseJSON) RawJSON() string {
return r.raw
}

// Type of webhook endpoint.
type V3DestinationWebhookGetResponseType string

const (
V3DestinationWebhookGetResponseTypeSlack V3DestinationWebhookGetResponseType = "slack"
V3DestinationWebhookGetResponseTypeGeneric V3DestinationWebhookGetResponseType = "generic"
V3DestinationWebhookGetResponseTypeGchat V3DestinationWebhookGetResponseType = "gchat"
)

type V3DestinationWebhookNewParams struct {
// The account id
AccountID param.Field[string] `path:"account_id,required"`
Expand Down Expand Up @@ -432,7 +490,7 @@ type V3DestinationWebhookListParams struct {
type V3DestinationWebhookListResponseEnvelope struct {
Errors []V3DestinationWebhookListResponseEnvelopeErrors `json:"errors,required"`
Messages []V3DestinationWebhookListResponseEnvelopeMessages `json:"messages,required"`
Result []AaaWebhooks `json:"result,required,nullable"`
Result []V3DestinationWebhookListResponse `json:"result,required,nullable"`
// Whether the API call was successful
Success V3DestinationWebhookListResponseEnvelopeSuccess `json:"success,required"`
ResultInfo V3DestinationWebhookListResponseEnvelopeResultInfo `json:"result_info"`
Expand Down Expand Up @@ -670,7 +728,7 @@ type V3DestinationWebhookGetParams struct {
type V3DestinationWebhookGetResponseEnvelope struct {
Errors []V3DestinationWebhookGetResponseEnvelopeErrors `json:"errors,required"`
Messages []V3DestinationWebhookGetResponseEnvelopeMessages `json:"messages,required"`
Result AaaWebhooks `json:"result,required"`
Result V3DestinationWebhookGetResponse `json:"result,required"`
// Whether the API call was successful
Success V3DestinationWebhookGetResponseEnvelopeSuccess `json:"success,required"`
JSON v3DestinationWebhookGetResponseEnvelopeJSON `json:"-"`
Expand Down
29 changes: 15 additions & 14 deletions alerting/v3history.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func NewV3HistoryService(opts ...option.RequestOption) (r *V3HistoryService) {
// Gets a list of history records for notifications sent to an account. The records
// are displayed for last `x` number of days based on the zone plan (free = 30, pro
// = 30, biz = 30, ent = 90).
func (r *V3HistoryService) List(ctx context.Context, params V3HistoryListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[AaaHistory], err error) {
func (r *V3HistoryService) List(ctx context.Context, params V3HistoryListParams, opts ...option.RequestOption) (res *shared.V4PagePaginationArray[V3HistoryListResponse], err error) {
var raw *http.Response
opts = append(r.Options, opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
Expand All @@ -57,11 +57,11 @@ func (r *V3HistoryService) List(ctx context.Context, params V3HistoryListParams,
// Gets a list of history records for notifications sent to an account. The records
// are displayed for last `x` number of days based on the zone plan (free = 30, pro
// = 30, biz = 30, ent = 90).
func (r *V3HistoryService) ListAutoPaging(ctx context.Context, params V3HistoryListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[AaaHistory] {
func (r *V3HistoryService) ListAutoPaging(ctx context.Context, params V3HistoryListParams, opts ...option.RequestOption) *shared.V4PagePaginationArrayAutoPager[V3HistoryListResponse] {
return shared.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...))
}

type AaaHistory struct {
type V3HistoryListResponse struct {
// UUID
ID string `json:"id"`
// Message body included in the notification sent.
Expand All @@ -74,18 +74,19 @@ type AaaHistory struct {
Mechanism string `json:"mechanism"`
// The type of mechanism to which the notification has been dispatched. This can be
// email/pagerduty/webhook based on the mechanism configured.
MechanismType AaaHistoryMechanismType `json:"mechanism_type"`
MechanismType V3HistoryListResponseMechanismType `json:"mechanism_type"`
// Name of the policy.
Name string `json:"name"`
// The unique identifier of a notification policy
PolicyID string `json:"policy_id"`
// Timestamp of when the notification was dispatched in ISO 8601 format.
Sent time.Time `json:"sent" format:"date-time"`
JSON aaaHistoryJSON `json:"-"`
Sent time.Time `json:"sent" format:"date-time"`
JSON v3HistoryListResponseJSON `json:"-"`
}

// aaaHistoryJSON contains the JSON metadata for the struct [AaaHistory]
type aaaHistoryJSON struct {
// v3HistoryListResponseJSON contains the JSON metadata for the struct
// [V3HistoryListResponse]
type v3HistoryListResponseJSON struct {
ID apijson.Field
AlertBody apijson.Field
AlertType apijson.Field
Expand All @@ -99,22 +100,22 @@ type aaaHistoryJSON struct {
ExtraFields map[string]apijson.Field
}

func (r *AaaHistory) UnmarshalJSON(data []byte) (err error) {
func (r *V3HistoryListResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}

func (r aaaHistoryJSON) RawJSON() string {
func (r v3HistoryListResponseJSON) RawJSON() string {
return r.raw
}

// The type of mechanism to which the notification has been dispatched. This can be
// email/pagerduty/webhook based on the mechanism configured.
type AaaHistoryMechanismType string
type V3HistoryListResponseMechanismType string

const (
AaaHistoryMechanismTypeEmail AaaHistoryMechanismType = "email"
AaaHistoryMechanismTypePagerduty AaaHistoryMechanismType = "pagerduty"
AaaHistoryMechanismTypeWebhook AaaHistoryMechanismType = "webhook"
V3HistoryListResponseMechanismTypeEmail V3HistoryListResponseMechanismType = "email"
V3HistoryListResponseMechanismTypePagerduty V3HistoryListResponseMechanismType = "pagerduty"
V3HistoryListResponseMechanismTypeWebhook V3HistoryListResponseMechanismType = "webhook"
)

type V3HistoryListParams struct {
Expand Down
Loading