package com.hubspot.singularity.api;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Collections;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;

@Schema(description = "Represents updates to the groups for a request")
public class SingularityUpdateGroupsRequest {
  private final Optional<String> group;
  private final Set<String> readWriteGroups;
  private final Set<String> readOnlyGroups;
  private final Optional<String> message;

  @JsonCreator
  public SingularityUpdateGroupsRequest(
    @JsonProperty("group") Optional<String> group,
    @JsonProperty("readWriteGroups") Set<String> readWriteGroups,
    @JsonProperty("readOnlyGroups") Set<String> readOnlyGroups,
    @JsonProperty("message") Optional<String> message
  ) {
    this.group = group;
    this.readWriteGroups =
      readWriteGroups != null ? readWriteGroups : Collections.emptySet();
    this.readOnlyGroups =
      readOnlyGroups != null ? readOnlyGroups : Collections.emptySet();
    this.message = message;
  }

  @Schema(description = "The primary request group", nullable = true)
  public Optional<String> getGroup() {
    return group;
  }

  @Schema(description = "Groups allowed read/write access to a request")
  public Set<String> getReadWriteGroups() {
    return readWriteGroups;
  }

  @Schema(description = "Groups allowed read only access to a request")
  public Set<String> getReadOnlyGroups() {
    return readOnlyGroups;
  }

  @Schema(
    description = "An option message detailing the reason for the group updates",
    nullable = true
  )
  public Optional<String> getMessage() {
    return message;
  }

  @Override
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }
    if (obj instanceof SingularityUpdateGroupsRequest) {
      final SingularityUpdateGroupsRequest that = (SingularityUpdateGroupsRequest) obj;
      return (
        Objects.equals(this.group, that.group) &&
        Objects.equals(this.readWriteGroups, that.readWriteGroups) &&
        Objects.equals(this.readOnlyGroups, that.readOnlyGroups) &&
        Objects.equals(this.message, that.message)
      );
    }
    return false;
  }

  @Override
  public int hashCode() {
    return Objects.hash(group, readWriteGroups, readOnlyGroups, message);
  }

  @Override
  public String toString() {
    return (
      "SingularityUpdateGroupsRequest{" +
      "group=" +
      group +
      ", readWriteGroups=" +
      readWriteGroups +
      ", readOnlyGroups=" +
      readOnlyGroups +
      ", message=" +
      message +
      '}'
    );
  }
}

@@ -138,16 +138,78 @@
 operty;%0A
+import com.hubspot.singularity.SingularityAuthorizationScope;%0A
 import i
@@ -251,16 +251,16 @@
 Schema;%0A
-
 import j
@@ -281,16 +281,38 @@
 ctions;%0A
+import java.util.Map;%0A
 import j
@@ -618,32 +618,127 @@
 readOnlyGroups;%0A
+  private final Optional%3CMap%3CString, Set%3CSingularityAuthorizationScope%3E%3E%3E groupScopeOverrides;%0A
   private final 
@@ -993,32 +993,164 @@
 readOnlyGroups,%0A
+    @JsonProperty(%0A      %22groupScopeOverrides%22%0A    ) Optional%3CMap%3CString, Set%3CSingularityAuthorizationScope%3E%3E%3E groupScopeOverrides,%0A
     @JsonPropert
@@ -1408,32 +1408,84 @@
 ons.emptySet();%0A
+    this.groupScopeOverrides = groupScopeOverrides;%0A
     this.message
@@ -1922,32 +1922,227 @@
 nlyGroups;%0A  %7D%0A%0A
+  @Schema(description = %22Overidden scopes for specific groups%22)%0A  public Optional%3CMap%3CString, Set%3CSingularityAuthorizationScope%3E%3E%3E getGroupScopeOverrides() %7B%0A    return groupScopeOverrides;%0A  %7D%0A%0A
   @Schema(%0A    d
@@ -2746,32 +2746,110 @@
 dOnlyGroups) &&%0A
+        Objects.equals(this.groupScopeOverrides, that.groupScopeOverrides) &&%0A
         Objects.
@@ -2983,22 +2983,35 @@
 ts.hash(
-group,
+%0A      group,%0A     
  readWri
@@ -3019,16 +3019,22 @@
 eGroups,
+%0A     
  readOnl
@@ -3041,24 +3041,57 @@
 yGroups,
+%0A      groupScopeOverrides,%0A     
  message
 );%0A  %7D%0A%0A
@@ -3082,16 +3082,21 @@
  message
+%0A    
 );%0A  %7D%0A%0A
@@ -3295,32 +3295,32 @@
 dOnlyGroups=%22 +%0A
-
       readOnlyGr
@@ -3318,32 +3318,93 @@
 eadOnlyGroups +%0A
+      %22, groupScopeOverrides=%22 +%0A      groupScopeOverrides +%0A
       %22, message

Update groups request