Skip to content

Commit

Permalink
Merge pull request #71 from orkes-io/add-domain-target-for-authorizat…
Browse files Browse the repository at this point in the history
…ion-client

Added domain as a target for AuthorizationClient
  • Loading branch information
gardusig authored Jan 18, 2023
2 parents a8499e9 + 1a50611 commit 287b60b
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 12 deletions.
76 changes: 64 additions & 12 deletions src/main/java/io/orkes/conductor/client/model/TargetRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,73 @@
import com.google.gson.stream.JsonWriter;
import io.swagger.v3.oas.annotations.media.Schema;

/** The object over which access is being granted or removed */
/**
* The object over which access is being granted or removed
*/
@Schema(description = "The object over which access is being granted or removed")
@javax.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.JavaClientCodegen", date = "2023-01-18T16:50:52.109134-03:00[America/Sao_Paulo]")
public class TargetRef {
/**
* Gets or Sets id
*/
@JsonAdapter(IdEnum.Adapter.class)
public enum IdEnum {
IDENTIFIER_OF_THE_TARGET_E_G_NAME_IN_CASE_IT_S_A_WORKFLOW_DEF(
"Identifier of the target e.g. `name` in case it's a WORKFLOW_DEF");

private String value;

IdEnum(String value) {
this.value = value;
}

public String getValue() {
return value;
}

@Override
public String toString() {
return String.valueOf(value);
}

public static IdEnum fromValue(String input) {
for (IdEnum b : IdEnum.values()) {
if (b.value.equals(input)) {
return b;
}
}
return null;
}

public static class Adapter extends TypeAdapter<IdEnum> {
@Override
public void write(final JsonWriter jsonWriter, final IdEnum enumeration) throws IOException {
jsonWriter.value(String.valueOf(enumeration.getValue()));
}

@Override
public IdEnum read(final JsonReader jsonReader) throws IOException {
Object value = jsonReader.nextString();
return IdEnum.fromValue((String) (value));
}
}
}

@SerializedName("id")
private String id = null;

/** Gets or Sets type */
/**
* Gets or Sets type
*/
@JsonAdapter(TypeEnum.Adapter.class)
public enum TypeEnum {
WORKFLOW_DEF("WORKFLOW_DEF"),
TASK_DEF("TASK_DEF"),
APPLICATION("APPLICATION"),
USER("USER"),
SECRET("SECRET"),
TAG("TAG"),
USER("USER");
DOMAIN("DOMAIN");

private String value;

Expand Down Expand Up @@ -64,8 +116,7 @@ public static TypeEnum fromValue(String input) {

public static class Adapter extends TypeAdapter<TypeEnum> {
@Override
public void write(final JsonWriter jsonWriter, final TypeEnum enumeration)
throws IOException {
public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException {
jsonWriter.value(String.valueOf(enumeration.getValue()));
}

Expand All @@ -87,9 +138,9 @@ public TargetRef id(String id) {

/**
* Get id
*
*
* @return id
*/
**/
@Schema(required = true, description = "")
public String getId() {
return id;
Expand All @@ -106,9 +157,9 @@ public TargetRef type(TypeEnum type) {

/**
* Get type
*
*
* @return type
*/
**/
@Schema(required = true, description = "")
public TypeEnum getType() {
return type;
Expand All @@ -127,7 +178,8 @@ public boolean equals(java.lang.Object o) {
return false;
}
TargetRef targetRef = (TargetRef) o;
return Objects.equals(this.id, targetRef.id) && Objects.equals(this.type, targetRef.type);
return Objects.equals(this.id, targetRef.id) &&
Objects.equals(this.type, targetRef.type);
}

@Override
Expand All @@ -147,8 +199,8 @@ public String toString() {
}

/**
* Convert the given object to string with each line indented by 4 spaces (except the first
* line).
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,21 @@ void testGrantPermissionsToGroup() {
authorizationClient.grantPermissions(request);
}

@Test
void testGrantPermissionsToDomain() {
AuthorizationRequest request = new AuthorizationRequest();
request.access(Arrays.asList(AuthorizationRequest.AccessEnum.EXECUTE));
SubjectRef subject = new SubjectRef();
subject.setId("app:89b6d9b8-c56c-41e7-98de-4049f57943c1");
subject.setType(SubjectRef.TypeEnum.USER);
request.setSubject(subject);
TargetRef target = new TargetRef();
target.setId("my-domain");
target.setType(TargetRef.TypeEnum.DOMAIN);
request.setTarget(target);
authorizationClient.grantPermissions(request);
}

@Test
void testGrantPermissionsToTag() {
authorizationClient.grantPermissions(getAuthorizationRequest());
Expand Down

0 comments on commit 287b60b

Please sign in to comment.