Skip to content

Commit

Permalink
feat(api): OpenAPI spec update via Stainless API (#1599)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored Mar 21, 2024
1 parent 7ea7fa4 commit f95e68f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 47 deletions.
2 changes: 1 addition & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3589,7 +3589,7 @@ Response Types:
Methods:

- <code title="post /accounts/{account_id}/pages/projects/{project_name}/deployments">client.Pages.Projects.Deployments.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages#ProjectDeploymentService.New">New</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, projectName <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages">pages</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages#ProjectDeploymentNewParams">ProjectDeploymentNewParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages">pages</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages#PagesDeployments">PagesDeployments</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_id}/pages/projects/{project_name}/deployments">client.Pages.Projects.Deployments.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages#ProjectDeploymentService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, projectName <a href="https://pkg.go.dev/builtin#string">string</a>, params <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages">pages</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages#ProjectDeploymentListParams">ProjectDeploymentListParams</a>) ([]<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages">pages</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages#PagesDeployments">PagesDeployments</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_id}/pages/projects/{project_name}/deployments">client.Pages.Projects.Deployments.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages#ProjectDeploymentService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, projectName <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages">pages</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages#ProjectDeploymentListParams">ProjectDeploymentListParams</a>) ([]<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages">pages</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages#PagesDeployments">PagesDeployments</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="delete /accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}">client.Pages.Projects.Deployments.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages#ProjectDeploymentService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, projectName <a href="https://pkg.go.dev/builtin#string">string</a>, deploymentID <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages">pages</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages#ProjectDeploymentDeleteParams">ProjectDeploymentDeleteParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages">pages</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages#ProjectDeploymentDeleteResponse">ProjectDeploymentDeleteResponse</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}">client.Pages.Projects.Deployments.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages#ProjectDeploymentService.Get">Get</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, projectName <a href="https://pkg.go.dev/builtin#string">string</a>, deploymentID <a href="https://pkg.go.dev/builtin#string">string</a>, query <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages">pages</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages#ProjectDeploymentGetParams">ProjectDeploymentGetParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages">pages</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages#PagesDeployments">PagesDeployments</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="post /accounts/{account_id}/pages/projects/{project_name}/deployments/{deployment_id}/retry">client.Pages.Projects.Deployments.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages#ProjectDeploymentService.Retry">Retry</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, projectName <a href="https://pkg.go.dev/builtin#string">string</a>, deploymentID <a href="https://pkg.go.dev/builtin#string">string</a>, body <a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages">pages</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages#ProjectDeploymentRetryParams">ProjectDeploymentRetryParams</a>) (<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages">pages</a>.<a href="https://pkg.go.dev/github.com/cloudflare/cloudflare-go/v2/pages#PagesDeployments">PagesDeployments</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
Expand Down
10 changes: 0 additions & 10 deletions pages/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -1033,8 +1033,6 @@ func (r pagesProjectsDeploymentConfigsPreviewServicesJSON) RawJSON() string {

// Service binding.
type PagesProjectsDeploymentConfigsPreviewServicesServiceBinding struct {
// The entrypoint to bind to.
Entrypoint string `json:"entrypoint,nullable"`
// The Service environment.
Environment string `json:"environment"`
// The Service name.
Expand All @@ -1046,7 +1044,6 @@ type PagesProjectsDeploymentConfigsPreviewServicesServiceBinding struct {
// JSON metadata for the struct
// [PagesProjectsDeploymentConfigsPreviewServicesServiceBinding]
type pagesProjectsDeploymentConfigsPreviewServicesServiceBindingJSON struct {
Entrypoint apijson.Field
Environment apijson.Field
Service apijson.Field
raw string
Expand Down Expand Up @@ -1736,8 +1733,6 @@ func (r pagesProjectsDeploymentConfigsProductionServicesJSON) RawJSON() string {

// Service binding.
type PagesProjectsDeploymentConfigsProductionServicesServiceBinding struct {
// The entrypoint to bind to.
Entrypoint string `json:"entrypoint,nullable"`
// The Service environment.
Environment string `json:"environment"`
// The Service name.
Expand All @@ -1749,7 +1744,6 @@ type PagesProjectsDeploymentConfigsProductionServicesServiceBinding struct {
// JSON metadata for the struct
// [PagesProjectsDeploymentConfigsProductionServicesServiceBinding]
type pagesProjectsDeploymentConfigsProductionServicesServiceBindingJSON struct {
Entrypoint apijson.Field
Environment apijson.Field
Service apijson.Field
raw string
Expand Down Expand Up @@ -2203,8 +2197,6 @@ func (r ProjectNewParamsDeploymentConfigsPreviewServices) MarshalJSON() (data []

// Service binding.
type ProjectNewParamsDeploymentConfigsPreviewServicesServiceBinding struct {
// The entrypoint to bind to.
Entrypoint param.Field[string] `json:"entrypoint"`
// The Service environment.
Environment param.Field[string] `json:"environment"`
// The Service name.
Expand Down Expand Up @@ -2521,8 +2513,6 @@ func (r ProjectNewParamsDeploymentConfigsProductionServices) MarshalJSON() (data

// Service binding.
type ProjectNewParamsDeploymentConfigsProductionServicesServiceBinding struct {
// The entrypoint to bind to.
Entrypoint param.Field[string] `json:"entrypoint"`
// The Service environment.
Environment param.Field[string] `json:"environment"`
// The Service name.
Expand Down
2 changes: 0 additions & 2 deletions pages/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ func TestProjectNewWithOptionalParams(t *testing.T) {
}),
Services: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewServices{
ServiceBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsPreviewServicesServiceBinding{
Entrypoint: cloudflare.F("MyHandler"),
Environment: cloudflare.F("production"),
Service: cloudflare.F("example-worker"),
}),
Expand Down Expand Up @@ -175,7 +174,6 @@ func TestProjectNewWithOptionalParams(t *testing.T) {
}),
Services: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionServices{
ServiceBinding: cloudflare.F(pages.ProjectNewParamsDeploymentConfigsProductionServicesServiceBinding{
Entrypoint: cloudflare.F("MyHandler"),
Environment: cloudflare.F("production"),
Service: cloudflare.F("example-worker"),
}),
Expand Down
35 changes: 3 additions & 32 deletions pages/projectdeployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import (
"context"
"fmt"
"net/http"
"net/url"

"github.com/cloudflare/cloudflare-go/v2/internal/apijson"
"github.com/cloudflare/cloudflare-go/v2/internal/apiquery"
"github.com/cloudflare/cloudflare-go/v2/internal/param"
"github.com/cloudflare/cloudflare-go/v2/internal/requestconfig"
"github.com/cloudflare/cloudflare-go/v2/option"
Expand Down Expand Up @@ -50,11 +48,11 @@ func (r *ProjectDeploymentService) New(ctx context.Context, projectName string,
}

// Fetch a list of project deployments.
func (r *ProjectDeploymentService) List(ctx context.Context, projectName string, params ProjectDeploymentListParams, opts ...option.RequestOption) (res *[]PagesDeployments, err error) {
func (r *ProjectDeploymentService) List(ctx context.Context, projectName string, query ProjectDeploymentListParams, opts ...option.RequestOption) (res *[]PagesDeployments, err error) {
opts = append(r.Options[:], opts...)
var env ProjectDeploymentListResponseEnvelope
path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments", params.AccountID, projectName)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...)
path := fmt.Sprintf("accounts/%s/pages/projects/%s/deployments", query.AccountID, projectName)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...)
if err != nil {
return
}
Expand Down Expand Up @@ -216,33 +214,6 @@ func (r ProjectDeploymentNewResponseEnvelopeSuccess) IsKnown() bool {
type ProjectDeploymentListParams struct {
// Identifier
AccountID param.Field[string] `path:"account_id,required"`
// What type of deployments to fetch.
Env param.Field[ProjectDeploymentListParamsEnv] `query:"env"`
}

// URLQuery serializes [ProjectDeploymentListParams]'s query parameters as
// `url.Values`.
func (r ProjectDeploymentListParams) URLQuery() (v url.Values) {
return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{
ArrayFormat: apiquery.ArrayQueryFormatComma,
NestedFormat: apiquery.NestedQueryFormatBrackets,
})
}

// What type of deployments to fetch.
type ProjectDeploymentListParamsEnv string

const (
ProjectDeploymentListParamsEnvProduction ProjectDeploymentListParamsEnv = "production"
ProjectDeploymentListParamsEnvPreview ProjectDeploymentListParamsEnv = "preview"
)

func (r ProjectDeploymentListParamsEnv) IsKnown() bool {
switch r {
case ProjectDeploymentListParamsEnvProduction, ProjectDeploymentListParamsEnvPreview:
return true
}
return false
}

type ProjectDeploymentListResponseEnvelope struct {
Expand Down
3 changes: 1 addition & 2 deletions pages/projectdeployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestProjectDeploymentNewWithOptionalParams(t *testing.T) {
}
}

func TestProjectDeploymentListWithOptionalParams(t *testing.T) {
func TestProjectDeploymentList(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
Expand All @@ -64,7 +64,6 @@ func TestProjectDeploymentListWithOptionalParams(t *testing.T) {
"this-is-my-project-01",
pages.ProjectDeploymentListParams{
AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
Env: cloudflare.F(pages.ProjectDeploymentListParamsEnvPreview),
},
)
if err != nil {
Expand Down

0 comments on commit f95e68f

Please sign in to comment.