Skip to content

Commit

Permalink
feat: auto-updated SDK (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Nov 14, 2024
1 parent 2120e9f commit e474295
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 139 deletions.
15 changes: 8 additions & 7 deletions mockhttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,18 @@ var endpointResponseExamples = map[string]map[string]mockResponse{
},

"/organizations/{org_id}/members/{member_id}": {
"DELETE": mockResponse{
Content: `null`,
Code: 200,
},
"GET": mockResponse{
Content: `{"id":"d57833f2-d308-4ede-9d2e-468d9d013d1b","joined_at":"2024-02-23T17:42:25Z","org_id":"my-organization-morning-bread-81040908","role":"admin","user_id":"b107d689-6dd2-4c9a-8b9e-0b25e457cf56"}`,
Code: 200,
},
"PATCH": mockResponse{
Content: `null`,
Code: 200,
},
},

"/projects": {
Expand Down Expand Up @@ -412,13 +420,6 @@ var endpointResponseExamples = map[string]map[string]mockResponse{
},
},

"/projects/{project_id}/branches/{branch_id}/set_as_primary": {
"POST": mockResponse{
Content: `{"branch":{"active_time_seconds":1,"compute_time_seconds":1,"cpu_used_sec":1,"created_at":"2022-11-23T17:42:25Z","creation_source":"console","current_state":"ready","data_transfer_bytes":100,"default":true,"id":"br-icy-dream-250089","name":"mybranch","parent_id":"br-aged-salad-637688","parent_lsn":"0/1E19478","project_id":"shiny-wind-028834","protected":false,"state_changed_at":"2022-11-30T20:09:48Z","updated_at":"2022-11-23T17:42:26Z","written_data_bytes":100},"operations":[]}`,
Code: 200,
},
},

"/projects/{project_id}/connection_uri": {
"GET": mockResponse{
Content: `null`,
Expand Down
131 changes: 60 additions & 71 deletions openAPIDefinition.json
Original file line number Diff line number Diff line change
Expand Up @@ -1662,76 +1662,6 @@
}
}
},
"/projects/{project_id}/branches/{branch_id}/set_as_primary": {
"parameters": [
{
"name": "project_id",
"in": "path",
"description": "The Neon project ID",
"required": true,
"schema": {
"type": "string",
"pattern": "^[a-z0-9-]{1,60}$"
}
},
{
"name": "branch_id",
"in": "path",
"description": "The branch ID",
"required": true,
"schema": {
"type": "string",
"pattern": "^[a-z0-9-]{1,60}$"
}
}
],
"post": {
"tags": [
"Branch"
],
"summary": "Set branch as primary",
"deprecated": true,
"description": "DEPRECATED. Use `/set_as_default` endpoint.\nSets the specified branch as the project's primary branch.\nThe primary designation is automatically removed from the previous primary branch.\nYou can obtain a `project_id` by listing the projects for your Neon account.\nYou can obtain the `branch_id` by listing the project's branches.\nFor more information, see [Manage branches](https://neon.tech/docs/manage/branches/).\n",
"operationId": "setPrimaryProjectBranch",
"responses": {
"200": {
"description": "Updated the specified branch",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/BranchOperations"
},
"example": {
"branch": {
"cpu_used_sec": 1,
"active_time_seconds": 1,
"compute_time_seconds": 1,
"written_data_bytes": 100,
"data_transfer_bytes": 100,
"id": "br-icy-dream-250089",
"project_id": "shiny-wind-028834",
"parent_id": "br-aged-salad-637688",
"parent_lsn": "0/1E19478",
"name": "mybranch",
"current_state": "ready",
"state_changed_at": "2022-11-30T20:09:48Z",
"created_at": "2022-11-23T17:42:25Z",
"updated_at": "2022-11-23T17:42:26Z",
"default": true,
"protected": false,
"creation_source": "console"
},
"operations": []
}
}
}
},
"default": {
"$ref": "#/components/responses/GeneralError"
}
}
}
},
"/projects/{project_id}/branches/{branch_id}/set_as_default": {
"parameters": [
{
Expand Down Expand Up @@ -3795,6 +3725,65 @@
"$ref": "#/components/responses/GeneralError"
}
}
},
"patch": {
"summary": "Update the role for an organization member",
"description": "Only an admin can perform this action.\n",
"tags": [
"Organizations"
],
"operationId": "updateOrganizationMember",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OrganizationMemberUpdateRequest"
},
"example": {
"role": "admin"
}
}
}
},
"responses": {
"200": {
"description": "The updated organization member",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Member"
}
}
}
},
"default": {
"$ref": "#/components/responses/GeneralError"
}
}
},
"delete": {
"summary": "Remove member from the organization",
"description": "Remove member from the organization.\nOnly an admin of the organization can perform this action.\nIf another admin is being removed, it will not be allows in case it is the only admin left in the organization.\n",
"tags": [
"Organizations"
],
"operationId": "removeOrganizationMember",
"responses": {
"200": {
"description": "Removed organization member",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/EmptyResponse"
}
}
}
},
"default": {
"$ref": "#/components/responses/GeneralError"
}
}
}
},
"/organizations/{org_id}/invitations": {
Expand Down Expand Up @@ -4017,7 +4006,7 @@
}
}
},
"501": {
"422": {
"description": "One or more of project ids provided is linked by Github or Vercel integration. Transferring integration projects is currently not supported",
"content": {
"application/json": {
Expand Down
38 changes: 24 additions & 14 deletions sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,17 @@ func (c Client) ListSharedProjects(cursor *string, limit *int, search *string) (
return v, nil
}

// RemoveOrganizationMember Remove member from the organization.
// Only an admin of the organization can perform this action.
// If another admin is being removed, it will not be allows in case it is the only admin left in the organization.
func (c Client) RemoveOrganizationMember(orgID string, memberID string) (EmptyResponse, error) {
var v EmptyResponse
if err := c.requestHandler(c.baseURL+"/organizations/"+orgID+"/members/"+memberID, "DELETE", nil, &v); err != nil {
return EmptyResponse{}, err
}
return v, nil
}

// ResetProjectBranchRolePassword Resets the password for the specified Postgres role.
// Returns a new password and operations. The new password is ready to use when the last operation finishes.
// The old password remains valid until last operation finishes.
Expand Down Expand Up @@ -855,20 +866,6 @@ func (c Client) SetDefaultProjectBranch(projectID string, branchID string) (Bran
return v, nil
}

// SetPrimaryProjectBranch DEPRECATED. Use `/set_as_default` endpoint.
// Sets the specified branch as the project's primary branch.
// The primary designation is automatically removed from the previous primary branch.
// You can obtain a `project_id` by listing the projects for your Neon account.
// You can obtain the `branch_id` by listing the project's branches.
// For more information, see [Manage branches](https://neon.tech/docs/manage/branches/).
func (c Client) SetPrimaryProjectBranch(projectID string, branchID string) (BranchOperations, error) {
var v BranchOperations
if err := c.requestHandler(c.baseURL+"/projects/"+projectID+"/branches/"+branchID+"/set_as_primary", "POST", nil, &v); err != nil {
return BranchOperations{}, err
}
return v, nil
}

// StartProjectEndpoint Starts a compute endpoint. The compute endpoint is ready to use
// after the last operation in chain finishes successfully.
// You can obtain a `project_id` by listing the projects for your Neon account.
Expand Down Expand Up @@ -905,6 +902,15 @@ func (c Client) TransferProjectsFromUserToOrg(cfg TransferProjectsToOrganization
return v, nil
}

// UpdateOrganizationMember Only an admin can perform this action.
func (c Client) UpdateOrganizationMember(orgID string, memberID string, cfg OrganizationMemberUpdateRequest) (Member, error) {
var v Member
if err := c.requestHandler(c.baseURL+"/organizations/"+orgID+"/members/"+memberID, "PATCH", cfg, &v); err != nil {
return Member{}, err
}
return v, nil
}

// UpdateProject Updates the specified project.
// You can obtain a `project_id` by listing the projects for your Neon account.
// Neon permits updating the project name only.
Expand Down Expand Up @@ -1837,6 +1843,10 @@ type OrganizationInvitesCreateRequest struct {
Invitations []OrganizationInviteCreateRequest `json:"invitations"`
}

type OrganizationMemberUpdateRequest struct {
Role MemberRole `json:"role"`
}

type OrganizationMembersResponse struct {
Members []MemberWithUser `json:"members"`
}
Expand Down
Loading

0 comments on commit e474295

Please sign in to comment.