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): update via SDK Studio #1746

Merged
merged 1 commit into from
Apr 10, 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
5 changes: 3 additions & 2 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3908,6 +3908,7 @@ Methods:
Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListCursor">ListCursor</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItem">ListItem</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemNewResponse">ListItemNewResponse</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemUpdateResponse">ListItemUpdateResponse</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules">rules</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/rules#ListItemListResponse">ListItemListResponse</a>
Expand Down Expand Up @@ -6643,7 +6644,7 @@ Methods:
Response Types:

- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#Item">Item</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#List">List</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#ListItem">ListItem</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#Quota">Quota</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#RequestConstants">RequestConstants</a>
- <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#RequestTypes">RequestTypes</a>
Expand All @@ -6653,7 +6654,7 @@ Methods:

- <code title="post /accounts/{account_identifier}/cloudforce-one/requests/new">client.CloudforceOne.Requests.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#RequestService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, accountIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#RequestNewParams">RequestNewParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#Item">Item</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="put /accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}">client.CloudforceOne.Requests.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#RequestService.Update">Update</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, accountIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>, requestIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#RequestUpdateParams">RequestUpdateParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#Item">Item</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /accounts/{account_identifier}/cloudforce-one/requests">client.CloudforceOne.Requests.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#RequestService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, accountIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#RequestListParams">RequestListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/pagination#V4PagePaginationArray">V4PagePaginationArray</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#List">List</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /accounts/{account_identifier}/cloudforce-one/requests">client.CloudforceOne.Requests.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#RequestService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, accountIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#RequestListParams">RequestListParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/internal/pagination#V4PagePaginationArray">V4PagePaginationArray</a>[<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#ListItem">ListItem</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="delete /accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}">client.CloudforceOne.Requests.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#RequestService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, accountIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>, requestIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#RequestDeleteResponseUnion">RequestDeleteResponseUnion</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_identifier}/cloudforce-one/requests/constants">client.CloudforceOne.Requests.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#RequestService.Constants">Constants</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, accountIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#RequestConstants">RequestConstants</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_identifier}/cloudforce-one/requests/{request_identifier}">client.CloudforceOne.Requests.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#RequestService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, accountIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>, requestIdentifier <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one">cloudforce_one</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/cloudforce_one#Item">Item</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
Expand Down
72 changes: 36 additions & 36 deletions cloudforce_one/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,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[List], 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...)
Expand All @@ -88,7 +88,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[List] {
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...))
}

Expand Down Expand Up @@ -249,18 +249,18 @@ func (r ItemStatus) IsKnown() bool {
return false
}

type List struct {
type ListItem struct {
// UUID
ID string `json:"id,required"`
// Request creation time
Created time.Time `json:"created,required" format:"date-time"`
Priority ListPriority `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 ListTlp `json:"tlp,required"`
Tlp ListItemTlp `json:"tlp,required"`
// Request last updated time
Updated time.Time `json:"updated,required" format:"date-time"`
// Request completion time
Expand All @@ -270,14 +270,14 @@ type List struct {
// Readable Request ID
ReadableID string `json:"readable_id"`
// Request Status
Status ListStatus `json:"status"`
Status ListItemStatus `json:"status"`
// Tokens for the request
Tokens int64 `json:"tokens"`
JSON listJSON `json:"-"`
Tokens int64 `json:"tokens"`
JSON listItemJSON `json:"-"`
}

// listJSON contains the JSON metadata for the struct [List]
type listJSON struct {
// listItemJSON contains the JSON metadata for the struct [ListItem]
type listItemJSON struct {
ID apijson.Field
Created apijson.Field
Priority apijson.Field
Expand All @@ -294,64 +294,64 @@ type listJSON struct {
ExtraFields map[string]apijson.Field
}

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

func (r listJSON) RawJSON() string {
func (r listItemJSON) RawJSON() string {
return r.raw
}

type ListPriority string
type ListItemPriority string

const (
ListPriorityRoutine ListPriority = "routine"
ListPriorityHigh ListPriority = "high"
ListPriorityUrgent ListPriority = "urgent"
ListItemPriorityRoutine ListItemPriority = "routine"
ListItemPriorityHigh ListItemPriority = "high"
ListItemPriorityUrgent ListItemPriority = "urgent"
)

func (r ListPriority) IsKnown() bool {
func (r ListItemPriority) IsKnown() bool {
switch r {
case ListPriorityRoutine, ListPriorityHigh, ListPriorityUrgent:
case ListItemPriorityRoutine, ListItemPriorityHigh, ListItemPriorityUrgent:
return true
}
return false
}

// The CISA defined Traffic Light Protocol (TLP)
type ListTlp string
type ListItemTlp string

const (
ListTlpClear ListTlp = "clear"
ListTlpAmber ListTlp = "amber"
ListTlpAmberStrict ListTlp = "amber-strict"
ListTlpGreen ListTlp = "green"
ListTlpRed ListTlp = "red"
ListItemTlpClear ListItemTlp = "clear"
ListItemTlpAmber ListItemTlp = "amber"
ListItemTlpAmberStrict ListItemTlp = "amber-strict"
ListItemTlpGreen ListItemTlp = "green"
ListItemTlpRed ListItemTlp = "red"
)

func (r ListTlp) IsKnown() bool {
func (r ListItemTlp) IsKnown() bool {
switch r {
case ListTlpClear, ListTlpAmber, ListTlpAmberStrict, ListTlpGreen, ListTlpRed:
case ListItemTlpClear, ListItemTlpAmber, ListItemTlpAmberStrict, ListItemTlpGreen, ListItemTlpRed:
return true
}
return false
}

// Request Status
type ListStatus string
type ListItemStatus string

const (
ListStatusOpen ListStatus = "open"
ListStatusAccepted ListStatus = "accepted"
ListStatusReported ListStatus = "reported"
ListStatusApproved ListStatus = "approved"
ListStatusCompleted ListStatus = "completed"
ListStatusDeclined ListStatus = "declined"
ListItemStatusOpen ListItemStatus = "open"
ListItemStatusAccepted ListItemStatus = "accepted"
ListItemStatusReported ListItemStatus = "reported"
ListItemStatusApproved ListItemStatus = "approved"
ListItemStatusCompleted ListItemStatus = "completed"
ListItemStatusDeclined ListItemStatus = "declined"
)

func (r ListStatus) IsKnown() bool {
func (r ListItemStatus) IsKnown() bool {
switch r {
case ListStatusOpen, ListStatusAccepted, ListStatusReported, ListStatusApproved, ListStatusCompleted, ListStatusDeclined:
case ListItemStatusOpen, ListItemStatusAccepted, ListItemStatusReported, ListItemStatusApproved, ListItemStatusCompleted, ListItemStatusDeclined:
return true
}
return false
Expand Down
21 changes: 21 additions & 0 deletions rules/listitem.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,27 @@ func (r listCursorJSON) RawJSON() string {
return r.raw
}

type ListItem struct {
// The unique operation ID of the asynchronous action.
OperationID string `json:"operation_id"`
JSON listItemJSON `json:"-"`
}

// listItemJSON contains the JSON metadata for the struct [ListItem]
type listItemJSON struct {
OperationID apijson.Field
raw string
ExtraFields map[string]apijson.Field
}

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

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

type ListItemNewResponse struct {
// The unique operation ID of the asynchronous action.
OperationID string `json:"operation_id"`
Expand Down