MCPcopy Index your code
hub / github.com/coder/coder / organizationByUserAndName

Method organizationByUserAndName

coderd/users.go:1895–1915  ·  view source on GitHub ↗

@Summary Get organization by user and organization name @ID get-organization-by-user-and-organization-name @Security CoderSessionToken @Produce json @Tags Users @Param user path string true "User ID, name, or me" @Param organizationname path string true "Organization name" @Success 200 {object} code

(rw http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

1893// @Success 200 {object} codersdk.Organization
1894// @Router /api/v2/users/{user}/organizations/{organizationname} [get]
1895func (api *API) organizationByUserAndName(rw http.ResponseWriter, r *http.Request) {
1896 ctx := r.Context()
1897 organizationName := chi.URLParam(r, "organizationname")
1898 organization, err := api.Database.GetOrganizationByName(ctx, database.GetOrganizationByNameParams{
1899 Name: organizationName,
1900 Deleted: false,
1901 })
1902 if httpapi.Is404Error(err) {
1903 httpapi.ResourceNotFound(rw)
1904 return
1905 }
1906 if err != nil {
1907 httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
1908 Message: "Internal error fetching organization.",
1909 Detail: err.Error(),
1910 })
1911 return
1912 }
1913
1914 httpapi.Write(ctx, rw, http.StatusOK, db2sdk.Organization(organization))
1915}
1916
1917type CreateUserRequest struct {
1918 codersdk.CreateUserRequestWithOrgs

Callers

nothing calls this directly

Calls 7

Is404ErrorFunction · 0.92
ResourceNotFoundFunction · 0.92
WriteFunction · 0.92
OrganizationFunction · 0.92
ContextMethod · 0.65
GetOrganizationByNameMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected