Skip to content

Commit 8033793

Browse files
committed
* Entity grant UI on users and entities
* JavaScript rework to make searching simpler
1 parent a598db8 commit 8033793

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

src/FusionAuthClient.ts

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,25 @@ export class FusionAuthClient {
753753
.go();
754754
}
755755

756+
/**
757+
* Deletes an Entity Grant for the given User or Entity.
758+
*
759+
* @param {UUID} entityId The Id of the Entity that the Entity Grant is being deleted for.
760+
* @param {UUID} recipientEntityId (Optional) The Id of the Entity that the Entity Grant is for.
761+
* @param {UUID} userId (Optional) The Id of the User that the Entity Grant is for.
762+
* @returns {Promise<ClientResponse<void>>}
763+
*/
764+
deleteEntityGrant(entityId: UUID, recipientEntityId: UUID, userId: UUID): Promise<ClientResponse<void>> {
765+
return this.start<void, Errors>()
766+
.withUri('/api/entity')
767+
.withUriSegment(entityId)
768+
.withUriSegment("grant")
769+
.withParameter('recipientEntityId', recipientEntityId)
770+
.withParameter('userId', userId)
771+
.withMethod("DELETE")
772+
.go();
773+
}
774+
756775
/**
757776
* Deletes the Entity Type for the given Id.
758777
*
@@ -2286,6 +2305,25 @@ export class FusionAuthClient {
22862305
.go();
22872306
}
22882307

2308+
/**
2309+
* Retrieves an Entity Grant for the given Entity and User/Entity.
2310+
*
2311+
* @param {UUID} entityId The Id of the Entity.
2312+
* @param {UUID} recipientEntityId (Optional) The Id of the Entity that the Entity Grant is for.
2313+
* @param {UUID} userId (Optional) The Id of the User that the Entity Grant is for.
2314+
* @returns {Promise<ClientResponse<EntityGrantResponse>>}
2315+
*/
2316+
retrieveEntityGrant(entityId: UUID, recipientEntityId: UUID, userId: UUID): Promise<ClientResponse<EntityGrantResponse>> {
2317+
return this.start<EntityGrantResponse, Errors>()
2318+
.withUri('/api/entity')
2319+
.withUriSegment(entityId)
2320+
.withUriSegment("grant")
2321+
.withParameter('recipientEntityId', recipientEntityId)
2322+
.withParameter('userId', userId)
2323+
.withMethod("GET")
2324+
.go();
2325+
}
2326+
22892327
/**
22902328
* Retrieves the Entity Type for the given Id.
22912329
*
@@ -3469,6 +3507,20 @@ export class FusionAuthClient {
34693507
.go();
34703508
}
34713509

3510+
/**
3511+
* Searches Entity Grants with the specified criteria and pagination.
3512+
*
3513+
* @param {EntityGrantSearchRequest} request The search criteria and pagination information.
3514+
* @returns {Promise<ClientResponse<EntityGrantSearchResponse>>}
3515+
*/
3516+
searchEntityGrants(request: EntityGrantSearchRequest): Promise<ClientResponse<EntityGrantSearchResponse>> {
3517+
return this.start<EntityGrantSearchResponse, Errors>()
3518+
.withUri('/api/entity/grant/search')
3519+
.withJSONBody(request)
3520+
.withMethod("POST")
3521+
.go();
3522+
}
3523+
34723524
/**
34733525
* Searches the entity types with the specified criteria and pagination.
34743526
*
@@ -4162,6 +4214,23 @@ export class FusionAuthClient {
41624214
.go();
41634215
}
41644216

4217+
/**
4218+
* Creates or updates an Entity Grant. This is when a User/Entity is granted permissions to an Entity.
4219+
*
4220+
* @param {UUID} entityId The Id of the Entity that the User/Entity is being granted access to.
4221+
* @param {EntityGrantRequest} request The request object that contains all of the information used to create the Entity Grant.
4222+
* @returns {Promise<ClientResponse<void>>}
4223+
*/
4224+
upsertEntityGrant(entityId: UUID, request: EntityGrantRequest): Promise<ClientResponse<void>> {
4225+
return this.start<void, Errors>()
4226+
.withUri('/api/entity')
4227+
.withUriSegment(entityId)
4228+
.withUriSegment("grant")
4229+
.withJSONBody(request)
4230+
.withMethod("POST")
4231+
.go();
4232+
}
4233+
41654234
/**
41664235
* Validates the end-user provided user_code from the user-interaction of the Device Authorization Grant.
41674236
* If you build your own activation form you should validate the user provided code prior to beginning the Authorization grant.

0 commit comments

Comments
 (0)