{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/27870435","id":27870435,"diff_hunk":"@@ -19,20 +19,62 @@\n \n package org.elasticsearch.script;\n \n-import java.util.Locale;\n-\n /**\n- * Operation/api that uses a script as part of its execution.\n- * Note that the suggest api is considered part of search for simplicity, as well as the percolate api.\n+ * Context of an operation that uses scripts as part of its execution.\n  */\n-public enum ScriptContext {\n-    MAPPING,\n-    UPDATE,\n-    SEARCH,\n-    AGGS;\n-\n-    @Override\n-    public String toString() {\n-        return name().toLowerCase(Locale.ROOT);\n+public interface ScriptContext {\n+\n+    /**\n+     * @return the name of the operation\n+     */\n+    String key();\n+\n+    /**\n+     * Standard operations that make use of scripts as part of their execution.\n+     * Note that the suggest api is considered part of search for simplicity, as well as the percolate api.\n+     */\n+    enum Standard implements ScriptContext {\n+\n+        AGGS(\"aggs\"), MAPPING(\"mapping\"), SEARCH(\"search\"), UPDATE(\"update\");\n+\n+        private final String key;\n+\n+        Standard(String key) {\n+            this.key = key;\n+        }\n+\n+        @Override\n+        public String key() {\n+            return key;\n+        }\n+    }\n+\n+    /**\n+     * Generic custom operation exposed via plugin\n+     *\n+     * @deprecated create a new {@link org.elasticsearch.script.ScriptContext.Plugin} instance instead\n+     */\n+    @Deprecated\n+    Plugin GENERIC_PLUGIN = new Plugin(\"plugin\");","path":"src/main/java/org/elasticsearch/script/ScriptContext.java","position":53,"original_position":53,"commit_id":"90cca4b53656ac68ddf4c862296d7da5af6b52de","original_commit_id":"90cca4b53656ac68ddf4c862296d7da5af6b52de","user":{"login":"uboness","id":211019,"avatar_url":"https://avatars.githubusercontent.com/u/211019?v=3","gravatar_id":"","url":"https://api.github.com/users/uboness","html_url":"https://github.com/uboness","followers_url":"https://api.github.com/users/uboness/followers","following_url":"https://api.github.com/users/uboness/following{/other_user}","gists_url":"https://api.github.com/users/uboness/gists{/gist_id}","starred_url":"https://api.github.com/users/uboness/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uboness/subscriptions","organizations_url":"https://api.github.com/users/uboness/orgs","repos_url":"https://api.github.com/users/uboness/repos","events_url":"https://api.github.com/users/uboness/events{/privacy}","received_events_url":"https://api.github.com/users/uboness/received_events","type":"User","site_admin":false},"body":"why not put this under `Standard` and deprecate it as an option?","created_at":"2015-04-07T11:46:42Z","updated_at":"2015-04-07T11:46:42Z","html_url":"https://github.com/elastic/elasticsearch/pull/10419#discussion_r27870435","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/10419","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/27870435"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/10419#discussion_r27870435"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/10419"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/10419","id":32600834,"html_url":"https://github.com/elastic/elasticsearch/pull/10419","diff_url":"https://github.com/elastic/elasticsearch/pull/10419.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/10419.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/10419","number":10419,"state":"open","locked":false,"title":"Scripting: allow plugins to define custom operations that they use scripts for","user":{"login":"javanna","id":832460,"avatar_url":"https://avatars.githubusercontent.com/u/832460?v=3","gravatar_id":"","url":"https://api.github.com/users/javanna","html_url":"https://github.com/javanna","followers_url":"https://api.github.com/users/javanna/followers","following_url":"https://api.github.com/users/javanna/following{/other_user}","gists_url":"https://api.github.com/users/javanna/gists{/gist_id}","starred_url":"https://api.github.com/users/javanna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javanna/subscriptions","organizations_url":"https://api.github.com/users/javanna/orgs","repos_url":"https://api.github.com/users/javanna/repos","events_url":"https://api.github.com/users/javanna/events{/privacy}","received_events_url":"https://api.github.com/users/javanna/received_events","type":"User","site_admin":false},"body":"Plugins can now define multiple operations/contexts that they use scripts for. Fine-grained settings can then be used to enable/disable scripts based on each single registered context.\r\n\r\nAlso added a new generic category called `plugins`, which will be used as a default when the context is not specified. This allows us to restore backwards compatibility for plugins on `ScriptService` by restoring the old methods that don't require the script context and making them internally use the `plugins` context, as they can only be called from plugins.\r\n\r\nCloses #10347","created_at":"2015-04-03T16:52:35Z","updated_at":"2015-04-07T11:46:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ef83e1b66a59dac8b8b7f315e5ed8a918461e01c","assignee":{"login":"uboness","id":211019,"avatar_url":"https://avatars.githubusercontent.com/u/211019?v=3","gravatar_id":"","url":"https://api.github.com/users/uboness","html_url":"https://github.com/uboness","followers_url":"https://api.github.com/users/uboness/followers","following_url":"https://api.github.com/users/uboness/following{/other_user}","gists_url":"https://api.github.com/users/uboness/gists{/gist_id}","starred_url":"https://api.github.com/users/uboness/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/uboness/subscriptions","organizations_url":"https://api.github.com/users/uboness/orgs","repos_url":"https://api.github.com/users/uboness/repos","events_url":"https://api.github.com/users/uboness/events{/privacy}","received_events_url":"https://api.github.com/users/uboness/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/10419/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/10419/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/10419/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/90cca4b53656ac68ddf4c862296d7da5af6b52de","head":{"label":"javanna:enhancement/custom_script_context_plugins","ref":"enhancement/custom_script_context_plugins","sha":"90cca4b53656ac68ddf4c862296d7da5af6b52de","user":{"login":"javanna","id":832460,"avatar_url":"https://avatars.githubusercontent.com/u/832460?v=3","gravatar_id":"","url":"https://api.github.com/users/javanna","html_url":"https://github.com/javanna","followers_url":"https://api.github.com/users/javanna/followers","following_url":"https://api.github.com/users/javanna/following{/other_user}","gists_url":"https://api.github.com/users/javanna/gists{/gist_id}","starred_url":"https://api.github.com/users/javanna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javanna/subscriptions","organizations_url":"https://api.github.com/users/javanna/orgs","repos_url":"https://api.github.com/users/javanna/repos","events_url":"https://api.github.com/users/javanna/events{/privacy}","received_events_url":"https://api.github.com/users/javanna/received_events","type":"User","site_admin":false},"repo":{"id":6652220,"name":"elasticsearch","full_name":"javanna/elasticsearch","owner":{"login":"javanna","id":832460,"avatar_url":"https://avatars.githubusercontent.com/u/832460?v=3","gravatar_id":"","url":"https://api.github.com/users/javanna","html_url":"https://github.com/javanna","followers_url":"https://api.github.com/users/javanna/followers","following_url":"https://api.github.com/users/javanna/following{/other_user}","gists_url":"https://api.github.com/users/javanna/gists{/gist_id}","starred_url":"https://api.github.com/users/javanna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javanna/subscriptions","organizations_url":"https://api.github.com/users/javanna/orgs","repos_url":"https://api.github.com/users/javanna/repos","events_url":"https://api.github.com/users/javanna/events{/privacy}","received_events_url":"https://api.github.com/users/javanna/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/javanna/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/javanna/elasticsearch","forks_url":"https://api.github.com/repos/javanna/elasticsearch/forks","keys_url":"https://api.github.com/repos/javanna/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/javanna/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/javanna/elasticsearch/teams","hooks_url":"https://api.github.com/repos/javanna/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/javanna/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/javanna/elasticsearch/events","assignees_url":"https://api.github.com/repos/javanna/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/javanna/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/javanna/elasticsearch/tags","blobs_url":"https://api.github.com/repos/javanna/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/javanna/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/javanna/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/javanna/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/javanna/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/javanna/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/javanna/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/javanna/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/javanna/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/javanna/elasticsearch/subscription","commits_url":"https://api.github.com/repos/javanna/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/javanna/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/javanna/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/javanna/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/javanna/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/javanna/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/javanna/elasticsearch/merges","archive_url":"https://api.github.com/repos/javanna/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/javanna/elasticsearch/downloads","issues_url":"https://api.github.com/repos/javanna/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/javanna/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/javanna/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/javanna/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/javanna/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/javanna/elasticsearch/releases{/id}","created_at":"2012-11-12T11:11:09Z","updated_at":"2015-03-31T11:29:39Z","pushed_at":"2015-04-07T11:41:29Z","git_url":"git://github.com/javanna/elasticsearch.git","ssh_url":"git@github.com:javanna/elasticsearch.git","clone_url":"https://github.com/javanna/elasticsearch.git","svn_url":"https://github.com/javanna/elasticsearch","homepage":"http://elasticsearch.org","size":104128,"stargazers_count":1,"watchers_count":1,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"elastic:1.x","ref":"1.x","sha":"5c41bd291e4be60d8753b3de2b5c17a77f3e989c","user":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"repo":{"id":507775,"name":"elasticsearch","full_name":"elastic/elasticsearch","owner":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elastic/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":false,"url":"https://api.github.com/repos/elastic/elasticsearch","forks_url":"https://api.github.com/repos/elastic/elasticsearch/forks","keys_url":"https://api.github.com/repos/elastic/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elastic/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elastic/elasticsearch/teams","hooks_url":"https://api.github.com/repos/elastic/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/elastic/elasticsearch/events","assignees_url":"https://api.github.com/repos/elastic/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/elastic/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/elastic/elasticsearch/tags","blobs_url":"https://api.github.com/repos/elastic/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elastic/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elastic/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/elastic/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/elastic/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/elastic/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/elastic/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/elastic/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/elastic/elasticsearch/subscription","commits_url":"https://api.github.com/repos/elastic/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/elastic/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/elastic/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/elastic/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elastic/elasticsearch/merges","archive_url":"https://api.github.com/repos/elastic/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elastic/elasticsearch/downloads","issues_url":"https://api.github.com/repos/elastic/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/elastic/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/elastic/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/elastic/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elastic/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/elastic/elasticsearch/releases{/id}","created_at":"2010-02-08T13:20:56Z","updated_at":"2015-04-07T11:39:08Z","pushed_at":"2015-04-07T11:41:32Z","git_url":"git://github.com/elastic/elasticsearch.git","ssh_url":"git@github.com:elastic/elasticsearch.git","clone_url":"https://github.com/elastic/elasticsearch.git","svn_url":"https://github.com/elastic/elasticsearch","homepage":"http://elasticsearch.org","size":320296,"stargazers_count":10688,"watchers_count":10688,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3332,"mirror_url":null,"open_issues_count":1069,"forks":3332,"open_issues":1069,"watchers":10688,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/10419"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/10419"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/10419"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/10419/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/10419/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/10419/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/90cca4b53656ac68ddf4c862296d7da5af6b52de"}}}}