Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat(api): manual updates #3652

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2497,6 +2497,7 @@ Methods:

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway#DiscoveryOperation">DiscoveryOperation</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway#DiscoveryGetResponse">DiscoveryGetResponse</a>

Methods:
Expand All @@ -2507,13 +2508,12 @@ Methods:

Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway#DiscoveryOperationListResponse">DiscoveryOperationListResponse</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway#DiscoveryOperationBulkEditResponse">DiscoveryOperationBulkEditResponse</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway#DiscoveryOperationEditResponse">DiscoveryOperationEditResponse</a>

Methods:

- <code title="get /zones/{zone_id}/api_gateway/discovery/operations">client.APIGateway.Discovery.Operations.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway#DiscoveryOperationService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway#DiscoveryOperationListParams">DiscoveryOperationListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/packages/pagination#V4PagePaginationArray">V4PagePaginationArray</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway#DiscoveryOperationListResponse">DiscoveryOperationListResponse</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /zones/{zone_id}/api_gateway/discovery/operations">client.APIGateway.Discovery.Operations.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway#DiscoveryOperationService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway#DiscoveryOperationListParams">DiscoveryOperationListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/packages/pagination#V4PagePaginationArray">V4PagePaginationArray</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway#DiscoveryOperation">DiscoveryOperation</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="patch /zones/{zone_id}/api_gateway/discovery/operations">client.APIGateway.Discovery.Operations.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway#DiscoveryOperationService.BulkEdit">BulkEdit</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway#DiscoveryOperationBulkEditParams">DiscoveryOperationBulkEditParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway#DiscoveryOperationBulkEditResponse">DiscoveryOperationBulkEditResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="patch /zones/{zone_id}/api_gateway/discovery/operations/{operation_id}">client.APIGateway.Discovery.Operations.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway#DiscoveryOperationService.Edit">Edit</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, operationID <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway#DiscoveryOperationEditParams">DiscoveryOperationEditParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway">api_gateway</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v3/api_gateway#DiscoveryOperationEditResponse">DiscoveryOperationEditResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

Expand Down
158 changes: 158 additions & 0 deletions api_gateway/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,164 @@ func (r *DiscoveryService) Get(ctx context.Context, query DiscoveryGetParams, op
return
}

type DiscoveryOperation struct {
// UUID
ID string `json:"id,required"`
// The endpoint which can contain path parameter templates in curly braces, each
// will be replaced from left to right with {varN}, starting with {var1}, during
// insertion. This will further be Cloudflare-normalized upon insertion. See:
// https://developers.cloudflare.com/rules/normalization/how-it-works/.
Endpoint string `json:"endpoint,required" format:"uri-template"`
// RFC3986-compliant host.
Host string `json:"host,required" format:"hostname"`
LastUpdated time.Time `json:"last_updated,required" format:"date-time"`
// The HTTP method used to access the endpoint.
Method DiscoveryOperationMethod `json:"method,required"`
// API discovery engine(s) that discovered this operation
Origin []DiscoveryOperationOrigin `json:"origin,required"`
// State of operation in API Discovery
//
// - `review` - Operation is not saved into API Shield Endpoint Management
// - `saved` - Operation is saved into API Shield Endpoint Management
// - `ignored` - Operation is marked as ignored
State DiscoveryOperationState `json:"state,required"`
Features DiscoveryOperationFeatures `json:"features"`
JSON discoveryOperationJSON `json:"-"`
}

// discoveryOperationJSON contains the JSON metadata for the struct
// [DiscoveryOperation]
type discoveryOperationJSON struct {
ID apijson.Field
Endpoint apijson.Field
Host apijson.Field
LastUpdated apijson.Field
Method apijson.Field
Origin apijson.Field
State apijson.Field
Features apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

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

// The HTTP method used to access the endpoint.
type DiscoveryOperationMethod string

const (
DiscoveryOperationMethodGet DiscoveryOperationMethod = "GET"
DiscoveryOperationMethodPost DiscoveryOperationMethod = "POST"
DiscoveryOperationMethodHead DiscoveryOperationMethod = "HEAD"
DiscoveryOperationMethodOptions DiscoveryOperationMethod = "OPTIONS"
DiscoveryOperationMethodPut DiscoveryOperationMethod = "PUT"
DiscoveryOperationMethodDelete DiscoveryOperationMethod = "DELETE"
DiscoveryOperationMethodConnect DiscoveryOperationMethod = "CONNECT"
DiscoveryOperationMethodPatch DiscoveryOperationMethod = "PATCH"
DiscoveryOperationMethodTrace DiscoveryOperationMethod = "TRACE"
)

func (r DiscoveryOperationMethod) IsKnown() bool {
switch r {
case DiscoveryOperationMethodGet, DiscoveryOperationMethodPost, DiscoveryOperationMethodHead, DiscoveryOperationMethodOptions, DiscoveryOperationMethodPut, DiscoveryOperationMethodDelete, DiscoveryOperationMethodConnect, DiscoveryOperationMethodPatch, DiscoveryOperationMethodTrace:
return true
}
return false
}

// - `ML` - Discovered operation was sourced using ML API Discovery \*
// `SessionIdentifier` - Discovered operation was sourced using Session
// Identifier API Discovery
type DiscoveryOperationOrigin string

const (
DiscoveryOperationOriginMl DiscoveryOperationOrigin = "ML"
DiscoveryOperationOriginSessionIdentifier DiscoveryOperationOrigin = "SessionIdentifier"
)

func (r DiscoveryOperationOrigin) IsKnown() bool {
switch r {
case DiscoveryOperationOriginMl, DiscoveryOperationOriginSessionIdentifier:
return true
}
return false
}

// State of operation in API Discovery
//
// - `review` - Operation is not saved into API Shield Endpoint Management
// - `saved` - Operation is saved into API Shield Endpoint Management
// - `ignored` - Operation is marked as ignored
type DiscoveryOperationState string

const (
DiscoveryOperationStateReview DiscoveryOperationState = "review"
DiscoveryOperationStateSaved DiscoveryOperationState = "saved"
DiscoveryOperationStateIgnored DiscoveryOperationState = "ignored"
)

func (r DiscoveryOperationState) IsKnown() bool {
switch r {
case DiscoveryOperationStateReview, DiscoveryOperationStateSaved, DiscoveryOperationStateIgnored:
return true
}
return false
}

type DiscoveryOperationFeatures struct {
TrafficStats DiscoveryOperationFeaturesTrafficStats `json:"traffic_stats"`
JSON discoveryOperationFeaturesJSON `json:"-"`
}

// discoveryOperationFeaturesJSON contains the JSON metadata for the struct
// [DiscoveryOperationFeatures]
type discoveryOperationFeaturesJSON struct {
TrafficStats apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

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

type DiscoveryOperationFeaturesTrafficStats struct {
LastUpdated time.Time `json:"last_updated,required" format:"date-time"`
// The period in seconds these statistics were computed over
PeriodSeconds int64 `json:"period_seconds,required"`
// The average number of requests seen during this period
Requests float64 `json:"requests,required"`
JSON discoveryOperationFeaturesTrafficStatsJSON `json:"-"`
}

// discoveryOperationFeaturesTrafficStatsJSON contains the JSON metadata for the
// struct [DiscoveryOperationFeaturesTrafficStats]
type discoveryOperationFeaturesTrafficStatsJSON struct {
LastUpdated apijson.Field
PeriodSeconds apijson.Field
Requests apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

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

type DiscoveryGetResponse struct {
Schemas []interface{} `json:"schemas,required"`
Timestamp time.Time `json:"timestamp,required" format:"date-time"`
Expand Down
163 changes: 2 additions & 161 deletions api_gateway/discoveryoperation.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"net/http"
"net/url"
"time"

"github.com/cloudflare/cloudflare-go/v3/internal/apijson"
"github.com/cloudflare/cloudflare-go/v3/internal/apiquery"
Expand Down Expand Up @@ -38,7 +37,7 @@ func NewDiscoveryOperationService(opts ...option.RequestOption) (r *DiscoveryOpe
}

// Retrieve the most up to date view of discovered operations
func (r *DiscoveryOperationService) List(ctx context.Context, params DiscoveryOperationListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[DiscoveryOperationListResponse], err error) {
func (r *DiscoveryOperationService) List(ctx context.Context, params DiscoveryOperationListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[DiscoveryOperation], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
Expand All @@ -60,7 +59,7 @@ func (r *DiscoveryOperationService) List(ctx context.Context, params DiscoveryOp
}

// Retrieve the most up to date view of discovered operations
func (r *DiscoveryOperationService) ListAutoPaging(ctx context.Context, params DiscoveryOperationListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[DiscoveryOperationListResponse] {
func (r *DiscoveryOperationService) ListAutoPaging(ctx context.Context, params DiscoveryOperationListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[DiscoveryOperation] {
return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...))
}

Expand Down Expand Up @@ -102,164 +101,6 @@ func (r *DiscoveryOperationService) Edit(ctx context.Context, operationID string
return
}

type DiscoveryOperationListResponse struct {
// UUID
ID string `json:"id,required"`
// The endpoint which can contain path parameter templates in curly braces, each
// will be replaced from left to right with {varN}, starting with {var1}, during
// insertion. This will further be Cloudflare-normalized upon insertion. See:
// https://developers.cloudflare.com/rules/normalization/how-it-works/.
Endpoint string `json:"endpoint,required" format:"uri-template"`
// RFC3986-compliant host.
Host string `json:"host,required" format:"hostname"`
LastUpdated time.Time `json:"last_updated,required" format:"date-time"`
// The HTTP method used to access the endpoint.
Method DiscoveryOperationListResponseMethod `json:"method,required"`
// API discovery engine(s) that discovered this operation
Origin []DiscoveryOperationListResponseOrigin `json:"origin,required"`
// State of operation in API Discovery
//
// - `review` - Operation is not saved into API Shield Endpoint Management
// - `saved` - Operation is saved into API Shield Endpoint Management
// - `ignored` - Operation is marked as ignored
State DiscoveryOperationListResponseState `json:"state,required"`
Features DiscoveryOperationListResponseFeatures `json:"features"`
JSON discoveryOperationListResponseJSON `json:"-"`
}

// discoveryOperationListResponseJSON contains the JSON metadata for the struct
// [DiscoveryOperationListResponse]
type discoveryOperationListResponseJSON struct {
ID apijson.Field
Endpoint apijson.Field
Host apijson.Field
LastUpdated apijson.Field
Method apijson.Field
Origin apijson.Field
State apijson.Field
Features apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

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

// The HTTP method used to access the endpoint.
type DiscoveryOperationListResponseMethod string

const (
DiscoveryOperationListResponseMethodGet DiscoveryOperationListResponseMethod = "GET"
DiscoveryOperationListResponseMethodPost DiscoveryOperationListResponseMethod = "POST"
DiscoveryOperationListResponseMethodHead DiscoveryOperationListResponseMethod = "HEAD"
DiscoveryOperationListResponseMethodOptions DiscoveryOperationListResponseMethod = "OPTIONS"
DiscoveryOperationListResponseMethodPut DiscoveryOperationListResponseMethod = "PUT"
DiscoveryOperationListResponseMethodDelete DiscoveryOperationListResponseMethod = "DELETE"
DiscoveryOperationListResponseMethodConnect DiscoveryOperationListResponseMethod = "CONNECT"
DiscoveryOperationListResponseMethodPatch DiscoveryOperationListResponseMethod = "PATCH"
DiscoveryOperationListResponseMethodTrace DiscoveryOperationListResponseMethod = "TRACE"
)

func (r DiscoveryOperationListResponseMethod) IsKnown() bool {
switch r {
case DiscoveryOperationListResponseMethodGet, DiscoveryOperationListResponseMethodPost, DiscoveryOperationListResponseMethodHead, DiscoveryOperationListResponseMethodOptions, DiscoveryOperationListResponseMethodPut, DiscoveryOperationListResponseMethodDelete, DiscoveryOperationListResponseMethodConnect, DiscoveryOperationListResponseMethodPatch, DiscoveryOperationListResponseMethodTrace:
return true
}
return false
}

// - `ML` - Discovered operation was sourced using ML API Discovery \*
// `SessionIdentifier` - Discovered operation was sourced using Session
// Identifier API Discovery
type DiscoveryOperationListResponseOrigin string

const (
DiscoveryOperationListResponseOriginMl DiscoveryOperationListResponseOrigin = "ML"
DiscoveryOperationListResponseOriginSessionIdentifier DiscoveryOperationListResponseOrigin = "SessionIdentifier"
)

func (r DiscoveryOperationListResponseOrigin) IsKnown() bool {
switch r {
case DiscoveryOperationListResponseOriginMl, DiscoveryOperationListResponseOriginSessionIdentifier:
return true
}
return false
}

// State of operation in API Discovery
//
// - `review` - Operation is not saved into API Shield Endpoint Management
// - `saved` - Operation is saved into API Shield Endpoint Management
// - `ignored` - Operation is marked as ignored
type DiscoveryOperationListResponseState string

const (
DiscoveryOperationListResponseStateReview DiscoveryOperationListResponseState = "review"
DiscoveryOperationListResponseStateSaved DiscoveryOperationListResponseState = "saved"
DiscoveryOperationListResponseStateIgnored DiscoveryOperationListResponseState = "ignored"
)

func (r DiscoveryOperationListResponseState) IsKnown() bool {
switch r {
case DiscoveryOperationListResponseStateReview, DiscoveryOperationListResponseStateSaved, DiscoveryOperationListResponseStateIgnored:
return true
}
return false
}

type DiscoveryOperationListResponseFeatures struct {
TrafficStats DiscoveryOperationListResponseFeaturesTrafficStats `json:"traffic_stats"`
JSON discoveryOperationListResponseFeaturesJSON `json:"-"`
}

// discoveryOperationListResponseFeaturesJSON contains the JSON metadata for the
// struct [DiscoveryOperationListResponseFeatures]
type discoveryOperationListResponseFeaturesJSON struct {
TrafficStats apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

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

type DiscoveryOperationListResponseFeaturesTrafficStats struct {
LastUpdated time.Time `json:"last_updated,required" format:"date-time"`
// The period in seconds these statistics were computed over
PeriodSeconds int64 `json:"period_seconds,required"`
// The average number of requests seen during this period
Requests float64 `json:"requests,required"`
JSON discoveryOperationListResponseFeaturesTrafficStatsJSON `json:"-"`
}

// discoveryOperationListResponseFeaturesTrafficStatsJSON contains the JSON
// metadata for the struct [DiscoveryOperationListResponseFeaturesTrafficStats]
type discoveryOperationListResponseFeaturesTrafficStatsJSON struct {
LastUpdated apijson.Field
PeriodSeconds apijson.Field
Requests apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

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

type DiscoveryOperationBulkEditResponse map[string]DiscoveryOperationBulkEditResponseItem

// Mappings of discovered operations (keys) to objects describing their state
Expand Down