Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT][API] Get user by id #90

Open
youen opened this issue Mar 31, 2024 · 0 comments
Open

[FEAT][API] Get user by id #90

youen opened this issue Mar 31, 2024 · 0 comments

Comments

@youen
Copy link
Collaborator

youen commented Mar 31, 2024

Description

Get a user by id.

Request

Method

GET

URL

/users/{id}

Request Parameters

Parameter Description Required example
id The id of the user to get. Yes 123e4567-e89b-12d3-a456-426614174000

Request Body

(none)

Result

Result parameters

Parameter Description Type
id The id of the user. UUID
organization_id The id of the user's organization. UUID
username The username of the user. string
email The email address of the user. string
role The role of the user. UserRole
max_allowed_dimensions_per_dataset The maximum number of dimensions allowed per dataset for the user. int
max_allowed_lines_per_dataset The maximum number of lines allowed per dataset for the user. int

Result Body

(none)

Example Curl Request

curl -X GET \
  http://localhost:8080/users/123e4567-e89b-12d3-a456-426614174000 \
  -H "Accept: application/json"

Go server

Struct

type User struct {
	ID                               *uuid.UUID `json:"id"`
	OrganizationID                   *uuid.UUID `json:"organization_id"`
	Username                         string     `json:"username"`
	Email                            string     `json:"email"`
	Role                             UserRole   `json:"role"`
	MaxAllowedDimensionsPerDataset    *int       `json:"max_allowed_dimensions_per_dataset"`
	MaxAllowedLinesPerDataset         *int       `json:"max_allowed_lines_per_dataset"`
}

Handler

func (h *handler) getUser(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()
	vars := mux.Vars(r)
	id := vars["id"]

	user, err := h.userService.GetUser(ctx, id)
	if err != nil {
		h.respondError(w, http.StatusInternalServerError, err)
		return
	}

	h.respondJSON(w, http.StatusOK, user)
}
```return
	}

	h.respondJSON(ctx, w, http.StatusOK, user)
}

Links

Automated Issue Details

Dear visitor,

This issue has been automatically generated from the Octopize project avatar-python to make SIGO compatible. Please vote with a thumbs up or thumbs down to assess the quality of the automatic generation.

Best regards,
The SIGO Team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant