Skip to content

Commit

Permalink
feat: auto-updated SDK (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Oct 25, 2024
1 parent 2ad6227 commit bda0f3c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
16 changes: 13 additions & 3 deletions openAPIDefinition.json
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,16 @@
"Branch"
],
"operationId": "listProjectBranches",
"parameters": [
{
"name": "search",
"description": "Search by branch `name` or `id`. You can specify partial `name` or `id` values to filter results.",
"in": "query",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Returned a list of branches for the specified project",
Expand Down Expand Up @@ -3322,7 +3332,7 @@
},
{
"name": "project_ids",
"description": "Specify a list of project IDs to filter the response.\nIf omitted, the response will contain all projects.\n",
"description": "Specify a list of project IDs to filter the response.\nIf omitted, the response will contain all projects.\nA list of project IDs can be specified as an array of parameter values or as a comma-separated list in a single parameter value.\n- As an array of parameter values: `project_ids=cold-poetry-09157238%20&project_ids=quiet-snow-71788278`\n- As a comma-separated list in a single parameter value: `project_ids=cold-poetry-09157238,quiet-snow-71788278`\n",
"in": "query",
"schema": {
"type": "array",
Expand Down Expand Up @@ -6281,14 +6291,14 @@
}
},
"OrganizationGuestsResponse": {
"description": "A list of details for guests of an organisation\n",
"description": "A list of details for guests of an organization\n",
"type": "array",
"items": {
"$ref": "#/components/schemas/OrganizationGuest"
}
},
"OrganizationGuest": {
"description": "Details of an organisation guest, who is not directly a member of\nan organisation but has been shared one of the projects it owns\n",
"description": "Details of an organization guest, who is not directly a member of\nan organization but has been shared one of the projects it owns\n",
"type": "object",
"required": [
"permission_id",
Expand Down
14 changes: 12 additions & 2 deletions sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,19 @@ func (c Client) ListProjectBranchRoles(projectID string, branchID string) (Roles
// A project may contain child branches that were branched from `main` or from another branch.
// A parent branch is identified by the `parent_id` value, which is the `id` of the parent branch.
// For related information, see [Manage branches](https://neon.tech/docs/manage/branches/).
func (c Client) ListProjectBranches(projectID string) (ListProjectBranchesRespObj, error) {
func (c Client) ListProjectBranches(projectID string, search *string) (ListProjectBranchesRespObj, error) {
var (
queryElements []string
query string
)
if search != nil {
queryElements = append(queryElements, "search="+*search)
}
if len(queryElements) > 0 {
query = "?" + strings.Join(queryElements, "&")
}
var v ListProjectBranchesRespObj
if err := c.requestHandler(c.baseURL+"/projects/"+projectID+"/branches", "GET", nil, &v); err != nil {
if err := c.requestHandler(c.baseURL+"/projects/"+projectID+"/branches"+query, "GET", nil, &v); err != nil {
return ListProjectBranchesRespObj{}, err
}
return v, nil
Expand Down
5 changes: 4 additions & 1 deletion sdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2158,6 +2158,7 @@ func Test_client_ListProjectBranches(t *testing.T) {
}
type args struct {
projectID string
search *string
}
tests := []struct {
name string
Expand All @@ -2170,6 +2171,7 @@ func Test_client_ListProjectBranches(t *testing.T) {
name: "happy path",
args: args{
projectID: "foo",
search: createPointer("foo"),
},
apiKey: "foo",
want: deserializeResp(endpointResponseExamples["/projects/{project_id}/branches"]["GET"].Content),
Expand All @@ -2179,6 +2181,7 @@ func Test_client_ListProjectBranches(t *testing.T) {
name: "unhappy path",
args: args{
projectID: "foo",
search: createPointer("foo"),
},
apiKey: "invalidApiKey",
want: ListProjectBranchesRespObj{},
Expand All @@ -2192,7 +2195,7 @@ func Test_client_ListProjectBranches(t *testing.T) {
if err != nil {
panic(err)
}
got, err := c.ListProjectBranches(tt.args.projectID)
got, err := c.ListProjectBranches(tt.args.projectID, tt.args.search)
if (err != nil) != tt.wantErr {
t.Errorf("ListProjectBranches() error = %v, wantErr %v", err, tt.wantErr)
return
Expand Down

0 comments on commit bda0f3c

Please sign in to comment.