Skip to content

Commit cf01937

Browse files
authored
Merge pull request #34 from 2uan2/master
Added partial support for interacting with the Groups API through the SDK
2 parents 23cf6a8 + a73c03b commit cf01937

12 files changed

Lines changed: 972 additions & 7 deletions

File tree

src/main/java/io/permit/sdk/api/ApiClient.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ public class ApiClient implements IDeprecatedApis {
119119
*/
120120
public final ElementsApi elements;
121121

122+
/**
123+
* The {@code GroupsApi} instance for accessing Permit Groups related API endpoints.
124+
*/
125+
public final GroupsApi groups;
122126

123127
/**
124128
* Constructs a new instance of the {@code ApiClient} class with the specified configuration.
@@ -148,6 +152,7 @@ public ApiClient(PermitConfig config) {
148152
this.relationshipTuples = new RelationshipTuplesApi(this.client, this.config);
149153
this.conditionSetRules = new ConditionSetRulesApi(this.client, this.config);
150154
this.elements = new ElementsApi(this.client, this.config);
155+
this.groups = new GroupsApi(this.client, this.config);
151156
}
152157

153158
/**

src/main/java/io/permit/sdk/api/GroupsApi.java

Lines changed: 327 additions & 0 deletions
Large diffs are not rendered by default.

src/main/java/io/permit/sdk/api/RelationshipTuplesApi.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public RelationshipTupleRead[] list(String subject, String relation, String obje
114114
* @param object The object of the relationship (a resource instance key).
115115
* @param page The page number of the results.
116116
* @return An array of RelationshipTupleRead objects representing the relationship tuples.
117-
* @throws IOException If an I/Oerror occurs during the HTTP request.
117+
* @throws IOException If an I/O error occurs during the HTTP request.
118118
* @throws PermitApiError If the Permit API returns a response with an error status code.
119119
* @throws PermitContextError If the configured {@link io.permit.sdk.PermitContext} does not match the required endpoint context.
120120
*/
@@ -129,7 +129,7 @@ public RelationshipTupleRead[] list(String subject, String relation, String obje
129129
* @param relation The relation between the two resource instances.
130130
* @param object The object of the relationship (a resource instance key).
131131
* @return An array of RelationshipTupleRead objects representing the relationship tuples.
132-
* @throws IOException If an I/Oerror occurs during the HTTP request.
132+
* @throws IOException If an I/O error occurs during the HTTP request.
133133
* @throws PermitApiError If the Permit API returns a response with an error status code.
134134
* @throws PermitContextError If the configured {@link io.permit.sdk.PermitContext} does not match the required endpoint context.
135135
*/
@@ -141,7 +141,7 @@ public RelationshipTupleRead[] list(String subject, String relation, String obje
141141
* Lists all relationship tuples with the default pagination parameters.
142142
*
143143
* @return An array of RelationshipTupleRead objects representing the relationship tuples.
144-
* @throws IOException If an I/Oerror occurs during the HTTP request.
144+
* @throws IOException If an I/O error occurs during the HTTP request.
145145
* @throws PermitApiError If the Permit API returns a response with an error status code.
146146
* @throws PermitContextError If the configured {@link io.permit.sdk.PermitContext} does not match the required endpoint context.
147147
*/

src/main/java/io/permit/sdk/api/ResourceInstancesApi.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ public ResourceInstanceRead get(String instanceKey) throws IOException, PermitAp
146146

147147
/**
148148
* Retrieves a resource instance by its key.
149+
* This is an alias for the {@link #get} method.
149150
*
150151
* @param instanceKey The key of the resource instance.
151152
* @return A ResourceInstanceRead object representing the retrieved resource instance.

src/main/java/io/permit/sdk/api/ResourceRelationsApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public RelationRead getById(UUID resourceId, UUID relationId) throws IOException
172172

173173
/**
174174
* Creates a new relation under the specified resource.
175-
* Since resource respresents a type, the relation itself represents a type and not a value.
175+
* Since resource represents a type, the relation itself represents a type and not a value.
176176
*
177177
* @param resourceKey The key of the resource.
178178
* @param relationData The {@link RelationCreate} object containing the data for the new resource relation.

src/main/java/io/permit/sdk/api/UsersApi.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public PaginatedResultUserRead list() throws IOException, PermitApiError, Permit
135135
/**
136136
* Retrieves a user by its key.
137137
*
138-
* @param userKey The key of theuser.
138+
* @param userKey The key of the user.
139139
* @return A UserRead object representing the retrieved user.
140140
* @throws IOException If an I/O error occurs during the HTTP request.
141141
* @throws PermitApiError If the Permit API returns a response with an error status code.
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
* Permit.io API
3+
* Authorization as a service
4+
*
5+
* The version of the OpenAPI document: 2.0.0
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
14+
package io.permit.sdk.openapi.models;
15+
16+
import javax.annotation.Generated;
17+
import com.google.gson.annotations.Expose;
18+
import com.google.gson.annotations.SerializedName;
19+
20+
21+
/**
22+
* GroupAddRole
23+
* <p>
24+
*
25+
*
26+
*/
27+
@Generated("jsonschema2pojo")
28+
public class GroupAddRole {
29+
/**
30+
* Role
31+
* <p>
32+
* The role key or id that will be assigned to the group.
33+
* (Required)
34+
*
35+
*/
36+
@SerializedName("role")
37+
@Expose
38+
public String role;
39+
/**
40+
* Resource
41+
* <p>
42+
* The resource key or id that the role belongs to.
43+
* (Required)
44+
*
45+
*/
46+
@SerializedName("resource")
47+
@Expose
48+
public String resource;
49+
/**
50+
* ResourceInstance
51+
* <p>
52+
* The resource instance key or id that the role belongs to.
53+
* (Required)
54+
*
55+
*/
56+
@SerializedName("resource_instance")
57+
@Expose
58+
public String resourceInstance;
59+
/**
60+
* Tenant
61+
* <p>
62+
* The tenant key or id that the role belongs to.
63+
* (Required)
64+
*
65+
*/
66+
@SerializedName("tenant")
67+
@Expose
68+
public String tenant;
69+
70+
/**
71+
* No args constructor for use in serialization
72+
*
73+
*/
74+
public GroupAddRole() {
75+
}
76+
77+
/**
78+
* Constructs a new GroupAddRole with all required identifiers.
79+
*
80+
* @param role the role key or id to assign to the group
81+
* @param resourceInstance the resource instance key or id that the role belongs to
82+
* @param resource the resource key or id that the role belongs to
83+
* @param tenant the tenant key or id that the role belongs to
84+
*/
85+
public GroupAddRole(java.lang.String role, java.lang.String resourceInstance, java.lang.String resource, java.lang.String tenant) {
86+
super();
87+
this.role = role;
88+
this.resourceInstance = resourceInstance;
89+
this.resource = resource;
90+
this.tenant = tenant;
91+
}
92+
93+
public GroupAddRole withRole(java.lang.String role) {
94+
this.role = role;
95+
return this;
96+
}
97+
98+
public GroupAddRole withResourceInstanceKey(java.lang.String resourceInstance) {
99+
this.resourceInstance = resourceInstance;
100+
return this;
101+
}
102+
103+
public GroupAddRole withResource(java.lang.String resource) {
104+
this.resource = resource;
105+
return this;
106+
}
107+
108+
public GroupAddRole withTenant(java.lang.String tenant) {
109+
this.tenant = tenant;
110+
return this;
111+
}
112+
}
113+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Permit.io API
3+
* Authorization as a service
4+
*
5+
* The version of the OpenAPI document: 2.0.0
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
14+
package io.permit.sdk.openapi.models;
15+
16+
import com.google.gson.annotations.Expose;
17+
import com.google.gson.annotations.SerializedName;
18+
19+
/**
20+
* GroupAssignUser
21+
* <p>
22+
*
23+
*
24+
*/
25+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-11-26T18:29:37.439030+07:00[Asia/Ho_Chi_Minh]", comments = "Generator version: 7.17.0")
26+
public class GroupAssignUser {
27+
/**
28+
* Tenant
29+
* <p>
30+
* the tenant key or id that the user belongs to.
31+
* (Required)
32+
*/
33+
@SerializedName("tenant")
34+
@Expose
35+
public String tenant;
36+
37+
/**
38+
*
39+
40+
* @param tenant
41+
*/
42+
public GroupAssignUser(java.lang.String tenant) {
43+
super();
44+
this.tenant = tenant;
45+
}
46+
47+
public GroupAssignUser withTenant(java.lang.String tenant) {
48+
this.tenant = tenant;
49+
return this;
50+
}
51+
}
52+
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Permit.io API
3+
* Authorization as a service
4+
*
5+
* The version of the OpenAPI document: 2.0.0
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
14+
package io.permit.sdk.openapi.models;
15+
16+
import com.google.gson.annotations.Expose;
17+
import com.google.gson.annotations.SerializedName;
18+
19+
import javax.annotation.Generated;
20+
21+
/**
22+
* GroupCreate
23+
* <p>
24+
*
25+
*
26+
*/
27+
@Generated("jsonschema2pojo")
28+
public class GroupCreate {
29+
/**
30+
* Group Resource Type Key
31+
* <p>
32+
* The key of the resource type that the group belongs to.
33+
*
34+
*/
35+
@SerializedName("group_resource_type_key")
36+
@Expose
37+
public java.lang.String groupResourceTypeKey = "group";
38+
39+
/**
40+
* Group Instance Key
41+
* <p>
42+
* Either the unique id of the resource instance that that the group belongs to, or the URL-friendly key of the <resource_key:resource_instance_key> (i.e: file:my_file)
43+
* (Required)
44+
*
45+
*/
46+
@SerializedName("group_instance_key")
47+
@Expose
48+
public java.lang.String groupInstanceKey;
49+
50+
/**
51+
* Group Tenant
52+
* <p>
53+
* The tenant key or id that the group belongs to.
54+
* (Required)
55+
*
56+
*/
57+
@SerializedName("group_tenant")
58+
@Expose
59+
public java.lang.String groupTenant;
60+
61+
/**
62+
* No args constructor for use in serialization
63+
*
64+
*/
65+
public GroupCreate() {
66+
}
67+
68+
/**
69+
*
70+
* @param groupInstanceKey
71+
* @param groupTenant
72+
*/
73+
public GroupCreate(java.lang.String groupInstanceKey, java.lang.String groupTenant) {
74+
super();
75+
this.groupInstanceKey = groupInstanceKey;
76+
this.groupTenant = groupTenant;
77+
}
78+
79+
public GroupCreate withGroupInstanceKey(java.lang.String groupInstanceKey) {
80+
this.groupInstanceKey = groupInstanceKey;
81+
return this;
82+
}
83+
84+
public GroupCreate withGroupTenant(java.lang.String groupTenant) {
85+
this.groupTenant = groupTenant;
86+
return this;
87+
}
88+
89+
public GroupCreate withGroupResourceTypeKey(java.lang.String groupResourceTypeKey) {
90+
this.groupResourceTypeKey = groupResourceTypeKey;
91+
return this;
92+
}
93+
}
94+

0 commit comments

Comments
 (0)