diff --git a/api/openapi/things.yml b/api/openapi/things.yml index b6efec5541f..58d98d7effe 100644 --- a/api/openapi/things.yml +++ b/api/openapi/things.yml @@ -105,43 +105,6 @@ paths: "500": $ref: "#/components/responses/ServiceError" - /things/members: - get: - operationId: listThingMembers - tags: - - Things - summary: Retrieves things members - description: | - Retrieves a list of things members. Due to performance concerns, data - is retrieved in subsets. The API things must ensure that the entire - dataset is consumed either by making subsequent requests, or by - increasing the subset size of the initial request. - parameters: - - $ref: "#/components/parameters/Limit" - - $ref: "#/components/parameters/Offset" - - $ref: "#/components/parameters/Metadata" - - $ref: "#/components/parameters/Status" - - $ref: "#/components/parameters/ThingName" - - $ref: "#/components/parameters/Tags" - - $ref: "#/components/parameters/Channel" - security: - - bearerAuth: [] - responses: - "200": - $ref: "#/components/responses/ThingPageRes" - "400": - description: Failed due to malformed query parameters. - "401": - description: | - Missing or invalid access token provided. - "403": - description: Failed to perform authorization over the entity. - "404": - description: A non-existent entity request. - "422": - description: Database can't process request. - "500": - $ref: "#/components/responses/ServiceError" /things/bulk: post: operationId: bulkCreateThings diff --git a/pkg/clients/postgres/clients.go b/pkg/clients/postgres/clients.go index 70b1fb0439a..d6aab235566 100644 --- a/pkg/clients/postgres/clients.go +++ b/pkg/clients/postgres/clients.go @@ -257,10 +257,11 @@ func (repo *Repository) RetrieveAllByIDs(ctx context.Context, pm clients.Page) ( if err != nil { return clients.ClientsPage{}, errors.Wrap(repoerr.ErrViewEntity, err) } + tq := query query = applyOrdering(query, pm) q := fmt.Sprintf(`SELECT c.id, c.name, c.tags, c.identity, c.metadata, COALESCE(c.domain_id, '') AS domain_id, c.status, - c.created_at, c.updated_at, COALESCE(c.updated_by, '') AS updated_by FROM clients c %s ORDER BY c.created_at LIMIT :limit OFFSET :offset;`, query) + c.created_at, c.updated_at, COALESCE(c.updated_by, '') AS updated_by FROM clients c %s LIMIT :limit OFFSET :offset;`, query) dbPage, err := ToDBClientsPage(pm) if err != nil { @@ -286,7 +287,7 @@ func (repo *Repository) RetrieveAllByIDs(ctx context.Context, pm clients.Page) ( items = append(items, c) } - cq := fmt.Sprintf(`SELECT COUNT(*) FROM clients c %s;`, query) + cq := fmt.Sprintf(`SELECT COUNT(*) FROM clients c %s;`, tq) total, err := postgres.Total(ctx, repo.DB, cq, dbPage) if err != nil { diff --git a/users/service.go b/users/service.go index 9aba741df72..4cee1516bea 100644 --- a/users/service.go +++ b/users/service.go @@ -200,7 +200,6 @@ func (svc service) ListClients(ctx context.Context, token string, pm mgclients.P } return svc.listUsers(ctx, res.GetDomainId(), isSuperAdmin, pm) } - } func (svc service) listEntityUsers(ctx context.Context, domainID, userID string, isSuperAdmin bool, pm mgclients.Page) (mgclients.ClientsPage, error) { @@ -247,8 +246,8 @@ func (svc service) listUsers(ctx context.Context, domainID string, isSuperAdmin } return usersPage, nil } -func (svc service) listUserIDs(ctx context.Context, domainID, reqUserSubject, objectType, objectID, permission string) ([]string, error) { +func (svc service) listUserIDs(ctx context.Context, domainID, reqUserSubject, objectType, objectID, permission string) ([]string, error) { res, err := svc.auth.Authorize(ctx, &magistrala.AuthorizeReq{ Domain: domainID, SubjectType: auth.UserType, diff --git a/users/service_test.go b/users/service_test.go index b2741a6ccc9..7fd8423562d 100644 --- a/users/service_test.go +++ b/users/service_test.go @@ -723,7 +723,7 @@ func TestListClients(t *testing.T) { err: svcerr.ErrAuthentication, }, { - desc: "list cleints as a superadmin with entity type and empty enty id", + desc: "list clients as a superadmin with entity type and empty enty id", pageMeta: mgclients.Page{ EntityType: authsvc.ThingType, EntityID: "", @@ -733,7 +733,7 @@ func TestListClients(t *testing.T) { err: svcerr.ErrMalformedEntity, }, { - desc: "list cleints as non superadmin with empty entity type and id", + desc: "list clients as non superadmin with empty entity type and id", pageMeta: mgclients.Page{}, identifyResponse: &magistrala.IdentityRes{UserId: client.ID, DomainId: validID, Id: authsvc.EncodeDomainUserID(validID, client.ID)}, platformAuthResponse: &magistrala.AuthorizeRes{Authorized: false},