-
Notifications
You must be signed in to change notification settings - Fork 582
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add organizations endpoint for users (#50)
* feat: Add organizations endpoint for users This moves the /user endpoint to /users/me instead. This will reduce code duplication. This adds /users/<name>/organizations to list organizations a user has access to. It doesn't contain the permissions a user has over the organizations, but that will come in a future contribution. * Fix requested changes * Fix tests * Fix timeout * Add test for UserOrgs * Add test for userparam getting * Add test for NoUser
- Loading branch information
Showing
20 changed files
with
597 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package coderd | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/coder/coder/database" | ||
) | ||
|
||
// Organization is the JSON representation of a Coder organization. | ||
type Organization struct { | ||
ID string `json:"id" validate:"required"` | ||
Name string `json:"name" validate:"required"` | ||
CreatedAt time.Time `json:"created_at" validate:"required"` | ||
UpdatedAt time.Time `json:"updated_at" validate:"required"` | ||
} | ||
|
||
// convertOrganization consumes the database representation and outputs an API friendly representation. | ||
func convertOrganization(organization database.Organization) Organization { | ||
return Organization{ | ||
ID: organization.ID, | ||
Name: organization.Name, | ||
CreatedAt: organization.CreatedAt, | ||
UpdatedAt: organization.UpdatedAt, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.