@@ -70,7 +70,8 @@ These sections show how to use the SDK to perform API management functions. Befo
70708 . [ Manage Flows] ( #manage-flows )
71719 . [ Manage JWTs] ( #manage-jwts )
727210 . [ Audit] ( #audit )
73- 11 . [ Manage Project] ( #manage-project )
73+ 11 . [ FGA (Fine-Grained Authorization)] ( #fga-fine-grained-authorization )
74+ 12 . [ Manage Project] ( #manage-project )
7475
7576If you wish to run any of our code samples and play with them, check out our [ Code Examples] ( #code-examples ) section.
7677
@@ -1265,6 +1266,94 @@ try {
12651266 // Handle the error
12661267}
12671268```
1269+
1270+ ### FGA (Fine-Grained Authorization)
1271+
1272+ You can manage fine-grained authorization schemas, relations, and resource metadata:
1273+
1274+ ``` java
1275+ // Create and manage authorization schemas
1276+ FGAService fs = descopeClient. getManagementServices(). getFgaService();
1277+
1278+ String dsl = " model AuthZ 1.0\n " +
1279+ " type user\n " +
1280+ " type document\n " +
1281+ " relation owner: user\n " +
1282+ " relation editor: user\n " +
1283+ " relation viewer: user" ;
1284+
1285+ try {
1286+ FGASchema schema = new FGASchema (dsl);
1287+ fs. saveSchema(schema);
1288+ } catch (DescopeException de) {
1289+ // Handle the error
1290+ }
1291+
1292+ // Load the current authorization schema
1293+ try {
1294+ FGASchema schema = fs. loadSchema();
1295+ // Do something with schema.getDsl()
1296+ } catch (DescopeException de) {
1297+ // Handle the error
1298+ }
1299+
1300+ // Create relations between resources and users
1301+ List<FGARelation > relations = Arrays . asList(
1302+ new FGARelation (" doc1" , " document" , " owner" , " user123" , " user" ),
1303+ new FGARelation (" doc1" , " document" , " viewer" , " user456" , " user" )
1304+ );
1305+
1306+ try {
1307+ fs. createRelations(relations);
1308+ } catch (DescopeException de) {
1309+ // Handle the error
1310+ }
1311+
1312+ // Check if relations are allowed
1313+ try {
1314+ List<FGACheckResult > results = fs. check(relations);
1315+ for (FGACheckResult result : results) {
1316+ // Do something with result.isAllowed()
1317+ }
1318+ } catch (DescopeException de) {
1319+ // Handle the error
1320+ }
1321+
1322+ // Delete relations
1323+ try {
1324+ fs. deleteRelations(relations);
1325+ } catch (DescopeException de) {
1326+ // Handle the error
1327+ }
1328+
1329+ // Save resource metadata
1330+ List<FGAResourceDetails > resourceDetails = Arrays . asList(
1331+ new FGAResourceDetails (" doc1" , " document" , " Important Document" ),
1332+ new FGAResourceDetails (" doc2" , " document" , " Public Document" )
1333+ );
1334+
1335+ try {
1336+ fs. saveResourcesDetails(resourceDetails);
1337+ } catch (DescopeException de) {
1338+ // Handle the error
1339+ }
1340+
1341+ // Load resource metadata
1342+ List<FGAResourceIdentifier > identifiers = Arrays . asList(
1343+ new FGAResourceIdentifier (" doc1" , " document" )
1344+ );
1345+
1346+ try {
1347+ List<FGAResourceDetails > details = fs. loadResourcesDetails(identifiers);
1348+ for (FGAResourceDetails detail : details) {
1349+ // Do something with detail.getDisplayName()
1350+ }
1351+ } catch (DescopeException de) {
1352+ // Handle the error
1353+ }
1354+
1355+ ```
1356+
12681357### Manage Project
12691358
12701359You can change the project name, as well as to clone the current project to a new one.
0 commit comments