Skip to content

Commit

Permalink
Fixes some names and method implementations
Browse files Browse the repository at this point in the history
Signed-off-by: Darshit Chanpura <[email protected]>
  • Loading branch information
DarshitChanpura committed Oct 14, 2024
1 parent 4d00642 commit 5213e6f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@
import org.opensearch.sample.actions.list.ListAccessibleResourcesAction;
import org.opensearch.sample.actions.list.ListAccessibleResourcesRestAction;
import org.opensearch.sample.actions.share.ShareResourceAction;
import org.opensearch.sample.actions.share.ShareResourceRestAction;
import org.opensearch.sample.actions.verify.VerifyResourceAccessAction;
import org.opensearch.sample.actions.verify.VerifyResourceAccessRestAction;
import org.opensearch.sample.transport.CreateResourceTransportAction;
import org.opensearch.sample.transport.ListAccessibleResourcesTransportAction;
import org.opensearch.sample.transport.ShareResourceTransportAction;
Expand Down Expand Up @@ -98,7 +100,12 @@ public List<RestHandler> getRestHandlers(
IndexNameExpressionResolver indexNameExpressionResolver,
Supplier<DiscoveryNodes> nodesInCluster
) {
return List.of(new CreateResourceRestAction(), new ListAccessibleResourcesRestAction());
return List.of(
new CreateResourceRestAction(),
new ListAccessibleResourcesRestAction(),
new VerifyResourceAccessRestAction(),
new ShareResourceRestAction()
);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* This class demonstrates a sample implementation of Basic Access Scopes to fit each plugin's use-case.
* The plugin then uses this scope when seeking access evaluation for a user on a particular resource.
*/
enum SampleResourceScope implements ResourceAccessScope {
public enum SampleResourceScope implements ResourceAccessScope {

SAMPLE_FULL_ACCESS("sample_full_access");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public List<Route> routes() {

@Override
public String getName() {
return "list_sample_resources";
return "share_sample_resources";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.opensearch.accesscontrol.resources.ResourceService;
import org.opensearch.accesscontrol.resources.ResourceSharing;
import org.opensearch.accesscontrol.resources.ShareWith;
import org.opensearch.accesscontrol.resources.SharedWithScope;
import org.opensearch.action.index.IndexRequest;
import org.opensearch.action.index.IndexResponse;
import org.opensearch.action.support.ActionFilters;
Expand All @@ -29,6 +30,7 @@
import org.opensearch.core.xcontent.ToXContent;
import org.opensearch.sample.Resource;
import org.opensearch.sample.SampleResourcePlugin;
import org.opensearch.sample.SampleResourceScope;
import org.opensearch.sample.actions.create.CreateResourceAction;
import org.opensearch.sample.actions.create.CreateResourceRequest;
import org.opensearch.sample.actions.create.CreateResourceResponse;
Expand Down Expand Up @@ -60,6 +62,7 @@ protected void doExecute(Task task, CreateResourceRequest request, ActionListene
createResource(request, listener);
listener.onResponse(new CreateResourceResponse("Resource " + request.getResource() + " created successfully."));
} catch (Exception e) {
log.info("Failed to create resource", e);
listener.onFailure(e);
}
}
Expand All @@ -82,7 +85,13 @@ private void createResource(CreateResourceRequest request, ActionListener<Create
}

private static ActionListener<IndexResponse> getIndexResponseActionListener(ActionListener<CreateResourceResponse> listener) {
ShareWith shareWith = new ShareWith(List.of());
SharedWithScope.SharedWithPerScope sharedWithPerScope = new SharedWithScope.SharedWithPerScope(
List.of(),
List.of(),
List.of()
);
SharedWithScope sharedWithScope = new SharedWithScope(SampleResourceScope.SAMPLE_FULL_ACCESS.getName(), sharedWithPerScope);
ShareWith shareWith = new ShareWith(List.of(sharedWithScope));
return ActionListener.wrap(idxResponse -> {
log.info("Created resource: {}", idxResponse.toString());
ResourceService rs = SampleResourcePlugin.GuiceHolder.getResourceService();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.opensearch.sample.SampleResourcePlugin

0 comments on commit 5213e6f

Please sign in to comment.