From c9866463c6c4604d31d29c7100d09e0690d80c5e Mon Sep 17 00:00:00 2001 From: stainless-bot Date: Mon, 4 Nov 2024 04:36:04 +0000 Subject: [PATCH] feat(api): remap models to newer bundle names --- api.md | 63 +-- argo/tieredcaching.go | 5 +- cache/cachereserve.go | 10 +- cache/regionaltieredcache.go | 4 +- cache/smarttieredcache.go | 6 +- cache/variant.go | 93 ++-- cloudforce_one/request.go | 491 ++++++------------ cloudforce_one/requestmessage.go | 101 +--- cloudforce_one/requestpriority.go | 334 ++---------- cloudforce_one/requestpriority_test.go | 20 +- .../originpostquantumencryption.go | 5 +- 11 files changed, 339 insertions(+), 793 deletions(-) diff --git a/api.md b/api.md index d4b60578f28..9a92e5bcc84 100644 --- a/api.md +++ b/api.md @@ -644,16 +644,19 @@ Methods: ## Variants +Params Types: + +- cache.CacheVariantIdentifierParam + Response Types: -- cache.CacheVariantIdentifier -- cache.VariantDeleteResponse +- cache.CacheVariant - cache.VariantEditResponse - cache.VariantGetResponse Methods: -- client.Cache.Variants.Delete(ctx context.Context, body cache.VariantDeleteParams) (cache.VariantDeleteResponse, error) +- client.Cache.Variants.Delete(ctx context.Context, body cache.VariantDeleteParams) (cache.CacheVariant, error) - client.Cache.Variants.Edit(ctx context.Context, params cache.VariantEditParams) (cache.VariantEditResponse, error) - client.Cache.Variants.Get(ctx context.Context, query cache.VariantGetParams) (cache.VariantGetResponse, error) @@ -7031,58 +7034,58 @@ Methods: Response Types: -- cloudforce_one.RequestNewResponse -- cloudforce_one.RequestUpdateResponse -- cloudforce_one.RequestListResponse +- cloudforce_one.Item +- cloudforce_one.ListItem +- cloudforce_one.Quota +- cloudforce_one.RequestConstants +- cloudforce_one.RequestTypes - cloudforce_one.RequestDeleteResponse -- cloudforce_one.RequestConstantsResponse -- cloudforce_one.RequestGetResponse -- cloudforce_one.RequestQuotaResponse Methods: -- client.CloudforceOne.Requests.New(ctx context.Context, accountIdentifier string, body cloudforce_one.RequestNewParams) (cloudforce_one.RequestNewResponse, error) -- client.CloudforceOne.Requests.Update(ctx context.Context, accountIdentifier string, requestIdentifier string, body cloudforce_one.RequestUpdateParams) (cloudforce_one.RequestUpdateResponse, error) -- client.CloudforceOne.Requests.List(ctx context.Context, accountIdentifier string, body cloudforce_one.RequestListParams) (pagination.V4PagePaginationArray[cloudforce_one.RequestListResponse], error) +- 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.Constants(ctx context.Context, accountIdentifier string) (cloudforce_one.RequestConstantsResponse, error) -- client.CloudforceOne.Requests.Get(ctx context.Context, accountIdentifier string, requestIdentifier string) (cloudforce_one.RequestGetResponse, error) -- client.CloudforceOne.Requests.Quota(ctx context.Context, accountIdentifier string) (cloudforce_one.RequestQuotaResponse, error) -- client.CloudforceOne.Requests.Types(ctx context.Context, accountIdentifier string) ([]string, 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) +- client.CloudforceOne.Requests.Types(ctx context.Context, accountIdentifier string) (cloudforce_one.RequestTypes, error) ### Message Response Types: -- cloudforce_one.RequestMessageNewResponse -- cloudforce_one.RequestMessageUpdateResponse +- cloudforce_one.Message - cloudforce_one.RequestMessageDeleteResponse -- cloudforce_one.RequestMessageGetResponse Methods: -- client.CloudforceOne.Requests.Message.New(ctx context.Context, accountIdentifier string, requestIdentifier string, body cloudforce_one.RequestMessageNewParams) (cloudforce_one.RequestMessageNewResponse, error) -- client.CloudforceOne.Requests.Message.Update(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64, body cloudforce_one.RequestMessageUpdateParams) (cloudforce_one.RequestMessageUpdateResponse, error) +- 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.Get(ctx context.Context, accountIdentifier string, requestIdentifier string, body cloudforce_one.RequestMessageGetParams) ([]cloudforce_one.RequestMessageGetResponse, error) +- client.CloudforceOne.Requests.Message.Get(ctx context.Context, accountIdentifier string, requestIdentifier string, body cloudforce_one.RequestMessageGetParams) ([]cloudforce_one.Message, error) ### Priority +Params Types: + +- cloudforce_one.LabelParam +- cloudforce_one.PriorityEditParam + Response Types: -- cloudforce_one.RequestPriorityNewResponse -- cloudforce_one.RequestPriorityUpdateResponse +- cloudforce_one.Label +- cloudforce_one.Priority - cloudforce_one.RequestPriorityDeleteResponse -- cloudforce_one.RequestPriorityGetResponse -- cloudforce_one.RequestPriorityQuotaResponse Methods: -- client.CloudforceOne.Requests.Priority.New(ctx context.Context, accountIdentifier string, body cloudforce_one.RequestPriorityNewParams) (cloudforce_one.RequestPriorityNewResponse, error) -- client.CloudforceOne.Requests.Priority.Update(ctx context.Context, accountIdentifier string, priorityIdentifer string, body cloudforce_one.RequestPriorityUpdateParams) (cloudforce_one.RequestPriorityUpdateResponse, error) +- 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.Get(ctx context.Context, accountIdentifier string, priorityIdentifer string) (cloudforce_one.RequestPriorityGetResponse, error) -- client.CloudforceOne.Requests.Priority.Quota(ctx context.Context, accountIdentifier string) (cloudforce_one.RequestPriorityQuotaResponse, 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) ### Assets diff --git a/argo/tieredcaching.go b/argo/tieredcaching.go index 4b54c2e7a6c..26e854818b6 100644 --- a/argo/tieredcaching.go +++ b/argo/tieredcaching.go @@ -9,6 +9,7 @@ import ( "net/http" "time" + "github.com/cloudflare/cloudflare-go/v3/cache" "github.com/cloudflare/cloudflare-go/v3/internal/apijson" "github.com/cloudflare/cloudflare-go/v3/internal/param" "github.com/cloudflare/cloudflare-go/v3/internal/requestconfig" @@ -165,7 +166,7 @@ func (r TieredCachingGetResponseValue) IsKnown() bool { type TieredCachingEditParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` + ZoneID param.Field[cache.CacheVariantIdentifierParam] `path:"zone_id,required"` // Enables Tiered Caching. Value param.Field[TieredCachingEditParamsValue] `json:"value,required"` } @@ -235,7 +236,7 @@ func (r TieredCachingEditResponseEnvelopeSuccess) IsKnown() bool { type TieredCachingGetParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` + ZoneID param.Field[cache.CacheVariantIdentifierParam] `path:"zone_id,required"` } type TieredCachingGetResponseEnvelope struct { diff --git a/cache/cachereserve.go b/cache/cachereserve.go index 1506d03110f..457a25cfcea 100644 --- a/cache/cachereserve.go +++ b/cache/cachereserve.go @@ -343,8 +343,8 @@ func (r cacheReserveStatusResponseJSON) RawJSON() string { type CacheReserveClearParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Body interface{} `json:"body,required"` + ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"` + Body interface{} `json:"body,required"` } func (r CacheReserveClearParams) MarshalJSON() (data []byte, err error) { @@ -400,7 +400,7 @@ func (r CacheReserveClearResponseEnvelopeSuccess) IsKnown() bool { type CacheReserveEditParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` + ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"` // Value of the Cache Reserve zone setting. Value param.Field[CacheReserveEditParamsValue] `json:"value,required"` } @@ -476,7 +476,7 @@ func (r CacheReserveEditResponseEnvelopeSuccess) IsKnown() bool { type CacheReserveGetParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` + ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"` } type CacheReserveGetResponseEnvelope struct { @@ -530,7 +530,7 @@ func (r CacheReserveGetResponseEnvelopeSuccess) IsKnown() bool { type CacheReserveStatusParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` + ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"` } type CacheReserveStatusResponseEnvelope struct { diff --git a/cache/regionaltieredcache.go b/cache/regionaltieredcache.go index 062592974e5..f8ee1213f48 100644 --- a/cache/regionaltieredcache.go +++ b/cache/regionaltieredcache.go @@ -212,7 +212,7 @@ func (r regionalTieredCacheGetResponseValueJSON) RawJSON() string { type RegionalTieredCacheEditParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` + ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"` // Value of the Regional Tiered Cache zone setting. Value param.Field[RegionalTieredCacheEditParamsValue] `json:"value,required"` } @@ -285,7 +285,7 @@ func (r RegionalTieredCacheEditResponseEnvelopeSuccess) IsKnown() bool { type RegionalTieredCacheGetParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` + ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"` } type RegionalTieredCacheGetResponseEnvelope struct { diff --git a/cache/smarttieredcache.go b/cache/smarttieredcache.go index 9078b481859..14fb0a42702 100644 --- a/cache/smarttieredcache.go +++ b/cache/smarttieredcache.go @@ -229,7 +229,7 @@ func (r SmartTieredCacheGetResponseValue) IsKnown() bool { type SmartTieredCacheDeleteParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` + ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"` } type SmartTieredCacheDeleteResponseEnvelope struct { @@ -277,7 +277,7 @@ func (r SmartTieredCacheDeleteResponseEnvelopeSuccess) IsKnown() bool { type SmartTieredCacheEditParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` + ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"` // Enable or disable the Smart Tiered Cache Value param.Field[SmartTieredCacheEditParamsValue] `json:"value,required"` } @@ -347,7 +347,7 @@ func (r SmartTieredCacheEditResponseEnvelopeSuccess) IsKnown() bool { type SmartTieredCacheGetParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` + ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"` } type SmartTieredCacheGetResponseEnvelope struct { diff --git a/cache/variant.go b/cache/variant.go index a7fe60a282b..7e0dc912570 100644 --- a/cache/variant.go +++ b/cache/variant.go @@ -40,7 +40,7 @@ func NewVariantService(opts ...option.RequestOption) (r *VariantService) { // 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but // does not serve the variant requested, the response will not be cached. This will // be indicated with BYPASS cache status in the response headers. -func (r *VariantService) Delete(ctx context.Context, body VariantDeleteParams, opts ...option.RequestOption) (res *VariantDeleteResponse, err error) { +func (r *VariantService) Delete(ctx context.Context, body VariantDeleteParams, opts ...option.RequestOption) (res *CacheVariant, err error) { var env VariantDeleteResponseEnvelope opts = append(r.Options[:], opts...) if body.ZoneID.Value == "" { @@ -98,51 +98,52 @@ func (r *VariantService) Get(ctx context.Context, query VariantGetParams, opts . return } -// ID of the zone setting. -type CacheVariantIdentifier string - -const ( - CacheVariantIdentifierVariants CacheVariantIdentifier = "variants" -) - -func (r CacheVariantIdentifier) IsKnown() bool { - switch r { - case CacheVariantIdentifierVariants: - return true - } - return false -} - // Variant support enables caching variants of images with certain file extensions // in addition to the original. This only applies when the origin server sends the // 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but // does not serve the variant requested, the response will not be cached. This will // be indicated with BYPASS cache status in the response headers. -type VariantDeleteResponse struct { +type CacheVariant struct { // ID of the zone setting. - ID CacheVariantIdentifier `json:"id,required"` + ID CacheVariantID `json:"id,required"` // last time this setting was modified. - ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` - JSON variantDeleteResponseJSON `json:"-"` + ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` + JSON cacheVariantJSON `json:"-"` } -// variantDeleteResponseJSON contains the JSON metadata for the struct -// [VariantDeleteResponse] -type variantDeleteResponseJSON struct { +// cacheVariantJSON contains the JSON metadata for the struct [CacheVariant] +type cacheVariantJSON struct { ID apijson.Field ModifiedOn apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *VariantDeleteResponse) UnmarshalJSON(data []byte) (err error) { +func (r *CacheVariant) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r variantDeleteResponseJSON) RawJSON() string { +func (r cacheVariantJSON) RawJSON() string { return r.raw } +// ID of the zone setting. +type CacheVariantID string + +const ( + CacheVariantIDVariants CacheVariantID = "variants" +) + +func (r CacheVariantID) IsKnown() bool { + switch r { + case CacheVariantIDVariants: + return true + } + return false +} + +type CacheVariantIdentifierParam = string + // Variant support enables caching variants of images with certain file extensions // in addition to the original. This only applies when the origin server sends the // 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but @@ -150,7 +151,7 @@ func (r variantDeleteResponseJSON) RawJSON() string { // be indicated with BYPASS cache status in the response headers. type VariantEditResponse struct { // ID of the zone setting. - ID CacheVariantIdentifier `json:"id,required"` + ID VariantEditResponseID `json:"id,required"` // last time this setting was modified. ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` // Value of the zone setting. @@ -176,6 +177,21 @@ func (r variantEditResponseJSON) RawJSON() string { return r.raw } +// ID of the zone setting. +type VariantEditResponseID string + +const ( + VariantEditResponseIDVariants VariantEditResponseID = "variants" +) + +func (r VariantEditResponseID) IsKnown() bool { + switch r { + case VariantEditResponseIDVariants: + return true + } + return false +} + // Value of the zone setting. type VariantEditResponseValue struct { // List of strings with the MIME types of all the variants that should be served @@ -247,7 +263,7 @@ func (r variantEditResponseValueJSON) RawJSON() string { // be indicated with BYPASS cache status in the response headers. type VariantGetResponse struct { // ID of the zone setting. - ID CacheVariantIdentifier `json:"id,required"` + ID VariantGetResponseID `json:"id,required"` // last time this setting was modified. ModifiedOn time.Time `json:"modified_on,required,nullable" format:"date-time"` // Value of the zone setting. @@ -273,6 +289,21 @@ func (r variantGetResponseJSON) RawJSON() string { return r.raw } +// ID of the zone setting. +type VariantGetResponseID string + +const ( + VariantGetResponseIDVariants VariantGetResponseID = "variants" +) + +func (r VariantGetResponseID) IsKnown() bool { + switch r { + case VariantGetResponseIDVariants: + return true + } + return false +} + // Value of the zone setting. type VariantGetResponseValue struct { // List of strings with the MIME types of all the variants that should be served @@ -339,7 +370,7 @@ func (r variantGetResponseValueJSON) RawJSON() string { type VariantDeleteParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` + ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"` } type VariantDeleteResponseEnvelope struct { @@ -350,7 +381,7 @@ type VariantDeleteResponseEnvelope struct { // 'Vary: Accept' response header. If the origin server sends 'Vary: Accept' but // does not serve the variant requested, the response will not be cached. This will // be indicated with BYPASS cache status in the response headers. - Result VariantDeleteResponse `json:"result,required"` + Result CacheVariant `json:"result,required"` // Whether the API call was successful Success VariantDeleteResponseEnvelopeSuccess `json:"success,required"` JSON variantDeleteResponseEnvelopeJSON `json:"-"` @@ -392,7 +423,7 @@ func (r VariantDeleteResponseEnvelopeSuccess) IsKnown() bool { type VariantEditParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` + ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"` // Value of the zone setting. Value param.Field[VariantEditParamsValue] `json:"value,required"` } @@ -492,7 +523,7 @@ func (r VariantEditResponseEnvelopeSuccess) IsKnown() bool { type VariantGetParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` + ZoneID param.Field[CacheVariantIdentifierParam] `path:"zone_id,required"` } type VariantGetResponseEnvelope struct { diff --git a/cloudforce_one/request.go b/cloudforce_one/request.go index a043882c291..9c6a4fff15b 100644 --- a/cloudforce_one/request.go +++ b/cloudforce_one/request.go @@ -45,7 +45,7 @@ func NewRequestService(opts ...option.RequestOption) (r *RequestService) { // Creating a request adds the request into the Cloudforce One queue for analysis. // In addition to the content, a short title, type, priority, and releasability // should be provided. If one is not provided, a default will be assigned. -func (r *RequestService) New(ctx context.Context, accountIdentifier string, body RequestNewParams, opts ...option.RequestOption) (res *RequestNewResponse, err error) { +func (r *RequestService) New(ctx context.Context, accountIdentifier string, body RequestNewParams, opts ...option.RequestOption) (res *Item, err error) { var env RequestNewResponseEnvelope opts = append(r.Options[:], opts...) if accountIdentifier == "" { @@ -64,7 +64,7 @@ func (r *RequestService) New(ctx context.Context, accountIdentifier string, body // Updating a request alters the request in the Cloudforce One queue. This API may // be used to update any attributes of the request after the initial submission. // Only fields that you choose to update need to be add to the request body. -func (r *RequestService) Update(ctx context.Context, accountIdentifier string, requestIdentifier string, body RequestUpdateParams, opts ...option.RequestOption) (res *RequestUpdateResponse, err error) { +func (r *RequestService) Update(ctx context.Context, accountIdentifier string, requestIdentifier string, body RequestUpdateParams, opts ...option.RequestOption) (res *Item, err error) { var env RequestUpdateResponseEnvelope opts = append(r.Options[:], opts...) if accountIdentifier == "" { @@ -85,7 +85,7 @@ func (r *RequestService) Update(ctx context.Context, accountIdentifier string, r } // List Requests -func (r *RequestService) List(ctx context.Context, accountIdentifier string, body RequestListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[RequestListResponse], err error) { +func (r *RequestService) List(ctx context.Context, accountIdentifier string, body RequestListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[ListItem], err error) { var raw *http.Response opts = append(r.Options[:], opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -107,7 +107,7 @@ func (r *RequestService) List(ctx context.Context, accountIdentifier string, bod } // List Requests -func (r *RequestService) ListAutoPaging(ctx context.Context, accountIdentifier string, body RequestListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[RequestListResponse] { +func (r *RequestService) ListAutoPaging(ctx context.Context, accountIdentifier string, body RequestListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[ListItem] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, accountIdentifier, body, opts...)) } @@ -128,7 +128,7 @@ func (r *RequestService) Delete(ctx context.Context, accountIdentifier string, r } // Get Request Priority, Status, and TLP constants -func (r *RequestService) Constants(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *RequestConstantsResponse, err error) { +func (r *RequestService) Constants(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *RequestConstants, err error) { var env RequestConstantsResponseEnvelope opts = append(r.Options[:], opts...) if accountIdentifier == "" { @@ -145,7 +145,7 @@ func (r *RequestService) Constants(ctx context.Context, accountIdentifier string } // Get a Request -func (r *RequestService) Get(ctx context.Context, accountIdentifier string, requestIdentifier string, opts ...option.RequestOption) (res *RequestGetResponse, err error) { +func (r *RequestService) Get(ctx context.Context, accountIdentifier string, requestIdentifier string, opts ...option.RequestOption) (res *Item, err error) { var env RequestGetResponseEnvelope opts = append(r.Options[:], opts...) if accountIdentifier == "" { @@ -166,7 +166,7 @@ func (r *RequestService) Get(ctx context.Context, accountIdentifier string, requ } // Get Request Quota -func (r *RequestService) Quota(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *RequestQuotaResponse, err error) { +func (r *RequestService) Quota(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *Quota, err error) { var env RequestQuotaResponseEnvelope opts = append(r.Options[:], opts...) if accountIdentifier == "" { @@ -183,7 +183,7 @@ func (r *RequestService) Quota(ctx context.Context, accountIdentifier string, op } // Get Request Types -func (r *RequestService) Types(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *[]string, err error) { +func (r *RequestService) Types(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *RequestTypes, err error) { var env RequestTypesResponseEnvelope opts = append(r.Options[:], opts...) if accountIdentifier == "" { @@ -199,7 +199,7 @@ func (r *RequestService) Types(ctx context.Context, accountIdentifier string, op return } -type RequestNewResponse struct { +type Item struct { // UUID ID string `json:"id,required"` // Request content @@ -211,116 +211,22 @@ type RequestNewResponse struct { // Brief description of the request Summary string `json:"summary,required"` // The CISA defined Traffic Light Protocol (TLP) - TLP RequestNewResponseTLP `json:"tlp,required"` - Updated time.Time `json:"updated,required" format:"date-time"` - Completed time.Time `json:"completed" format:"date-time"` - // Tokens for the request messages - MessageTokens int64 `json:"message_tokens"` - // Readable Request ID - ReadableID string `json:"readable_id"` - // Request Status - Status RequestNewResponseStatus `json:"status"` - // Tokens for the request - Tokens int64 `json:"tokens"` - JSON requestNewResponseJSON `json:"-"` -} - -// requestNewResponseJSON contains the JSON metadata for the struct -// [RequestNewResponse] -type requestNewResponseJSON struct { - ID apijson.Field - Content apijson.Field - Created apijson.Field - Priority apijson.Field - Request apijson.Field - Summary apijson.Field - TLP apijson.Field - Updated apijson.Field - Completed apijson.Field - MessageTokens apijson.Field - ReadableID apijson.Field - Status apijson.Field - Tokens apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestNewResponseJSON) RawJSON() string { - return r.raw -} - -// The CISA defined Traffic Light Protocol (TLP) -type RequestNewResponseTLP string - -const ( - RequestNewResponseTLPClear RequestNewResponseTLP = "clear" - RequestNewResponseTLPAmber RequestNewResponseTLP = "amber" - RequestNewResponseTLPAmberStrict RequestNewResponseTLP = "amber-strict" - RequestNewResponseTLPGreen RequestNewResponseTLP = "green" - RequestNewResponseTLPRed RequestNewResponseTLP = "red" -) - -func (r RequestNewResponseTLP) IsKnown() bool { - switch r { - case RequestNewResponseTLPClear, RequestNewResponseTLPAmber, RequestNewResponseTLPAmberStrict, RequestNewResponseTLPGreen, RequestNewResponseTLPRed: - return true - } - return false -} - -// Request Status -type RequestNewResponseStatus string - -const ( - RequestNewResponseStatusOpen RequestNewResponseStatus = "open" - RequestNewResponseStatusAccepted RequestNewResponseStatus = "accepted" - RequestNewResponseStatusReported RequestNewResponseStatus = "reported" - RequestNewResponseStatusApproved RequestNewResponseStatus = "approved" - RequestNewResponseStatusCompleted RequestNewResponseStatus = "completed" - RequestNewResponseStatusDeclined RequestNewResponseStatus = "declined" -) - -func (r RequestNewResponseStatus) IsKnown() bool { - switch r { - case RequestNewResponseStatusOpen, RequestNewResponseStatusAccepted, RequestNewResponseStatusReported, RequestNewResponseStatusApproved, RequestNewResponseStatusCompleted, RequestNewResponseStatusDeclined: - return true - } - return false -} - -type RequestUpdateResponse struct { - // UUID - ID string `json:"id,required"` - // Request content - Content string `json:"content,required"` - Created time.Time `json:"created,required" format:"date-time"` - Priority time.Time `json:"priority,required" format:"date-time"` - // Requested information from request - Request string `json:"request,required"` - // Brief description of the request - Summary string `json:"summary,required"` - // The CISA defined Traffic Light Protocol (TLP) - TLP RequestUpdateResponseTLP `json:"tlp,required"` - Updated time.Time `json:"updated,required" format:"date-time"` - Completed time.Time `json:"completed" format:"date-time"` + TLP ItemTLP `json:"tlp,required"` + Updated time.Time `json:"updated,required" format:"date-time"` + Completed time.Time `json:"completed" format:"date-time"` // Tokens for the request messages MessageTokens int64 `json:"message_tokens"` // Readable Request ID ReadableID string `json:"readable_id"` // Request Status - Status RequestUpdateResponseStatus `json:"status"` + Status ItemStatus `json:"status"` // Tokens for the request - Tokens int64 `json:"tokens"` - JSON requestUpdateResponseJSON `json:"-"` + Tokens int64 `json:"tokens"` + JSON itemJSON `json:"-"` } -// requestUpdateResponseJSON contains the JSON metadata for the struct -// [RequestUpdateResponse] -type requestUpdateResponseJSON struct { +// itemJSON contains the JSON metadata for the struct [Item] +type itemJSON struct { ID apijson.Field Content apijson.Field Created apijson.Field @@ -338,65 +244,65 @@ type requestUpdateResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *RequestUpdateResponse) UnmarshalJSON(data []byte) (err error) { +func (r *Item) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r requestUpdateResponseJSON) RawJSON() string { +func (r itemJSON) RawJSON() string { return r.raw } // The CISA defined Traffic Light Protocol (TLP) -type RequestUpdateResponseTLP string +type ItemTLP string const ( - RequestUpdateResponseTLPClear RequestUpdateResponseTLP = "clear" - RequestUpdateResponseTLPAmber RequestUpdateResponseTLP = "amber" - RequestUpdateResponseTLPAmberStrict RequestUpdateResponseTLP = "amber-strict" - RequestUpdateResponseTLPGreen RequestUpdateResponseTLP = "green" - RequestUpdateResponseTLPRed RequestUpdateResponseTLP = "red" + ItemTLPClear ItemTLP = "clear" + ItemTLPAmber ItemTLP = "amber" + ItemTLPAmberStrict ItemTLP = "amber-strict" + ItemTLPGreen ItemTLP = "green" + ItemTLPRed ItemTLP = "red" ) -func (r RequestUpdateResponseTLP) IsKnown() bool { +func (r ItemTLP) IsKnown() bool { switch r { - case RequestUpdateResponseTLPClear, RequestUpdateResponseTLPAmber, RequestUpdateResponseTLPAmberStrict, RequestUpdateResponseTLPGreen, RequestUpdateResponseTLPRed: + case ItemTLPClear, ItemTLPAmber, ItemTLPAmberStrict, ItemTLPGreen, ItemTLPRed: return true } return false } // Request Status -type RequestUpdateResponseStatus string +type ItemStatus string const ( - RequestUpdateResponseStatusOpen RequestUpdateResponseStatus = "open" - RequestUpdateResponseStatusAccepted RequestUpdateResponseStatus = "accepted" - RequestUpdateResponseStatusReported RequestUpdateResponseStatus = "reported" - RequestUpdateResponseStatusApproved RequestUpdateResponseStatus = "approved" - RequestUpdateResponseStatusCompleted RequestUpdateResponseStatus = "completed" - RequestUpdateResponseStatusDeclined RequestUpdateResponseStatus = "declined" + ItemStatusOpen ItemStatus = "open" + ItemStatusAccepted ItemStatus = "accepted" + ItemStatusReported ItemStatus = "reported" + ItemStatusApproved ItemStatus = "approved" + ItemStatusCompleted ItemStatus = "completed" + ItemStatusDeclined ItemStatus = "declined" ) -func (r RequestUpdateResponseStatus) IsKnown() bool { +func (r ItemStatus) IsKnown() bool { switch r { - case RequestUpdateResponseStatusOpen, RequestUpdateResponseStatusAccepted, RequestUpdateResponseStatusReported, RequestUpdateResponseStatusApproved, RequestUpdateResponseStatusCompleted, RequestUpdateResponseStatusDeclined: + case ItemStatusOpen, ItemStatusAccepted, ItemStatusReported, ItemStatusApproved, ItemStatusCompleted, ItemStatusDeclined: return true } return false } -type RequestListResponse struct { +type ListItem struct { // UUID ID string `json:"id,required"` // Request creation time - Created time.Time `json:"created,required" format:"date-time"` - Priority RequestListResponsePriority `json:"priority,required"` + Created time.Time `json:"created,required" format:"date-time"` + Priority ListItemPriority `json:"priority,required"` // Requested information from request Request string `json:"request,required"` // Brief description of the request Summary string `json:"summary,required"` // The CISA defined Traffic Light Protocol (TLP) - TLP RequestListResponseTLP `json:"tlp,required"` + TLP ListItemTLP `json:"tlp,required"` // Request last updated time Updated time.Time `json:"updated,required" format:"date-time"` // Request completion time @@ -406,15 +312,14 @@ type RequestListResponse struct { // Readable Request ID ReadableID string `json:"readable_id"` // Request Status - Status RequestListResponseStatus `json:"status"` + Status ListItemStatus `json:"status"` // Tokens for the request - Tokens int64 `json:"tokens"` - JSON requestListResponseJSON `json:"-"` + Tokens int64 `json:"tokens"` + JSON listItemJSON `json:"-"` } -// requestListResponseJSON contains the JSON metadata for the struct -// [RequestListResponse] -type requestListResponseJSON struct { +// listItemJSON contains the JSON metadata for the struct [ListItem] +type listItemJSON struct { ID apijson.Field Created apijson.Field Priority apijson.Field @@ -431,120 +336,109 @@ type requestListResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *RequestListResponse) UnmarshalJSON(data []byte) (err error) { +func (r *ListItem) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r requestListResponseJSON) RawJSON() string { +func (r listItemJSON) RawJSON() string { return r.raw } -type RequestListResponsePriority string +type ListItemPriority string const ( - RequestListResponsePriorityRoutine RequestListResponsePriority = "routine" - RequestListResponsePriorityHigh RequestListResponsePriority = "high" - RequestListResponsePriorityUrgent RequestListResponsePriority = "urgent" + ListItemPriorityRoutine ListItemPriority = "routine" + ListItemPriorityHigh ListItemPriority = "high" + ListItemPriorityUrgent ListItemPriority = "urgent" ) -func (r RequestListResponsePriority) IsKnown() bool { +func (r ListItemPriority) IsKnown() bool { switch r { - case RequestListResponsePriorityRoutine, RequestListResponsePriorityHigh, RequestListResponsePriorityUrgent: + case ListItemPriorityRoutine, ListItemPriorityHigh, ListItemPriorityUrgent: return true } return false } // The CISA defined Traffic Light Protocol (TLP) -type RequestListResponseTLP string +type ListItemTLP string const ( - RequestListResponseTLPClear RequestListResponseTLP = "clear" - RequestListResponseTLPAmber RequestListResponseTLP = "amber" - RequestListResponseTLPAmberStrict RequestListResponseTLP = "amber-strict" - RequestListResponseTLPGreen RequestListResponseTLP = "green" - RequestListResponseTLPRed RequestListResponseTLP = "red" + ListItemTLPClear ListItemTLP = "clear" + ListItemTLPAmber ListItemTLP = "amber" + ListItemTLPAmberStrict ListItemTLP = "amber-strict" + ListItemTLPGreen ListItemTLP = "green" + ListItemTLPRed ListItemTLP = "red" ) -func (r RequestListResponseTLP) IsKnown() bool { +func (r ListItemTLP) IsKnown() bool { switch r { - case RequestListResponseTLPClear, RequestListResponseTLPAmber, RequestListResponseTLPAmberStrict, RequestListResponseTLPGreen, RequestListResponseTLPRed: + case ListItemTLPClear, ListItemTLPAmber, ListItemTLPAmberStrict, ListItemTLPGreen, ListItemTLPRed: return true } return false } // Request Status -type RequestListResponseStatus string +type ListItemStatus string const ( - RequestListResponseStatusOpen RequestListResponseStatus = "open" - RequestListResponseStatusAccepted RequestListResponseStatus = "accepted" - RequestListResponseStatusReported RequestListResponseStatus = "reported" - RequestListResponseStatusApproved RequestListResponseStatus = "approved" - RequestListResponseStatusCompleted RequestListResponseStatus = "completed" - RequestListResponseStatusDeclined RequestListResponseStatus = "declined" + ListItemStatusOpen ListItemStatus = "open" + ListItemStatusAccepted ListItemStatus = "accepted" + ListItemStatusReported ListItemStatus = "reported" + ListItemStatusApproved ListItemStatus = "approved" + ListItemStatusCompleted ListItemStatus = "completed" + ListItemStatusDeclined ListItemStatus = "declined" ) -func (r RequestListResponseStatus) IsKnown() bool { +func (r ListItemStatus) IsKnown() bool { switch r { - case RequestListResponseStatusOpen, RequestListResponseStatusAccepted, RequestListResponseStatusReported, RequestListResponseStatusApproved, RequestListResponseStatusCompleted, RequestListResponseStatusDeclined: + case ListItemStatusOpen, ListItemStatusAccepted, ListItemStatusReported, ListItemStatusApproved, ListItemStatusCompleted, ListItemStatusDeclined: return true } return false } -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:"-"` +type Quota struct { + // Anniversary date is when annual quota limit is refresh + AnniversaryDate time.Time `json:"anniversary_date" format:"date-time"` + // Quater anniversary date is when quota limit is refreshed each quarter + QuarterAnniversaryDate time.Time `json:"quarter_anniversary_date" format:"date-time"` + // Tokens for the quarter + Quota int64 `json:"quota"` + // Tokens remaining for the quarter + Remaining int64 `json:"remaining"` + JSON quotaJSON `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 +// quotaJSON contains the JSON metadata for the struct [Quota] +type quotaJSON struct { + AnniversaryDate apijson.Field + QuarterAnniversaryDate apijson.Field + Quota apijson.Field + Remaining apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *RequestDeleteResponse) UnmarshalJSON(data []byte) (err error) { +func (r *Quota) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r requestDeleteResponseJSON) RawJSON() string { +func (r quotaJSON) RawJSON() string { return r.raw } -// Whether the API call was successful -type RequestDeleteResponseSuccess bool - -const ( - RequestDeleteResponseSuccessTrue RequestDeleteResponseSuccess = true -) - -func (r RequestDeleteResponseSuccess) IsKnown() bool { - switch r { - case RequestDeleteResponseSuccessTrue: - return true - } - return false -} - -type RequestConstantsResponse struct { - Priority []RequestConstantsResponsePriority `json:"priority"` - Status []RequestConstantsResponseStatus `json:"status"` - TLP []RequestConstantsResponseTLP `json:"tlp"` - JSON requestConstantsResponseJSON `json:"-"` +type RequestConstants struct { + Priority []RequestConstantsPriority `json:"priority"` + Status []RequestConstantsStatus `json:"status"` + TLP []RequestConstantsTLP `json:"tlp"` + JSON requestConstantsJSON `json:"-"` } -// requestConstantsResponseJSON contains the JSON metadata for the struct -// [RequestConstantsResponse] -type requestConstantsResponseJSON struct { +// requestConstantsJSON contains the JSON metadata for the struct +// [RequestConstants] +type requestConstantsJSON struct { Priority apijson.Field Status apijson.Field TLP apijson.Field @@ -552,193 +446,112 @@ type requestConstantsResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *RequestConstantsResponse) UnmarshalJSON(data []byte) (err error) { +func (r *RequestConstants) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r requestConstantsResponseJSON) RawJSON() string { +func (r requestConstantsJSON) RawJSON() string { return r.raw } -type RequestConstantsResponsePriority string +type RequestConstantsPriority string const ( - RequestConstantsResponsePriorityRoutine RequestConstantsResponsePriority = "routine" - RequestConstantsResponsePriorityHigh RequestConstantsResponsePriority = "high" - RequestConstantsResponsePriorityUrgent RequestConstantsResponsePriority = "urgent" + RequestConstantsPriorityRoutine RequestConstantsPriority = "routine" + RequestConstantsPriorityHigh RequestConstantsPriority = "high" + RequestConstantsPriorityUrgent RequestConstantsPriority = "urgent" ) -func (r RequestConstantsResponsePriority) IsKnown() bool { +func (r RequestConstantsPriority) IsKnown() bool { switch r { - case RequestConstantsResponsePriorityRoutine, RequestConstantsResponsePriorityHigh, RequestConstantsResponsePriorityUrgent: + case RequestConstantsPriorityRoutine, RequestConstantsPriorityHigh, RequestConstantsPriorityUrgent: return true } return false } // Request Status -type RequestConstantsResponseStatus string +type RequestConstantsStatus string const ( - RequestConstantsResponseStatusOpen RequestConstantsResponseStatus = "open" - RequestConstantsResponseStatusAccepted RequestConstantsResponseStatus = "accepted" - RequestConstantsResponseStatusReported RequestConstantsResponseStatus = "reported" - RequestConstantsResponseStatusApproved RequestConstantsResponseStatus = "approved" - RequestConstantsResponseStatusCompleted RequestConstantsResponseStatus = "completed" - RequestConstantsResponseStatusDeclined RequestConstantsResponseStatus = "declined" + RequestConstantsStatusOpen RequestConstantsStatus = "open" + RequestConstantsStatusAccepted RequestConstantsStatus = "accepted" + RequestConstantsStatusReported RequestConstantsStatus = "reported" + RequestConstantsStatusApproved RequestConstantsStatus = "approved" + RequestConstantsStatusCompleted RequestConstantsStatus = "completed" + RequestConstantsStatusDeclined RequestConstantsStatus = "declined" ) -func (r RequestConstantsResponseStatus) IsKnown() bool { +func (r RequestConstantsStatus) IsKnown() bool { switch r { - case RequestConstantsResponseStatusOpen, RequestConstantsResponseStatusAccepted, RequestConstantsResponseStatusReported, RequestConstantsResponseStatusApproved, RequestConstantsResponseStatusCompleted, RequestConstantsResponseStatusDeclined: + case RequestConstantsStatusOpen, RequestConstantsStatusAccepted, RequestConstantsStatusReported, RequestConstantsStatusApproved, RequestConstantsStatusCompleted, RequestConstantsStatusDeclined: return true } return false } // The CISA defined Traffic Light Protocol (TLP) -type RequestConstantsResponseTLP string +type RequestConstantsTLP string const ( - RequestConstantsResponseTLPClear RequestConstantsResponseTLP = "clear" - RequestConstantsResponseTLPAmber RequestConstantsResponseTLP = "amber" - RequestConstantsResponseTLPAmberStrict RequestConstantsResponseTLP = "amber-strict" - RequestConstantsResponseTLPGreen RequestConstantsResponseTLP = "green" - RequestConstantsResponseTLPRed RequestConstantsResponseTLP = "red" + RequestConstantsTLPClear RequestConstantsTLP = "clear" + RequestConstantsTLPAmber RequestConstantsTLP = "amber" + RequestConstantsTLPAmberStrict RequestConstantsTLP = "amber-strict" + RequestConstantsTLPGreen RequestConstantsTLP = "green" + RequestConstantsTLPRed RequestConstantsTLP = "red" ) -func (r RequestConstantsResponseTLP) IsKnown() bool { +func (r RequestConstantsTLP) IsKnown() bool { switch r { - case RequestConstantsResponseTLPClear, RequestConstantsResponseTLPAmber, RequestConstantsResponseTLPAmberStrict, RequestConstantsResponseTLPGreen, RequestConstantsResponseTLPRed: + case RequestConstantsTLPClear, RequestConstantsTLPAmber, RequestConstantsTLPAmberStrict, RequestConstantsTLPGreen, RequestConstantsTLPRed: return true } return false } -type RequestGetResponse struct { - // UUID - ID string `json:"id,required"` - // Request content - Content string `json:"content,required"` - Created time.Time `json:"created,required" format:"date-time"` - Priority time.Time `json:"priority,required" format:"date-time"` - // Requested information from request - Request string `json:"request,required"` - // Brief description of the request - Summary string `json:"summary,required"` - // The CISA defined Traffic Light Protocol (TLP) - TLP RequestGetResponseTLP `json:"tlp,required"` - Updated time.Time `json:"updated,required" format:"date-time"` - Completed time.Time `json:"completed" format:"date-time"` - // Tokens for the request messages - MessageTokens int64 `json:"message_tokens"` - // Readable Request ID - ReadableID string `json:"readable_id"` - // Request Status - Status RequestGetResponseStatus `json:"status"` - // Tokens for the request - Tokens int64 `json:"tokens"` - JSON requestGetResponseJSON `json:"-"` +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:"-"` } -// requestGetResponseJSON contains the JSON metadata for the struct -// [RequestGetResponse] -type requestGetResponseJSON struct { - ID apijson.Field - Content apijson.Field - Created apijson.Field - Priority apijson.Field - Request apijson.Field - Summary apijson.Field - TLP apijson.Field - Updated apijson.Field - Completed apijson.Field - MessageTokens apijson.Field - ReadableID apijson.Field - Status apijson.Field - Tokens apijson.Field - raw string - ExtraFields map[string]apijson.Field +// 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 *RequestGetResponse) UnmarshalJSON(data []byte) (err error) { +func (r *RequestDeleteResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r requestGetResponseJSON) RawJSON() string { +func (r requestDeleteResponseJSON) RawJSON() string { return r.raw } -// The CISA defined Traffic Light Protocol (TLP) -type RequestGetResponseTLP string - -const ( - RequestGetResponseTLPClear RequestGetResponseTLP = "clear" - RequestGetResponseTLPAmber RequestGetResponseTLP = "amber" - RequestGetResponseTLPAmberStrict RequestGetResponseTLP = "amber-strict" - RequestGetResponseTLPGreen RequestGetResponseTLP = "green" - RequestGetResponseTLPRed RequestGetResponseTLP = "red" -) - -func (r RequestGetResponseTLP) IsKnown() bool { - switch r { - case RequestGetResponseTLPClear, RequestGetResponseTLPAmber, RequestGetResponseTLPAmberStrict, RequestGetResponseTLPGreen, RequestGetResponseTLPRed: - return true - } - return false -} - -// Request Status -type RequestGetResponseStatus string +// Whether the API call was successful +type RequestDeleteResponseSuccess bool const ( - RequestGetResponseStatusOpen RequestGetResponseStatus = "open" - RequestGetResponseStatusAccepted RequestGetResponseStatus = "accepted" - RequestGetResponseStatusReported RequestGetResponseStatus = "reported" - RequestGetResponseStatusApproved RequestGetResponseStatus = "approved" - RequestGetResponseStatusCompleted RequestGetResponseStatus = "completed" - RequestGetResponseStatusDeclined RequestGetResponseStatus = "declined" + RequestDeleteResponseSuccessTrue RequestDeleteResponseSuccess = true ) -func (r RequestGetResponseStatus) IsKnown() bool { +func (r RequestDeleteResponseSuccess) IsKnown() bool { switch r { - case RequestGetResponseStatusOpen, RequestGetResponseStatusAccepted, RequestGetResponseStatusReported, RequestGetResponseStatusApproved, RequestGetResponseStatusCompleted, RequestGetResponseStatusDeclined: + case RequestDeleteResponseSuccessTrue: return true } return false } -type RequestQuotaResponse struct { - // Anniversary date is when annual quota limit is refresh - AnniversaryDate time.Time `json:"anniversary_date" format:"date-time"` - // Quater anniversary date is when quota limit is refreshed each quarter - QuarterAnniversaryDate time.Time `json:"quarter_anniversary_date" format:"date-time"` - // Tokens for the quarter - Quota int64 `json:"quota"` - // Tokens remaining for the quarter - Remaining int64 `json:"remaining"` - JSON requestQuotaResponseJSON `json:"-"` -} - -// requestQuotaResponseJSON contains the JSON metadata for the struct -// [RequestQuotaResponse] -type requestQuotaResponseJSON struct { - AnniversaryDate apijson.Field - QuarterAnniversaryDate apijson.Field - Quota apijson.Field - Remaining apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestQuotaResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestQuotaResponseJSON) RawJSON() string { - return r.raw -} - type RequestNewParams struct { // Request content Content param.Field[string] `json:"content"` @@ -780,7 +593,7 @@ type RequestNewResponseEnvelope struct { Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success RequestNewResponseEnvelopeSuccess `json:"success,required"` - Result RequestNewResponse `json:"result"` + Result Item `json:"result"` JSON requestNewResponseEnvelopeJSON `json:"-"` } @@ -859,7 +672,7 @@ type RequestUpdateResponseEnvelope struct { Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success RequestUpdateResponseEnvelopeSuccess `json:"success,required"` - Result RequestUpdateResponse `json:"result"` + Result Item `json:"result"` JSON requestUpdateResponseEnvelopeJSON `json:"-"` } @@ -965,7 +778,7 @@ type RequestConstantsResponseEnvelope struct { Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success RequestConstantsResponseEnvelopeSuccess `json:"success,required"` - Result RequestConstantsResponse `json:"result"` + Result RequestConstants `json:"result"` JSON requestConstantsResponseEnvelopeJSON `json:"-"` } @@ -1008,7 +821,7 @@ type RequestGetResponseEnvelope struct { Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success RequestGetResponseEnvelopeSuccess `json:"success,required"` - Result RequestGetResponse `json:"result"` + Result Item `json:"result"` JSON requestGetResponseEnvelopeJSON `json:"-"` } @@ -1051,7 +864,7 @@ type RequestQuotaResponseEnvelope struct { Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success RequestQuotaResponseEnvelopeSuccess `json:"success,required"` - Result RequestQuotaResponse `json:"result"` + Result Quota `json:"result"` JSON requestQuotaResponseEnvelopeJSON `json:"-"` } @@ -1094,7 +907,7 @@ type RequestTypesResponseEnvelope struct { Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success RequestTypesResponseEnvelopeSuccess `json:"success,required"` - Result []string `json:"result"` + Result RequestTypes `json:"result"` JSON requestTypesResponseEnvelopeJSON `json:"-"` } diff --git a/cloudforce_one/requestmessage.go b/cloudforce_one/requestmessage.go index 8d11d342b6b..8e85eec4d74 100644 --- a/cloudforce_one/requestmessage.go +++ b/cloudforce_one/requestmessage.go @@ -36,7 +36,7 @@ func NewRequestMessageService(opts ...option.RequestOption) (r *RequestMessageSe } // Create a New Request Message -func (r *RequestMessageService) New(ctx context.Context, accountIdentifier string, requestIdentifier string, body RequestMessageNewParams, opts ...option.RequestOption) (res *RequestMessageNewResponse, err error) { +func (r *RequestMessageService) New(ctx context.Context, accountIdentifier string, requestIdentifier string, body RequestMessageNewParams, opts ...option.RequestOption) (res *Message, err error) { var env RequestMessageNewResponseEnvelope opts = append(r.Options[:], opts...) if accountIdentifier == "" { @@ -57,7 +57,7 @@ func (r *RequestMessageService) New(ctx context.Context, accountIdentifier strin } // Update a Request Message -func (r *RequestMessageService) Update(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64, body RequestMessageUpdateParams, opts ...option.RequestOption) (res *RequestMessageUpdateResponse, err error) { +func (r *RequestMessageService) Update(ctx context.Context, accountIdentifier string, requestIdentifier string, messageIdentifer int64, body RequestMessageUpdateParams, opts ...option.RequestOption) (res *Message, err error) { var env RequestMessageUpdateResponseEnvelope opts = append(r.Options[:], opts...) if accountIdentifier == "" { @@ -94,7 +94,7 @@ func (r *RequestMessageService) Delete(ctx context.Context, accountIdentifier st } // List Request Messages -func (r *RequestMessageService) Get(ctx context.Context, accountIdentifier string, requestIdentifier string, body RequestMessageGetParams, opts ...option.RequestOption) (res *[]RequestMessageGetResponse, err error) { +func (r *RequestMessageService) Get(ctx context.Context, accountIdentifier string, requestIdentifier string, body RequestMessageGetParams, opts ...option.RequestOption) (res *[]Message, err error) { var env RequestMessageGetResponseEnvelope opts = append(r.Options[:], opts...) if accountIdentifier == "" { @@ -114,7 +114,7 @@ func (r *RequestMessageService) Get(ctx context.Context, accountIdentifier strin return } -type RequestMessageNewResponse struct { +type Message struct { // Message ID ID int64 `json:"id,required"` // Author of message @@ -126,13 +126,12 @@ type RequestMessageNewResponse struct { // Message last updated time Updated time.Time `json:"updated,required" format:"date-time"` // Message creation time - Created time.Time `json:"created" format:"date-time"` - JSON requestMessageNewResponseJSON `json:"-"` + Created time.Time `json:"created" format:"date-time"` + JSON messageJSON `json:"-"` } -// requestMessageNewResponseJSON contains the JSON metadata for the struct -// [RequestMessageNewResponse] -type requestMessageNewResponseJSON struct { +// messageJSON contains the JSON metadata for the struct [Message] +type messageJSON struct { ID apijson.Field Author apijson.Field Content apijson.Field @@ -143,48 +142,11 @@ type requestMessageNewResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *RequestMessageNewResponse) UnmarshalJSON(data []byte) (err error) { +func (r *Message) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r requestMessageNewResponseJSON) RawJSON() string { - return r.raw -} - -type RequestMessageUpdateResponse struct { - // Message ID - ID int64 `json:"id,required"` - // Author of message - Author string `json:"author,required"` - // Content of message - Content string `json:"content,required"` - // Whether the message is a follow-on request - IsFollowOnRequest bool `json:"is_follow_on_request,required"` - // Message last updated time - Updated time.Time `json:"updated,required" format:"date-time"` - // Message creation time - Created time.Time `json:"created" format:"date-time"` - JSON requestMessageUpdateResponseJSON `json:"-"` -} - -// requestMessageUpdateResponseJSON contains the JSON metadata for the struct -// [RequestMessageUpdateResponse] -type requestMessageUpdateResponseJSON struct { - ID apijson.Field - Author apijson.Field - Content apijson.Field - IsFollowOnRequest apijson.Field - Updated apijson.Field - Created apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestMessageUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestMessageUpdateResponseJSON) RawJSON() string { +func (r messageJSON) RawJSON() string { return r.raw } @@ -229,43 +191,6 @@ func (r RequestMessageDeleteResponseSuccess) IsKnown() bool { return false } -type RequestMessageGetResponse struct { - // Message ID - ID int64 `json:"id,required"` - // Author of message - Author string `json:"author,required"` - // Content of message - Content string `json:"content,required"` - // Whether the message is a follow-on request - IsFollowOnRequest bool `json:"is_follow_on_request,required"` - // Message last updated time - Updated time.Time `json:"updated,required" format:"date-time"` - // Message creation time - Created time.Time `json:"created" format:"date-time"` - JSON requestMessageGetResponseJSON `json:"-"` -} - -// requestMessageGetResponseJSON contains the JSON metadata for the struct -// [RequestMessageGetResponse] -type requestMessageGetResponseJSON struct { - ID apijson.Field - Author apijson.Field - Content apijson.Field - IsFollowOnRequest apijson.Field - Updated apijson.Field - Created apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestMessageGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestMessageGetResponseJSON) RawJSON() string { - return r.raw -} - type RequestMessageNewParams struct { // Content of message Content param.Field[string] `json:"content"` @@ -280,7 +205,7 @@ type RequestMessageNewResponseEnvelope struct { Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success RequestMessageNewResponseEnvelopeSuccess `json:"success,required"` - Result RequestMessageNewResponse `json:"result"` + Result Message `json:"result"` JSON requestMessageNewResponseEnvelopeJSON `json:"-"` } @@ -332,7 +257,7 @@ type RequestMessageUpdateResponseEnvelope struct { Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success RequestMessageUpdateResponseEnvelopeSuccess `json:"success,required"` - Result RequestMessageUpdateResponse `json:"result"` + Result Message `json:"result"` JSON requestMessageUpdateResponseEnvelopeJSON `json:"-"` } @@ -410,7 +335,7 @@ type RequestMessageGetResponseEnvelope struct { Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success RequestMessageGetResponseEnvelopeSuccess `json:"success,required"` - Result []RequestMessageGetResponse `json:"result"` + Result []Message `json:"result"` JSON requestMessageGetResponseEnvelopeJSON `json:"-"` } diff --git a/cloudforce_one/requestpriority.go b/cloudforce_one/requestpriority.go index c748887aaf2..d487d1812ea 100644 --- a/cloudforce_one/requestpriority.go +++ b/cloudforce_one/requestpriority.go @@ -36,7 +36,7 @@ func NewRequestPriorityService(opts ...option.RequestOption) (r *RequestPriority } // Create a New Priority Intelligence Requirement -func (r *RequestPriorityService) New(ctx context.Context, accountIdentifier string, body RequestPriorityNewParams, opts ...option.RequestOption) (res *RequestPriorityNewResponse, err error) { +func (r *RequestPriorityService) New(ctx context.Context, accountIdentifier string, body RequestPriorityNewParams, opts ...option.RequestOption) (res *Priority, err error) { var env RequestPriorityNewResponseEnvelope opts = append(r.Options[:], opts...) if accountIdentifier == "" { @@ -53,7 +53,7 @@ func (r *RequestPriorityService) New(ctx context.Context, accountIdentifier stri } // Update a Priority Intelligence Requirement -func (r *RequestPriorityService) Update(ctx context.Context, accountIdentifier string, priorityIdentifer string, body RequestPriorityUpdateParams, opts ...option.RequestOption) (res *RequestPriorityUpdateResponse, err error) { +func (r *RequestPriorityService) Update(ctx context.Context, accountIdentifier string, priorityIdentifer string, body RequestPriorityUpdateParams, opts ...option.RequestOption) (res *Item, err error) { var env RequestPriorityUpdateResponseEnvelope opts = append(r.Options[:], opts...) if accountIdentifier == "" { @@ -90,7 +90,7 @@ func (r *RequestPriorityService) Delete(ctx context.Context, accountIdentifier s } // Get a Priority Intelligence Requirement -func (r *RequestPriorityService) Get(ctx context.Context, accountIdentifier string, priorityIdentifer string, opts ...option.RequestOption) (res *RequestPriorityGetResponse, err error) { +func (r *RequestPriorityService) Get(ctx context.Context, accountIdentifier string, priorityIdentifer string, opts ...option.RequestOption) (res *Item, err error) { var env RequestPriorityGetResponseEnvelope opts = append(r.Options[:], opts...) if accountIdentifier == "" { @@ -111,7 +111,7 @@ func (r *RequestPriorityService) Get(ctx context.Context, accountIdentifier stri } // Get Priority Intelligence Requirement Quota -func (r *RequestPriorityService) Quota(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *RequestPriorityQuotaResponse, err error) { +func (r *RequestPriorityService) Quota(ctx context.Context, accountIdentifier string, opts ...option.RequestOption) (res *Quota, err error) { var env RequestPriorityQuotaResponseEnvelope opts = append(r.Options[:], opts...) if accountIdentifier == "" { @@ -127,27 +127,30 @@ func (r *RequestPriorityService) Quota(ctx context.Context, accountIdentifier st return } -type RequestPriorityNewResponse struct { +type Label = string + +type LabelParam = string + +type Priority struct { // UUID ID string `json:"id,required"` // Priority creation time Created time.Time `json:"created,required" format:"date-time"` // List of labels - Labels []string `json:"labels,required"` + Labels []Label `json:"labels,required"` // Priority Priority int64 `json:"priority,required"` // Requirement Requirement string `json:"requirement,required"` // The CISA defined Traffic Light Protocol (TLP) - TLP RequestPriorityNewResponseTLP `json:"tlp,required"` + TLP PriorityTLP `json:"tlp,required"` // Priority last updated time - Updated time.Time `json:"updated,required" format:"date-time"` - JSON requestPriorityNewResponseJSON `json:"-"` + Updated time.Time `json:"updated,required" format:"date-time"` + JSON priorityJSON `json:"-"` } -// requestPriorityNewResponseJSON contains the JSON metadata for the struct -// [RequestPriorityNewResponse] -type requestPriorityNewResponseJSON struct { +// priorityJSON contains the JSON metadata for the struct [Priority] +type priorityJSON struct { ID apijson.Field Created apijson.Field Labels apijson.Field @@ -159,121 +162,62 @@ type requestPriorityNewResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *RequestPriorityNewResponse) UnmarshalJSON(data []byte) (err error) { +func (r *Priority) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r requestPriorityNewResponseJSON) RawJSON() string { +func (r priorityJSON) RawJSON() string { return r.raw } // The CISA defined Traffic Light Protocol (TLP) -type RequestPriorityNewResponseTLP string +type PriorityTLP string const ( - RequestPriorityNewResponseTLPClear RequestPriorityNewResponseTLP = "clear" - RequestPriorityNewResponseTLPAmber RequestPriorityNewResponseTLP = "amber" - RequestPriorityNewResponseTLPAmberStrict RequestPriorityNewResponseTLP = "amber-strict" - RequestPriorityNewResponseTLPGreen RequestPriorityNewResponseTLP = "green" - RequestPriorityNewResponseTLPRed RequestPriorityNewResponseTLP = "red" + PriorityTLPClear PriorityTLP = "clear" + PriorityTLPAmber PriorityTLP = "amber" + PriorityTLPAmberStrict PriorityTLP = "amber-strict" + PriorityTLPGreen PriorityTLP = "green" + PriorityTLPRed PriorityTLP = "red" ) -func (r RequestPriorityNewResponseTLP) IsKnown() bool { +func (r PriorityTLP) IsKnown() bool { switch r { - case RequestPriorityNewResponseTLPClear, RequestPriorityNewResponseTLPAmber, RequestPriorityNewResponseTLPAmberStrict, RequestPriorityNewResponseTLPGreen, RequestPriorityNewResponseTLPRed: + case PriorityTLPClear, PriorityTLPAmber, PriorityTLPAmberStrict, PriorityTLPGreen, PriorityTLPRed: return true } return false } -type RequestPriorityUpdateResponse struct { - // UUID - ID string `json:"id,required"` - // Request content - Content string `json:"content,required"` - Created time.Time `json:"created,required" format:"date-time"` - Priority time.Time `json:"priority,required" format:"date-time"` - // Requested information from request - Request string `json:"request,required"` - // Brief description of the request - Summary string `json:"summary,required"` +type PriorityEditParam struct { + // List of labels + Labels param.Field[[]LabelParam] `json:"labels,required"` + // Priority + Priority param.Field[int64] `json:"priority,required"` + // Requirement + Requirement param.Field[string] `json:"requirement,required"` // The CISA defined Traffic Light Protocol (TLP) - TLP RequestPriorityUpdateResponseTLP `json:"tlp,required"` - Updated time.Time `json:"updated,required" format:"date-time"` - Completed time.Time `json:"completed" format:"date-time"` - // Tokens for the request messages - MessageTokens int64 `json:"message_tokens"` - // Readable Request ID - ReadableID string `json:"readable_id"` - // Request Status - Status RequestPriorityUpdateResponseStatus `json:"status"` - // Tokens for the request - Tokens int64 `json:"tokens"` - JSON requestPriorityUpdateResponseJSON `json:"-"` -} - -// requestPriorityUpdateResponseJSON contains the JSON metadata for the struct -// [RequestPriorityUpdateResponse] -type requestPriorityUpdateResponseJSON struct { - ID apijson.Field - Content apijson.Field - Created apijson.Field - Priority apijson.Field - Request apijson.Field - Summary apijson.Field - TLP apijson.Field - Updated apijson.Field - Completed apijson.Field - MessageTokens apijson.Field - ReadableID apijson.Field - Status apijson.Field - Tokens apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestPriorityUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) + TLP param.Field[PriorityEditTLP] `json:"tlp,required"` } -func (r requestPriorityUpdateResponseJSON) RawJSON() string { - return r.raw +func (r PriorityEditParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } // The CISA defined Traffic Light Protocol (TLP) -type RequestPriorityUpdateResponseTLP string +type PriorityEditTLP string const ( - RequestPriorityUpdateResponseTLPClear RequestPriorityUpdateResponseTLP = "clear" - RequestPriorityUpdateResponseTLPAmber RequestPriorityUpdateResponseTLP = "amber" - RequestPriorityUpdateResponseTLPAmberStrict RequestPriorityUpdateResponseTLP = "amber-strict" - RequestPriorityUpdateResponseTLPGreen RequestPriorityUpdateResponseTLP = "green" - RequestPriorityUpdateResponseTLPRed RequestPriorityUpdateResponseTLP = "red" + PriorityEditTLPClear PriorityEditTLP = "clear" + PriorityEditTLPAmber PriorityEditTLP = "amber" + PriorityEditTLPAmberStrict PriorityEditTLP = "amber-strict" + PriorityEditTLPGreen PriorityEditTLP = "green" + PriorityEditTLPRed PriorityEditTLP = "red" ) -func (r RequestPriorityUpdateResponseTLP) IsKnown() bool { +func (r PriorityEditTLP) IsKnown() bool { switch r { - case RequestPriorityUpdateResponseTLPClear, RequestPriorityUpdateResponseTLPAmber, RequestPriorityUpdateResponseTLPAmberStrict, RequestPriorityUpdateResponseTLPGreen, RequestPriorityUpdateResponseTLPRed: - return true - } - return false -} - -// Request Status -type RequestPriorityUpdateResponseStatus string - -const ( - RequestPriorityUpdateResponseStatusOpen RequestPriorityUpdateResponseStatus = "open" - RequestPriorityUpdateResponseStatusAccepted RequestPriorityUpdateResponseStatus = "accepted" - RequestPriorityUpdateResponseStatusReported RequestPriorityUpdateResponseStatus = "reported" - RequestPriorityUpdateResponseStatusApproved RequestPriorityUpdateResponseStatus = "approved" - RequestPriorityUpdateResponseStatusCompleted RequestPriorityUpdateResponseStatus = "completed" - RequestPriorityUpdateResponseStatusDeclined RequestPriorityUpdateResponseStatus = "declined" -) - -func (r RequestPriorityUpdateResponseStatus) IsKnown() bool { - switch r { - case RequestPriorityUpdateResponseStatusOpen, RequestPriorityUpdateResponseStatusAccepted, RequestPriorityUpdateResponseStatusReported, RequestPriorityUpdateResponseStatusApproved, RequestPriorityUpdateResponseStatusCompleted, RequestPriorityUpdateResponseStatusDeclined: + case PriorityEditTLPClear, PriorityEditTLPAmber, PriorityEditTLPAmberStrict, PriorityEditTLPGreen, PriorityEditTLPRed: return true } return false @@ -320,162 +264,12 @@ func (r RequestPriorityDeleteResponseSuccess) IsKnown() bool { return false } -type RequestPriorityGetResponse struct { - // UUID - ID string `json:"id,required"` - // Request content - Content string `json:"content,required"` - Created time.Time `json:"created,required" format:"date-time"` - Priority time.Time `json:"priority,required" format:"date-time"` - // Requested information from request - Request string `json:"request,required"` - // Brief description of the request - Summary string `json:"summary,required"` - // The CISA defined Traffic Light Protocol (TLP) - TLP RequestPriorityGetResponseTLP `json:"tlp,required"` - Updated time.Time `json:"updated,required" format:"date-time"` - Completed time.Time `json:"completed" format:"date-time"` - // Tokens for the request messages - MessageTokens int64 `json:"message_tokens"` - // Readable Request ID - ReadableID string `json:"readable_id"` - // Request Status - Status RequestPriorityGetResponseStatus `json:"status"` - // Tokens for the request - Tokens int64 `json:"tokens"` - JSON requestPriorityGetResponseJSON `json:"-"` -} - -// requestPriorityGetResponseJSON contains the JSON metadata for the struct -// [RequestPriorityGetResponse] -type requestPriorityGetResponseJSON struct { - ID apijson.Field - Content apijson.Field - Created apijson.Field - Priority apijson.Field - Request apijson.Field - Summary apijson.Field - TLP apijson.Field - Updated apijson.Field - Completed apijson.Field - MessageTokens apijson.Field - ReadableID apijson.Field - Status apijson.Field - Tokens apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestPriorityGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestPriorityGetResponseJSON) RawJSON() string { - return r.raw -} - -// The CISA defined Traffic Light Protocol (TLP) -type RequestPriorityGetResponseTLP string - -const ( - RequestPriorityGetResponseTLPClear RequestPriorityGetResponseTLP = "clear" - RequestPriorityGetResponseTLPAmber RequestPriorityGetResponseTLP = "amber" - RequestPriorityGetResponseTLPAmberStrict RequestPriorityGetResponseTLP = "amber-strict" - RequestPriorityGetResponseTLPGreen RequestPriorityGetResponseTLP = "green" - RequestPriorityGetResponseTLPRed RequestPriorityGetResponseTLP = "red" -) - -func (r RequestPriorityGetResponseTLP) IsKnown() bool { - switch r { - case RequestPriorityGetResponseTLPClear, RequestPriorityGetResponseTLPAmber, RequestPriorityGetResponseTLPAmberStrict, RequestPriorityGetResponseTLPGreen, RequestPriorityGetResponseTLPRed: - return true - } - return false -} - -// Request Status -type RequestPriorityGetResponseStatus string - -const ( - RequestPriorityGetResponseStatusOpen RequestPriorityGetResponseStatus = "open" - RequestPriorityGetResponseStatusAccepted RequestPriorityGetResponseStatus = "accepted" - RequestPriorityGetResponseStatusReported RequestPriorityGetResponseStatus = "reported" - RequestPriorityGetResponseStatusApproved RequestPriorityGetResponseStatus = "approved" - RequestPriorityGetResponseStatusCompleted RequestPriorityGetResponseStatus = "completed" - RequestPriorityGetResponseStatusDeclined RequestPriorityGetResponseStatus = "declined" -) - -func (r RequestPriorityGetResponseStatus) IsKnown() bool { - switch r { - case RequestPriorityGetResponseStatusOpen, RequestPriorityGetResponseStatusAccepted, RequestPriorityGetResponseStatusReported, RequestPriorityGetResponseStatusApproved, RequestPriorityGetResponseStatusCompleted, RequestPriorityGetResponseStatusDeclined: - return true - } - return false -} - -type RequestPriorityQuotaResponse struct { - // Anniversary date is when annual quota limit is refresh - AnniversaryDate time.Time `json:"anniversary_date" format:"date-time"` - // Quater anniversary date is when quota limit is refreshed each quarter - QuarterAnniversaryDate time.Time `json:"quarter_anniversary_date" format:"date-time"` - // Tokens for the quarter - Quota int64 `json:"quota"` - // Tokens remaining for the quarter - Remaining int64 `json:"remaining"` - JSON requestPriorityQuotaResponseJSON `json:"-"` -} - -// requestPriorityQuotaResponseJSON contains the JSON metadata for the struct -// [RequestPriorityQuotaResponse] -type requestPriorityQuotaResponseJSON struct { - AnniversaryDate apijson.Field - QuarterAnniversaryDate apijson.Field - Quota apijson.Field - Remaining apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RequestPriorityQuotaResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r requestPriorityQuotaResponseJSON) RawJSON() string { - return r.raw -} - type RequestPriorityNewParams struct { - // List of labels - Labels param.Field[[]string] `json:"labels,required"` - // Priority - Priority param.Field[int64] `json:"priority,required"` - // Requirement - Requirement param.Field[string] `json:"requirement,required"` - // The CISA defined Traffic Light Protocol (TLP) - TLP param.Field[RequestPriorityNewParamsTLP] `json:"tlp,required"` + PriorityEdit PriorityEditParam `json:"priority_edit,required"` } func (r RequestPriorityNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The CISA defined Traffic Light Protocol (TLP) -type RequestPriorityNewParamsTLP string - -const ( - RequestPriorityNewParamsTLPClear RequestPriorityNewParamsTLP = "clear" - RequestPriorityNewParamsTLPAmber RequestPriorityNewParamsTLP = "amber" - RequestPriorityNewParamsTLPAmberStrict RequestPriorityNewParamsTLP = "amber-strict" - RequestPriorityNewParamsTLPGreen RequestPriorityNewParamsTLP = "green" - RequestPriorityNewParamsTLPRed RequestPriorityNewParamsTLP = "red" -) - -func (r RequestPriorityNewParamsTLP) IsKnown() bool { - switch r { - case RequestPriorityNewParamsTLPClear, RequestPriorityNewParamsTLPAmber, RequestPriorityNewParamsTLPAmberStrict, RequestPriorityNewParamsTLPGreen, RequestPriorityNewParamsTLPRed: - return true - } - return false + return apijson.MarshalRoot(r.PriorityEdit) } type RequestPriorityNewResponseEnvelope struct { @@ -483,7 +277,7 @@ type RequestPriorityNewResponseEnvelope struct { Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success RequestPriorityNewResponseEnvelopeSuccess `json:"success,required"` - Result RequestPriorityNewResponse `json:"result"` + Result Priority `json:"result"` JSON requestPriorityNewResponseEnvelopeJSON `json:"-"` } @@ -522,37 +316,11 @@ func (r RequestPriorityNewResponseEnvelopeSuccess) IsKnown() bool { } type RequestPriorityUpdateParams struct { - // List of labels - Labels param.Field[[]string] `json:"labels,required"` - // Priority - Priority param.Field[int64] `json:"priority,required"` - // Requirement - Requirement param.Field[string] `json:"requirement,required"` - // The CISA defined Traffic Light Protocol (TLP) - TLP param.Field[RequestPriorityUpdateParamsTLP] `json:"tlp,required"` + PriorityEdit PriorityEditParam `json:"priority_edit,required"` } func (r RequestPriorityUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The CISA defined Traffic Light Protocol (TLP) -type RequestPriorityUpdateParamsTLP string - -const ( - RequestPriorityUpdateParamsTLPClear RequestPriorityUpdateParamsTLP = "clear" - RequestPriorityUpdateParamsTLPAmber RequestPriorityUpdateParamsTLP = "amber" - RequestPriorityUpdateParamsTLPAmberStrict RequestPriorityUpdateParamsTLP = "amber-strict" - RequestPriorityUpdateParamsTLPGreen RequestPriorityUpdateParamsTLP = "green" - RequestPriorityUpdateParamsTLPRed RequestPriorityUpdateParamsTLP = "red" -) - -func (r RequestPriorityUpdateParamsTLP) IsKnown() bool { - switch r { - case RequestPriorityUpdateParamsTLPClear, RequestPriorityUpdateParamsTLPAmber, RequestPriorityUpdateParamsTLPAmberStrict, RequestPriorityUpdateParamsTLPGreen, RequestPriorityUpdateParamsTLPRed: - return true - } - return false + return apijson.MarshalRoot(r.PriorityEdit) } type RequestPriorityUpdateResponseEnvelope struct { @@ -560,7 +328,7 @@ type RequestPriorityUpdateResponseEnvelope struct { Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success RequestPriorityUpdateResponseEnvelopeSuccess `json:"success,required"` - Result RequestPriorityUpdateResponse `json:"result"` + Result Item `json:"result"` JSON requestPriorityUpdateResponseEnvelopeJSON `json:"-"` } @@ -603,7 +371,7 @@ type RequestPriorityGetResponseEnvelope struct { Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success RequestPriorityGetResponseEnvelopeSuccess `json:"success,required"` - Result RequestPriorityGetResponse `json:"result"` + Result Item `json:"result"` JSON requestPriorityGetResponseEnvelopeJSON `json:"-"` } @@ -646,7 +414,7 @@ type RequestPriorityQuotaResponseEnvelope struct { Messages []shared.ResponseInfo `json:"messages,required"` // Whether the API call was successful Success RequestPriorityQuotaResponseEnvelopeSuccess `json:"success,required"` - Result RequestPriorityQuotaResponse `json:"result"` + Result Quota `json:"result"` JSON requestPriorityQuotaResponseEnvelopeJSON `json:"-"` } diff --git a/cloudforce_one/requestpriority_test.go b/cloudforce_one/requestpriority_test.go index 65d7eb80687..269a92b53df 100644 --- a/cloudforce_one/requestpriority_test.go +++ b/cloudforce_one/requestpriority_test.go @@ -31,10 +31,12 @@ func TestRequestPriorityNew(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", cloudforce_one.RequestPriorityNewParams{ - Labels: cloudflare.F([]string{"DoS", "CVE"}), - Priority: cloudflare.F(int64(1)), - Requirement: cloudflare.F("DoS attacks carried out by CVEs"), - TLP: cloudflare.F(cloudforce_one.RequestPriorityNewParamsTLPClear), + PriorityEdit: cloudforce_one.PriorityEditParam{ + Labels: cloudflare.F([]cloudforce_one.LabelParam{"DoS", "CVE"}), + Priority: cloudflare.F(int64(1)), + Requirement: cloudflare.F("DoS attacks carried out by CVEs"), + TLP: cloudflare.F(cloudforce_one.PriorityEditTLPClear), + }, }, ) if err != nil { @@ -64,10 +66,12 @@ func TestRequestPriorityUpdate(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", cloudforce_one.RequestPriorityUpdateParams{ - Labels: cloudflare.F([]string{"DoS", "CVE"}), - Priority: cloudflare.F(int64(1)), - Requirement: cloudflare.F("DoS attacks carried out by CVEs"), - TLP: cloudflare.F(cloudforce_one.RequestPriorityUpdateParamsTLPClear), + PriorityEdit: cloudforce_one.PriorityEditParam{ + Labels: cloudflare.F([]cloudforce_one.LabelParam{"DoS", "CVE"}), + Priority: cloudflare.F(int64(1)), + Requirement: cloudflare.F("DoS attacks carried out by CVEs"), + TLP: cloudflare.F(cloudforce_one.PriorityEditTLPClear), + }, }, ) if err != nil { diff --git a/origin_post_quantum_encryption/originpostquantumencryption.go b/origin_post_quantum_encryption/originpostquantumencryption.go index b38ba27624a..dce9a7f91d5 100644 --- a/origin_post_quantum_encryption/originpostquantumencryption.go +++ b/origin_post_quantum_encryption/originpostquantumencryption.go @@ -8,6 +8,7 @@ import ( "fmt" "net/http" + "github.com/cloudflare/cloudflare-go/v3/cache" "github.com/cloudflare/cloudflare-go/v3/internal/apijson" "github.com/cloudflare/cloudflare-go/v3/internal/param" "github.com/cloudflare/cloudflare-go/v3/internal/requestconfig" @@ -80,7 +81,7 @@ func (r *OriginPostQuantumEncryptionService) Get(ctx context.Context, query Orig type OriginPostQuantumEncryptionUpdateParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` + ZoneID param.Field[cache.CacheVariantIdentifierParam] `path:"zone_id,required"` // Value of the Origin Post Quantum Encryption Setting. Value param.Field[OriginPostQuantumEncryptionUpdateParamsValue] `json:"value,required"` } @@ -151,7 +152,7 @@ func (r OriginPostQuantumEncryptionUpdateResponseEnvelopeSuccess) IsKnown() bool type OriginPostQuantumEncryptionGetParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` + ZoneID param.Field[cache.CacheVariantIdentifierParam] `path:"zone_id,required"` } type OriginPostQuantumEncryptionGetResponseEnvelope struct {