diff --git a/.stats.yml b/.stats.yml index a594a051342..d815e5acaf6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1296 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ec9f8eaec2fb4d1843f2a2ffc2c6ebaf8c45275c9a18f8ece252fd7fe4a7c946.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-ccc4d0cef46244cffd7a8d06b4ae14a936e2c0c4ed40a5af409f183d4fd60eb9.yml diff --git a/api.md b/api.md index 144aa0f59a3..fb862451921 100644 --- a/api.md +++ b/api.md @@ -6873,14 +6873,14 @@ Response Types: - cloudforce_one.Quota - cloudforce_one.RequestConstants - cloudforce_one.RequestTypes -- cloudforce_one.RequestDeleteResponse +- cloudforce_one.RequestDeleteResponseUnion Methods: - client.CloudforceOne.Requests.New(ctx context.Context, accountIdentifier string, body cloudforce_one.RequestNewParams) (cloudforce_one.Item, error) - client.CloudforceOne.Requests.Update(ctx context.Context, accountIdentifier string, requestIdentifier string, body cloudforce_one.RequestUpdateParams) (cloudforce_one.Item, error) - client.CloudforceOne.Requests.List(ctx context.Context, accountIdentifier string, body cloudforce_one.RequestListParams) (pagination.V4PagePaginationArray[cloudforce_one.ListItem], error) -- client.CloudforceOne.Requests.Delete(ctx context.Context, accountIdentifier string, requestIdentifier string) (cloudforce_one.RequestDeleteResponse, error) +- client.CloudforceOne.Requests.Delete(ctx context.Context, accountIdentifier string, requestIdentifier string) (cloudforce_one.RequestDeleteResponseUnion, error) - client.CloudforceOne.Requests.Constants(ctx context.Context, accountIdentifier string) (cloudforce_one.RequestConstants, error) - client.CloudforceOne.Requests.Get(ctx context.Context, accountIdentifier string, requestIdentifier string) (cloudforce_one.Item, error) - client.CloudforceOne.Requests.Quota(ctx context.Context, accountIdentifier string) (cloudforce_one.Quota, error) @@ -6891,13 +6891,13 @@ Methods: Response Types: - cloudforce_one.Message -- cloudforce_one.RequestMessageDeleteResponse +- cloudforce_one.RequestMessageDeleteResponseUnion Methods: - client.CloudforceOne.Requests.Message.New(ctx context.Context, accountIdentifier string, requestIdentifier string, body cloudforce_one.RequestMessageNewParams) (cloudforce_one.Message, error) - client.CloudforceOne.Requests.Message.Update(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64, body cloudforce_one.RequestMessageUpdateParams) (cloudforce_one.Message, error) -- client.CloudforceOne.Requests.Message.Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64) (cloudforce_one.RequestMessageDeleteResponse, error) +- client.CloudforceOne.Requests.Message.Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64) (cloudforce_one.RequestMessageDeleteResponseUnion, error) - client.CloudforceOne.Requests.Message.Get(ctx context.Context, accountIdentifier string, requestIdentifier string, body cloudforce_one.RequestMessageGetParams) ([]cloudforce_one.Message, error) ### Priority @@ -6911,13 +6911,13 @@ Response Types: - cloudforce_one.Label - cloudforce_one.Priority -- cloudforce_one.RequestPriorityDeleteResponse +- cloudforce_one.RequestPriorityDeleteResponseUnion Methods: - client.CloudforceOne.Requests.Priority.New(ctx context.Context, accountIdentifier string, body cloudforce_one.RequestPriorityNewParams) (cloudforce_one.Priority, error) - client.CloudforceOne.Requests.Priority.Update(ctx context.Context, accountIdentifier string, priorityIdentifer string, body cloudforce_one.RequestPriorityUpdateParams) (cloudforce_one.Item, error) -- client.CloudforceOne.Requests.Priority.Delete(ctx context.Context, accountIdentifier string, priorityIdentifer string) (cloudforce_one.RequestPriorityDeleteResponse, error) +- client.CloudforceOne.Requests.Priority.Delete(ctx context.Context, accountIdentifier string, priorityIdentifer string) (cloudforce_one.RequestPriorityDeleteResponseUnion, error) - client.CloudforceOne.Requests.Priority.Get(ctx context.Context, accountIdentifier string, priorityIdentifer string) (cloudforce_one.Item, error) - client.CloudforceOne.Requests.Priority.Quota(ctx context.Context, accountIdentifier string) (cloudforce_one.Quota, error) diff --git a/cloudforce_one/request.go b/cloudforce_one/request.go index 5a70f4a8371..05902b915c1 100644 --- a/cloudforce_one/request.go +++ b/cloudforce_one/request.go @@ -6,6 +6,7 @@ import ( "context" "fmt" "net/http" + "reflect" "time" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" @@ -14,6 +15,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v2/option" "github.com/cloudflare/cloudflare-go/v2/shared" + "github.com/tidwall/gjson" ) // RequestService contains methods and other services that help with interacting @@ -93,10 +95,15 @@ func (r *RequestService) ListAutoPaging(ctx context.Context, accountIdentifier s } // Delete a Request -func (r *RequestService) Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, opts ...option.RequestOption) (res *RequestDeleteResponse, err error) { +func (r *RequestService) Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, opts ...option.RequestOption) (res *RequestDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) + var env RequestDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s", accountIdentifier, requestIdentifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result return } @@ -464,46 +471,30 @@ func (r RequestConstantsTlp) IsKnown() bool { type RequestTypes []string -type RequestDeleteResponse struct { - Errors []shared.ResponseInfo `json:"errors,required"` - Messages []shared.ResponseInfo `json:"messages,required"` - // Whether the API call was successful - Success RequestDeleteResponseSuccess `json:"success,required"` - JSON requestDeleteResponseJSON `json:"-"` -} - -// requestDeleteResponseJSON contains the JSON metadata for the struct -// [RequestDeleteResponse] -type requestDeleteResponseJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// Union satisfied by [cloudforce_one.RequestDeleteResponseUnknown], +// [cloudforce_one.RequestDeleteResponseArray] or [shared.UnionString]. +type RequestDeleteResponseUnion interface { + ImplementsCloudforceOneRequestDeleteResponseUnion() } -func (r requestDeleteResponseJSON) RawJSON() string { - return r.raw +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RequestDeleteResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RequestDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) } -// Whether the API call was successful -type RequestDeleteResponseSuccess bool +type RequestDeleteResponseArray []interface{} -const ( - RequestDeleteResponseSuccessTrue RequestDeleteResponseSuccess = true -) - -func (r RequestDeleteResponseSuccess) IsKnown() bool { - switch r { - case RequestDeleteResponseSuccessTrue: - return true - } - return false -} +func (r RequestDeleteResponseArray) ImplementsCloudforceOneRequestDeleteResponseUnion() {} type RequestNewParams struct { // Request content @@ -544,9 +535,9 @@ func (r RequestNewParamsTlp) IsKnown() bool { type RequestNewResponseEnvelope struct { Errors []shared.ResponseInfo `json:"errors,required"` Messages []shared.ResponseInfo `json:"messages,required"` + Result Item `json:"result,required"` // Whether the API call was successful Success RequestNewResponseEnvelopeSuccess `json:"success,required"` - Result Item `json:"result"` JSON requestNewResponseEnvelopeJSON `json:"-"` } @@ -555,8 +546,8 @@ type RequestNewResponseEnvelope struct { type requestNewResponseEnvelopeJSON struct { Errors apijson.Field Messages apijson.Field - Success apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -623,9 +614,9 @@ func (r RequestUpdateParamsTlp) IsKnown() bool { type RequestUpdateResponseEnvelope struct { Errors []shared.ResponseInfo `json:"errors,required"` Messages []shared.ResponseInfo `json:"messages,required"` + Result Item `json:"result,required"` // Whether the API call was successful Success RequestUpdateResponseEnvelopeSuccess `json:"success,required"` - Result Item `json:"result"` JSON requestUpdateResponseEnvelopeJSON `json:"-"` } @@ -634,8 +625,8 @@ type RequestUpdateResponseEnvelope struct { type requestUpdateResponseEnvelopeJSON struct { Errors apijson.Field Messages apijson.Field - Success apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -726,12 +717,55 @@ func (r RequestListParamsStatus) IsKnown() bool { return false } +type RequestDeleteResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RequestDeleteResponseUnion `json:"result,required"` + // Whether the API call was successful + Success RequestDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON requestDeleteResponseEnvelopeJSON `json:"-"` +} + +// requestDeleteResponseEnvelopeJSON contains the JSON metadata for the struct +// [RequestDeleteResponseEnvelope] +type requestDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RequestDeleteResponseEnvelopeSuccess bool + +const ( + RequestDeleteResponseEnvelopeSuccessTrue RequestDeleteResponseEnvelopeSuccess = true +) + +func (r RequestDeleteResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case RequestDeleteResponseEnvelopeSuccessTrue: + return true + } + return false +} + type RequestConstantsResponseEnvelope struct { Errors []shared.ResponseInfo `json:"errors,required"` Messages []shared.ResponseInfo `json:"messages,required"` + Result RequestConstants `json:"result,required"` // Whether the API call was successful Success RequestConstantsResponseEnvelopeSuccess `json:"success,required"` - Result RequestConstants `json:"result"` JSON requestConstantsResponseEnvelopeJSON `json:"-"` } @@ -740,8 +774,8 @@ type RequestConstantsResponseEnvelope struct { type requestConstantsResponseEnvelopeJSON struct { Errors apijson.Field Messages apijson.Field - Success apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -772,9 +806,9 @@ func (r RequestConstantsResponseEnvelopeSuccess) IsKnown() bool { type RequestGetResponseEnvelope struct { Errors []shared.ResponseInfo `json:"errors,required"` Messages []shared.ResponseInfo `json:"messages,required"` + Result Item `json:"result,required"` // Whether the API call was successful Success RequestGetResponseEnvelopeSuccess `json:"success,required"` - Result Item `json:"result"` JSON requestGetResponseEnvelopeJSON `json:"-"` } @@ -783,8 +817,8 @@ type RequestGetResponseEnvelope struct { type requestGetResponseEnvelopeJSON struct { Errors apijson.Field Messages apijson.Field - Success apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -815,9 +849,9 @@ func (r RequestGetResponseEnvelopeSuccess) IsKnown() bool { type RequestQuotaResponseEnvelope struct { Errors []shared.ResponseInfo `json:"errors,required"` Messages []shared.ResponseInfo `json:"messages,required"` + Result Quota `json:"result,required"` // Whether the API call was successful Success RequestQuotaResponseEnvelopeSuccess `json:"success,required"` - Result Quota `json:"result"` JSON requestQuotaResponseEnvelopeJSON `json:"-"` } @@ -826,8 +860,8 @@ type RequestQuotaResponseEnvelope struct { type requestQuotaResponseEnvelopeJSON struct { Errors apijson.Field Messages apijson.Field - Success apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -858,9 +892,9 @@ func (r RequestQuotaResponseEnvelopeSuccess) IsKnown() bool { type RequestTypesResponseEnvelope struct { Errors []shared.ResponseInfo `json:"errors,required"` Messages []shared.ResponseInfo `json:"messages,required"` + Result RequestTypes `json:"result,required"` // Whether the API call was successful Success RequestTypesResponseEnvelopeSuccess `json:"success,required"` - Result RequestTypes `json:"result"` JSON requestTypesResponseEnvelopeJSON `json:"-"` } @@ -869,8 +903,8 @@ type RequestTypesResponseEnvelope struct { type requestTypesResponseEnvelopeJSON struct { Errors apijson.Field Messages apijson.Field - Success apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } diff --git a/cloudforce_one/requestmessage.go b/cloudforce_one/requestmessage.go index fedcf3004bd..4e93aef8863 100644 --- a/cloudforce_one/requestmessage.go +++ b/cloudforce_one/requestmessage.go @@ -6,6 +6,7 @@ import ( "context" "fmt" "net/http" + "reflect" "time" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" @@ -13,6 +14,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v2/option" "github.com/cloudflare/cloudflare-go/v2/shared" + "github.com/tidwall/gjson" ) // RequestMessageService contains methods and other services that help with @@ -63,10 +65,15 @@ func (r *RequestMessageService) Update(ctx context.Context, accountIdentifier st } // Delete a Request Message -func (r *RequestMessageService) Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64, opts ...option.RequestOption) (res *RequestMessageDeleteResponse, err error) { +func (r *RequestMessageService) Delete(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64, opts ...option.RequestOption) (res *RequestMessageDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) + var env RequestMessageDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/%s/message/%v", accountIdentifier, requestIdentifier, messageIdentifer) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result return } @@ -119,45 +126,30 @@ func (r messageJSON) RawJSON() string { return r.raw } -type RequestMessageDeleteResponse struct { - Errors []shared.ResponseInfo `json:"errors,required"` - Messages []shared.ResponseInfo `json:"messages,required"` - // Whether the API call was successful - Success RequestMessageDeleteResponseSuccess `json:"success,required"` - JSON requestMessageDeleteResponseJSON `json:"-"` -} - -// requestMessageDeleteResponseJSON contains the JSON metadata for the struct -// [RequestMessageDeleteResponse] -type requestMessageDeleteResponseJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestMessageDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// Union satisfied by [cloudforce_one.RequestMessageDeleteResponseUnknown], +// [cloudforce_one.RequestMessageDeleteResponseArray] or [shared.UnionString]. +type RequestMessageDeleteResponseUnion interface { + ImplementsCloudforceOneRequestMessageDeleteResponseUnion() } -func (r requestMessageDeleteResponseJSON) RawJSON() string { - return r.raw +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RequestMessageDeleteResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RequestMessageDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) } -// Whether the API call was successful -type RequestMessageDeleteResponseSuccess bool - -const ( - RequestMessageDeleteResponseSuccessTrue RequestMessageDeleteResponseSuccess = true -) +type RequestMessageDeleteResponseArray []interface{} -func (r RequestMessageDeleteResponseSuccess) IsKnown() bool { - switch r { - case RequestMessageDeleteResponseSuccessTrue: - return true - } - return false +func (r RequestMessageDeleteResponseArray) ImplementsCloudforceOneRequestMessageDeleteResponseUnion() { } type RequestMessageNewParams struct { @@ -172,9 +164,9 @@ func (r RequestMessageNewParams) MarshalJSON() (data []byte, err error) { type RequestMessageNewResponseEnvelope struct { Errors []shared.ResponseInfo `json:"errors,required"` Messages []shared.ResponseInfo `json:"messages,required"` + Result Message `json:"result,required"` // Whether the API call was successful Success RequestMessageNewResponseEnvelopeSuccess `json:"success,required"` - Result Message `json:"result"` JSON requestMessageNewResponseEnvelopeJSON `json:"-"` } @@ -183,8 +175,8 @@ type RequestMessageNewResponseEnvelope struct { type requestMessageNewResponseEnvelopeJSON struct { Errors apijson.Field Messages apijson.Field - Success apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -251,9 +243,9 @@ func (r RequestMessageUpdateParamsTlp) IsKnown() bool { type RequestMessageUpdateResponseEnvelope struct { Errors []shared.ResponseInfo `json:"errors,required"` Messages []shared.ResponseInfo `json:"messages,required"` + Result Message `json:"result,required"` // Whether the API call was successful Success RequestMessageUpdateResponseEnvelopeSuccess `json:"success,required"` - Result Message `json:"result"` JSON requestMessageUpdateResponseEnvelopeJSON `json:"-"` } @@ -262,8 +254,8 @@ type RequestMessageUpdateResponseEnvelope struct { type requestMessageUpdateResponseEnvelopeJSON struct { Errors apijson.Field Messages apijson.Field - Success apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -291,6 +283,49 @@ func (r RequestMessageUpdateResponseEnvelopeSuccess) IsKnown() bool { return false } +type RequestMessageDeleteResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RequestMessageDeleteResponseUnion `json:"result,required"` + // Whether the API call was successful + Success RequestMessageDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON requestMessageDeleteResponseEnvelopeJSON `json:"-"` +} + +// requestMessageDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [RequestMessageDeleteResponseEnvelope] +type requestMessageDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestMessageDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestMessageDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RequestMessageDeleteResponseEnvelopeSuccess bool + +const ( + RequestMessageDeleteResponseEnvelopeSuccessTrue RequestMessageDeleteResponseEnvelopeSuccess = true +) + +func (r RequestMessageDeleteResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case RequestMessageDeleteResponseEnvelopeSuccessTrue: + return true + } + return false +} + type RequestMessageGetParams struct { // Page number of results Page param.Field[int64] `json:"page,required"` @@ -329,9 +364,9 @@ func (r RequestMessageGetParamsSortOrder) IsKnown() bool { type RequestMessageGetResponseEnvelope struct { Errors []shared.ResponseInfo `json:"errors,required"` Messages []shared.ResponseInfo `json:"messages,required"` + Result []Message `json:"result,required"` // Whether the API call was successful Success RequestMessageGetResponseEnvelopeSuccess `json:"success,required"` - Result []Message `json:"result"` JSON requestMessageGetResponseEnvelopeJSON `json:"-"` } @@ -340,8 +375,8 @@ type RequestMessageGetResponseEnvelope struct { type requestMessageGetResponseEnvelopeJSON struct { Errors apijson.Field Messages apijson.Field - Success apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } diff --git a/cloudforce_one/requestpriority.go b/cloudforce_one/requestpriority.go index f6b6751bcc2..5b004848580 100644 --- a/cloudforce_one/requestpriority.go +++ b/cloudforce_one/requestpriority.go @@ -6,6 +6,7 @@ import ( "context" "fmt" "net/http" + "reflect" "time" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" @@ -13,6 +14,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v2/option" "github.com/cloudflare/cloudflare-go/v2/shared" + "github.com/tidwall/gjson" ) // RequestPriorityService contains methods and other services that help with @@ -61,10 +63,15 @@ func (r *RequestPriorityService) Update(ctx context.Context, accountIdentifier s } // Delete a Priority Intelligence Report -func (r *RequestPriorityService) Delete(ctx context.Context, accountIdentifier string, priorityIdentifer string, opts ...option.RequestOption) (res *RequestPriorityDeleteResponse, err error) { +func (r *RequestPriorityService) Delete(ctx context.Context, accountIdentifier string, priorityIdentifer string, opts ...option.RequestOption) (res *RequestPriorityDeleteResponseUnion, err error) { opts = append(r.Options[:], opts...) + var env RequestPriorityDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/cloudforce-one/requests/priority/%s", accountIdentifier, priorityIdentifer) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &res, opts...) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) + if err != nil { + return + } + res = &env.Result return } @@ -190,45 +197,30 @@ func (r PriorityEditTlp) IsKnown() bool { return false } -type RequestPriorityDeleteResponse struct { - Errors []shared.ResponseInfo `json:"errors,required"` - Messages []shared.ResponseInfo `json:"messages,required"` - // Whether the API call was successful - Success RequestPriorityDeleteResponseSuccess `json:"success,required"` - JSON requestPriorityDeleteResponseJSON `json:"-"` +// Union satisfied by [cloudforce_one.RequestPriorityDeleteResponseUnknown], +// [cloudforce_one.RequestPriorityDeleteResponseArray] or [shared.UnionString]. +type RequestPriorityDeleteResponseUnion interface { + ImplementsCloudforceOneRequestPriorityDeleteResponseUnion() } -// requestPriorityDeleteResponseJSON contains the JSON metadata for the struct -// [RequestPriorityDeleteResponse] -type requestPriorityDeleteResponseJSON struct { - Errors apijson.Field - Messages apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*RequestPriorityDeleteResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(RequestPriorityDeleteResponseArray{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) } -func (r *RequestPriorityDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} +type RequestPriorityDeleteResponseArray []interface{} -func (r requestPriorityDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type RequestPriorityDeleteResponseSuccess bool - -const ( - RequestPriorityDeleteResponseSuccessTrue RequestPriorityDeleteResponseSuccess = true -) - -func (r RequestPriorityDeleteResponseSuccess) IsKnown() bool { - switch r { - case RequestPriorityDeleteResponseSuccessTrue: - return true - } - return false +func (r RequestPriorityDeleteResponseArray) ImplementsCloudforceOneRequestPriorityDeleteResponseUnion() { } type RequestPriorityNewParams struct { @@ -242,9 +234,9 @@ func (r RequestPriorityNewParams) MarshalJSON() (data []byte, err error) { type RequestPriorityNewResponseEnvelope struct { Errors []shared.ResponseInfo `json:"errors,required"` Messages []shared.ResponseInfo `json:"messages,required"` + Result Priority `json:"result,required"` // Whether the API call was successful Success RequestPriorityNewResponseEnvelopeSuccess `json:"success,required"` - Result Priority `json:"result"` JSON requestPriorityNewResponseEnvelopeJSON `json:"-"` } @@ -253,8 +245,8 @@ type RequestPriorityNewResponseEnvelope struct { type requestPriorityNewResponseEnvelopeJSON struct { Errors apijson.Field Messages apijson.Field - Success apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -293,9 +285,9 @@ func (r RequestPriorityUpdateParams) MarshalJSON() (data []byte, err error) { type RequestPriorityUpdateResponseEnvelope struct { Errors []shared.ResponseInfo `json:"errors,required"` Messages []shared.ResponseInfo `json:"messages,required"` + Result Item `json:"result,required"` // Whether the API call was successful Success RequestPriorityUpdateResponseEnvelopeSuccess `json:"success,required"` - Result Item `json:"result"` JSON requestPriorityUpdateResponseEnvelopeJSON `json:"-"` } @@ -304,8 +296,8 @@ type RequestPriorityUpdateResponseEnvelope struct { type requestPriorityUpdateResponseEnvelopeJSON struct { Errors apijson.Field Messages apijson.Field - Success apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -333,12 +325,55 @@ func (r RequestPriorityUpdateResponseEnvelopeSuccess) IsKnown() bool { return false } +type RequestPriorityDeleteResponseEnvelope struct { + Errors []shared.ResponseInfo `json:"errors,required"` + Messages []shared.ResponseInfo `json:"messages,required"` + Result RequestPriorityDeleteResponseUnion `json:"result,required"` + // Whether the API call was successful + Success RequestPriorityDeleteResponseEnvelopeSuccess `json:"success,required"` + JSON requestPriorityDeleteResponseEnvelopeJSON `json:"-"` +} + +// requestPriorityDeleteResponseEnvelopeJSON contains the JSON metadata for the +// struct [RequestPriorityDeleteResponseEnvelope] +type requestPriorityDeleteResponseEnvelopeJSON struct { + Errors apijson.Field + Messages apijson.Field + Result apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *RequestPriorityDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r requestPriorityDeleteResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +// Whether the API call was successful +type RequestPriorityDeleteResponseEnvelopeSuccess bool + +const ( + RequestPriorityDeleteResponseEnvelopeSuccessTrue RequestPriorityDeleteResponseEnvelopeSuccess = true +) + +func (r RequestPriorityDeleteResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case RequestPriorityDeleteResponseEnvelopeSuccessTrue: + return true + } + return false +} + type RequestPriorityGetResponseEnvelope struct { Errors []shared.ResponseInfo `json:"errors,required"` Messages []shared.ResponseInfo `json:"messages,required"` + Result Item `json:"result,required"` // Whether the API call was successful Success RequestPriorityGetResponseEnvelopeSuccess `json:"success,required"` - Result Item `json:"result"` JSON requestPriorityGetResponseEnvelopeJSON `json:"-"` } @@ -347,8 +382,8 @@ type RequestPriorityGetResponseEnvelope struct { type requestPriorityGetResponseEnvelopeJSON struct { Errors apijson.Field Messages apijson.Field - Success apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -379,9 +414,9 @@ func (r RequestPriorityGetResponseEnvelopeSuccess) IsKnown() bool { type RequestPriorityQuotaResponseEnvelope struct { Errors []shared.ResponseInfo `json:"errors,required"` Messages []shared.ResponseInfo `json:"messages,required"` + Result Quota `json:"result,required"` // Whether the API call was successful Success RequestPriorityQuotaResponseEnvelopeSuccess `json:"success,required"` - Result Quota `json:"result"` JSON requestPriorityQuotaResponseEnvelopeJSON `json:"-"` } @@ -390,8 +425,8 @@ type RequestPriorityQuotaResponseEnvelope struct { type requestPriorityQuotaResponseEnvelopeJSON struct { Errors apijson.Field Messages apijson.Field - Success apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } diff --git a/intel/whois.go b/intel/whois.go index 82c9c1aa90b..83849a72c9a 100644 --- a/intel/whois.go +++ b/intel/whois.go @@ -259,9 +259,9 @@ func (r WhoisGetParams) URLQuery() (v url.Values) { type WhoisGetResponseEnvelope struct { Errors []shared.ResponseInfo `json:"errors,required"` Messages []shared.ResponseInfo `json:"messages,required"` + Result WhoisGetResponse `json:"result,required"` // Whether the API call was successful Success WhoisGetResponseEnvelopeSuccess `json:"success,required"` - Result WhoisGetResponse `json:"result"` JSON whoisGetResponseEnvelopeJSON `json:"-"` } @@ -270,8 +270,8 @@ type WhoisGetResponseEnvelope struct { type whoisGetResponseEnvelopeJSON struct { Errors apijson.Field Messages apijson.Field - Success apijson.Field Result apijson.Field + Success apijson.Field raw string ExtraFields map[string]apijson.Field } diff --git a/shared/union.go b/shared/union.go index d00051ef1b0..7daaec2f41b 100644 --- a/shared/union.go +++ b/shared/union.go @@ -188,6 +188,9 @@ func (UnionString) ImplementsOriginPostQuantumEncryptionOriginPostQuantumEncrypt } func (UnionString) ImplementsHostnamesSettingValueUnionParam() {} func (UnionString) ImplementsHostnamesSettingValueUnion() {} +func (UnionString) ImplementsCloudforceOneRequestDeleteResponseUnion() {} +func (UnionString) ImplementsCloudforceOneRequestMessageDeleteResponseUnion() {} +func (UnionString) ImplementsCloudforceOneRequestPriorityDeleteResponseUnion() {} func (UnionString) ImplementsEventNotificationsR2ConfigurationQueueDeleteResponseUnion() {} type UnionInt int64