7
7
8
8
import static org .opensearch .common .xcontent .json .JsonXContent .jsonXContent ;
9
9
import static org .opensearch .ml .common .CommonValue .ML_MODEL_GROUP_INDEX ;
10
+ import static org .opensearch .ml .common .settings .MLCommonsSettings .ML_COMMONS_MODEL_ACCESS_CONTROL_ENABLED ;
10
11
import static org .opensearch .security .spi .resources .FeatureConfigConstants .OPENSEARCH_RESOURCE_SHARING_ENABLED ;
11
12
import static org .opensearch .security .spi .resources .FeatureConfigConstants .OPENSEARCH_RESOURCE_SHARING_ENABLED_DEFAULT ;
13
+ import static org .opensearch .security .spi .resources .ResourceAccessLevels .PLACE_HOLDER ;
12
14
13
15
import java .time .Instant ;
14
16
import java .util .HashSet ;
57
59
import org .opensearch .search .builder .SearchSourceBuilder ;
58
60
import org .opensearch .security .spi .resources .client .ResourceSharingClient ;
59
61
import org .opensearch .security .spi .resources .sharing .Recipient ;
60
- import org .opensearch .security .spi .resources .sharing .SharedWithActionGroup ;
62
+ import org .opensearch .security .spi .resources .sharing .Recipients ;
63
+ import org .opensearch .security .spi .resources .sharing .ShareWith ;
61
64
import org .opensearch .transport .client .Client ;
62
65
63
66
import lombok .extern .log4j .Log4j2 ;
@@ -98,8 +101,8 @@ public void createModelGroup(MLRegisterModelGroupInput input, ActionListener<Str
98
101
User user = RestActionUtils .getUserContext (client );
99
102
// Create a recipient sharing list
100
103
AtomicReference <Map <Recipient , Set <String >>> recipientMap = new AtomicReference <>();
101
- boolean isResourceSharingFeatureEnabled = this . settings
102
- .getAsBoolean (OPENSEARCH_RESOURCE_SHARING_ENABLED , OPENSEARCH_RESOURCE_SHARING_ENABLED_DEFAULT );
104
+ boolean isResourceSharingFeatureEnabled = ML_COMMONS_MODEL_ACCESS_CONTROL_ENABLED . get ( settings )
105
+ && this . settings .getAsBoolean (OPENSEARCH_RESOURCE_SHARING_ENABLED , OPENSEARCH_RESOURCE_SHARING_ENABLED_DEFAULT );
103
106
104
107
try (ThreadContext .StoredContext context = client .threadPool ().getThreadContext ().stashContext ()) {
105
108
ActionListener <String > wrappedListener = ActionListener .runBefore (listener , context ::restore );
@@ -191,8 +194,9 @@ public void createModelGroup(MLRegisterModelGroupInput input, ActionListener<Str
191
194
// Create an entry in resource-sharing index
192
195
String modelGroupId = indexResponse .getId ();
193
196
String modelGroupIndex = indexResponse .getIndex ();
194
- SharedWithActionGroup .ActionGroupRecipients recipients =
195
- new SharedWithActionGroup .ActionGroupRecipients (recipientMap .get ());
197
+ ShareWith shareWith = new ShareWith (
198
+ Map .of (PLACE_HOLDER , new Recipients (recipientMap .get ()))
199
+ );
196
200
197
201
ResourceSharingClient resourceSharingClient = ResourceSharingClientAccessor
198
202
.getInstance ()
@@ -202,7 +206,7 @@ public void createModelGroup(MLRegisterModelGroupInput input, ActionListener<Str
202
206
.share (
203
207
modelGroupId ,
204
208
modelGroupIndex ,
205
- recipients ,
209
+ shareWith ,
206
210
ActionListener .wrap (resourceSharing -> {
207
211
log
208
212
.debug (
0 commit comments