Skip to content

Commit

Permalink
Use Seq instead of Vector in user mgmt apis (digital-asset#12725)
Browse files Browse the repository at this point in the history
For consistency with other APIs in this area.
Note that some pre-existing APIs use `List` instead of `Seq`,
but at least those use the same underlying implementation.

CHANGELOG_BEGIN
CHANGELOG_END
  • Loading branch information
adriaanm-da authored Feb 3, 2022
1 parent 372e77d commit 810554b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ object EndpointsCompanion {
trait CreateFromUserToken[A] {
def apply(
jwt: DecodedJwt[String],
listUserRights: UserId => Future[Vector[UserRight]],
listUserRights: UserId => Future[Seq[UserRight]],
getLedgerId: () => Future[String],
): ET[A]
}
Expand Down Expand Up @@ -117,7 +117,7 @@ object EndpointsCompanion {

private def transformUserTokenTo[B](
jwt: DecodedJwt[String],
listUserRights: UserId => Future[Vector[UserRight]],
listUserRights: UserId => Future[Seq[UserRight]],
getLedgerId: () => Future[String],
)(
fromUser: FromUser[Unauthorized, B]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ object domain extends com.daml.fetchcontracts.domain.Aliases {
Ref.Party.fromString(party.unwrap).map(LedgerUserRight.CanReadAs).disjunction
}

def fromLedgerUserRights(input: Vector[LedgerUserRight]): List[UserRight] = input
def fromLedgerUserRights(input: Seq[LedgerUserRight]): List[UserRight] = input
.map[domain.UserRight] {
case LedgerUserRight.ParticipantAdmin => ParticipantAdmin
case LedgerUserRight.CanActAs(party) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,49 +52,49 @@ final class UserManagementClient(service: UserManagementServiceStub)(implicit
.deleteUser(proto.DeleteUserRequest(userId.toString))
.map(_ => ())

def listUsers(token: Option[String] = None): Future[Vector[User]] =
def listUsers(token: Option[String] = None): Future[Seq[User]] =
LedgerClient
.stub(service, token)
.listUsers(proto.ListUsersRequest())
.map(_.users.view.map(fromProtoUser).toVector)
.map(_.users.view.map(fromProtoUser).toSeq)

def grantUserRights(
userId: UserId,
rights: Seq[UserRight],
token: Option[String] = None,
): Future[Vector[UserRight]] =
): Future[Seq[UserRight]] =
LedgerClient
.stub(service, token)
.grantUserRights(proto.GrantUserRightsRequest(userId.toString, rights.map(toProtoRight)))
.map(_.newlyGrantedRights.view.collect(fromProtoRight.unlift).toVector)
.map(_.newlyGrantedRights.view.collect(fromProtoRight.unlift).toSeq)

def revokeUserRights(
userId: UserId,
rights: Seq[UserRight],
token: Option[String] = None,
): Future[Vector[UserRight]] =
): Future[Seq[UserRight]] =
LedgerClient
.stub(service, token)
.revokeUserRights(proto.RevokeUserRightsRequest(userId.toString, rights.map(toProtoRight)))
.map(_.newlyRevokedRights.view.collect(fromProtoRight.unlift).toVector)
.map(_.newlyRevokedRights.view.collect(fromProtoRight.unlift).toSeq)

/** List the rights of the given user.
* Unknown rights are ignored.
*/
def listUserRights(userId: UserId, token: Option[String] = None): Future[Vector[UserRight]] =
def listUserRights(userId: UserId, token: Option[String] = None): Future[Seq[UserRight]] =
LedgerClient
.stub(service, token)
.listUserRights(proto.ListUserRightsRequest(userId.toString))
.map(_.rights.view.collect(fromProtoRight.unlift).toVector)
.map(_.rights.view.collect(fromProtoRight.unlift).toSeq)

/** Retrieve the rights of the user authenticated by the token(s) on the call .
* Unknown rights are ignored.
*/
def listAuthenticatedUserRights(token: Option[String] = None): Future[Vector[UserRight]] =
def listAuthenticatedUserRights(token: Option[String] = None): Future[Seq[UserRight]] =
LedgerClient
.stub(service, token)
.listUserRights(proto.ListUserRightsRequest())
.map(_.rights.view.collect(fromProtoRight.unlift).toVector)
.map(_.rights.view.collect(fromProtoRight.unlift).toSeq)
}

object UserManagementClient {
Expand Down

0 comments on commit 810554b

Please sign in to comment.