diff --git a/src/CodeGeneration/ApiGenerator/ApiGenerator.cs b/src/CodeGeneration/ApiGenerator/ApiGenerator.cs index 85102887829..fb542724edf 100644 --- a/src/CodeGeneration/ApiGenerator/ApiGenerator.cs +++ b/src/CodeGeneration/ApiGenerator/ApiGenerator.cs @@ -24,20 +24,12 @@ public class ApiGenerator "xpack.ml.delete_filter.json", "xpack.ml.get_filters.json", "xpack.ml.put_filter.json", + "xpack.ml.update_filter.json", "rank_eval.json", // these API's are new and need to be mapped "xpack.ml.delete_forecast.json", "xpack.ml.find_file_structure.json", - - "xpack.ml.update_filter.json", - "xpack.security.delete_privileges.json", - "xpack.security.get_privileges.json", - "xpack.security.get_user_privileges.json", - "xpack.security.get_index_privileges.json", - "xpack.security.has_privileges.json", - "xpack.security.put_privilege.json", - "xpack.security.put_privileges.json", }; public static void Generate(string downloadBranch, params string[] folders) diff --git a/src/CodeGeneration/ApiGenerator/Domain/ApiUrlPart.cs b/src/CodeGeneration/ApiGenerator/Domain/ApiUrlPart.cs index 6eb846f2a09..2e2e46cf051 100644 --- a/src/CodeGeneration/ApiGenerator/Domain/ApiUrlPart.cs +++ b/src/CodeGeneration/ApiGenerator/Domain/ApiUrlPart.cs @@ -61,6 +61,7 @@ public string ClrTypeName return "Metrics"; case "feature": return "Features"; case "action_id": return "ActionIds"; + case "application": case "repository": case "snapshot": case "lang": @@ -71,6 +72,7 @@ public string ClrTypeName case "alias": case "context": case "name": + case "user": case "thread_pool_patterns": return Type == "string" ? "Name" : "Names"; case "parent_task_id": diff --git a/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs b/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs index 0ba171fb2df..3e82ecbc61b 100644 --- a/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs +++ b/src/Elasticsearch.Net/Domain/RequestParameters/RequestParameters.Generated.cs @@ -2685,6 +2685,16 @@ public partial class ClearCachedRolesRequestParameters : RequestParameters HttpMethod.POST; } + ///Request options for XpackSecurityDeletePrivileges
TODO
+ public partial class DeletePrivilegesRequestParameters : RequestParameters + { + public override HttpMethod DefaultHttpMethod => HttpMethod.DELETE; + /// + /// If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh + /// to make this operation visible to search, if `false` then do nothing with refreshes. + /// + public Refresh? Refresh { get => Q("refresh"); set => Q("refresh", value); } + } ///Request options for XpackSecurityDeleteRole
https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role.html
public partial class DeleteRoleRequestParameters : RequestParameters { @@ -2735,6 +2745,11 @@ public partial class EnableUserRequestParameters : RequestParameters public Refresh? Refresh { get => Q("refresh"); set => Q("refresh", value); } } + ///Request options for XpackSecurityGetPrivileges
TODO
+ public partial class GetPrivilegesRequestParameters : RequestParameters + { + public override HttpMethod DefaultHttpMethod => HttpMethod.GET; + } ///Request options for XpackSecurityGetRole
https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html
public partial class GetRoleRequestParameters : RequestParameters { @@ -2755,11 +2770,31 @@ public partial class GetUserRequestParameters : RequestParameters HttpMethod.GET; } + ///Request options for XpackSecurityGetUserPrivileges
https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html
+ public partial class GetUserPrivilegesRequestParameters : RequestParameters + { + public override HttpMethod DefaultHttpMethod => HttpMethod.GET; + } + ///Request options for XpackSecurityHasPrivileges
https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html
+ public partial class HasPrivilegesRequestParameters : RequestParameters + { + public override HttpMethod DefaultHttpMethod => HttpMethod.POST; + } ///Request options for XpackSecurityInvalidateToken
https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html
public partial class InvalidateUserAccessTokenRequestParameters : RequestParameters { public override HttpMethod DefaultHttpMethod => HttpMethod.DELETE; } + ///Request options for XpackSecurityPutPrivileges
TODO
+ public partial class PutPrivilegesRequestParameters : RequestParameters + { + public override HttpMethod DefaultHttpMethod => HttpMethod.PUT; + /// + /// If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh + /// to make this operation visible to search, if `false` then do nothing with refreshes. + /// + public Refresh? Refresh { get => Q("refresh"); set => Q("refresh", value); } + } ///Request options for XpackSecurityPutRole
https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html
public partial class PutRoleRequestParameters : RequestParameters { diff --git a/src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs b/src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs index 80278904d0b..b88df2bb9d3 100644 --- a/src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs +++ b/src/Elasticsearch.Net/ElasticLowLevelClient.Generated.cs @@ -4034,6 +4034,18 @@ public TResponse XpackSecurityClearCachedRoles(string name, ClearCach ///A func that allows you to describe the querystring parameters & request specific connection settings. public Task XpackSecurityClearCachedRolesAsync(string name, ClearCachedRolesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync(POST, Url($"_xpack/security/role/{name.NotNull("name")}/_clear_cache"), ctx, null, _params(requestParameters)); + ///DELETE on /_xpack/security/privilege/{application}/{name} TODO + ///Application name + ///Privilege name + ///A func that allows you to describe the querystring parameters & request specific connection settings. + public TResponse XpackSecurityDeletePrivileges(string application, string name, DeletePrivilegesRequestParameters requestParameters = null) + where TResponse : class, IElasticsearchResponse, new() => this.DoRequest(DELETE, Url($"_xpack/security/privilege/{application.NotNull("application")}/{name.NotNull("name")}"), null, _params(requestParameters)); + ///DELETE on /_xpack/security/privilege/{application}/{name} TODO + ///Application name + ///Privilege name + ///A func that allows you to describe the querystring parameters & request specific connection settings. + public Task XpackSecurityDeletePrivilegesAsync(string application, string name, DeletePrivilegesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) + where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync(DELETE, Url($"_xpack/security/privilege/{application.NotNull("application")}/{name.NotNull("name")}"), ctx, null, _params(requestParameters)); ///DELETE on /_xpack/security/role/{name} https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role.html ///Role name ///A func that allows you to describe the querystring parameters & request specific connection settings. @@ -4104,6 +4116,18 @@ public TResponse XpackSecurityEnableUserPost(string username, EnableU ///A func that allows you to describe the querystring parameters & request specific connection settings. public Task XpackSecurityEnableUserPostAsync(string username, EnableUserRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync(POST, Url($"_xpack/security/user/{username.NotNull("username")}/_enable"), ctx, null, _params(requestParameters)); + ///GET on /_xpack/security/privilege/{application}/{name} TODO + ///Application name + ///Privilege name + ///A func that allows you to describe the querystring parameters & request specific connection settings. + public TResponse XpackSecurityGetPrivileges(string application, string name, GetPrivilegesRequestParameters requestParameters = null) + where TResponse : class, IElasticsearchResponse, new() => this.DoRequest(GET, Url($"_xpack/security/privilege/{application.NotNull("application")}/{name.NotNull("name")}"), null, _params(requestParameters)); + ///GET on /_xpack/security/privilege/{application}/{name} TODO + ///Application name + ///Privilege name + ///A func that allows you to describe the querystring parameters & request specific connection settings. + public Task XpackSecurityGetPrivilegesAsync(string application, string name, GetPrivilegesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) + where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync(GET, Url($"_xpack/security/privilege/{application.NotNull("application")}/{name.NotNull("name")}"), ctx, null, _params(requestParameters)); ///GET on /_xpack/security/role/{name} https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html ///Role name ///A func that allows you to describe the querystring parameters & request specific connection settings. @@ -4168,6 +4192,54 @@ public TResponse XpackSecurityGetUser(GetUserRequestParameters reques ///A func that allows you to describe the querystring parameters & request specific connection settings. public Task XpackSecurityGetUserAsync(GetUserRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync(GET, Url($"_xpack/security/user"), ctx, null, _params(requestParameters)); + ///GET on /_xpack/security/user/_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html + ///A func that allows you to describe the querystring parameters & request specific connection settings. + public TResponse XpackSecurityGetUserPrivileges(GetUserPrivilegesRequestParameters requestParameters = null) + where TResponse : class, IElasticsearchResponse, new() => this.DoRequest(GET, Url($"_xpack/security/user/_privileges"), null, _params(requestParameters)); + ///GET on /_xpack/security/user/_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html + ///A func that allows you to describe the querystring parameters & request specific connection settings. + public Task XpackSecurityGetUserPrivilegesAsync(GetUserPrivilegesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) + where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync(GET, Url($"_xpack/security/user/_privileges"), ctx, null, _params(requestParameters)); + ///GET on /_xpack/security/user/_has_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html + ///A func that allows you to describe the querystring parameters & request specific connection settings. + public TResponse XpackSecurityHasPrivilegesGet(HasPrivilegesRequestParameters requestParameters = null) + where TResponse : class, IElasticsearchResponse, new() => this.DoRequest(GET, Url($"_xpack/security/user/_has_privileges"), null, _params(requestParameters)); + ///GET on /_xpack/security/user/_has_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html + ///A func that allows you to describe the querystring parameters & request specific connection settings. + public Task XpackSecurityHasPrivilegesGetAsync(HasPrivilegesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) + where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync(GET, Url($"_xpack/security/user/_has_privileges"), ctx, null, _params(requestParameters)); + ///GET on /_xpack/security/user/{user}/_has_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html + ///Username + ///A func that allows you to describe the querystring parameters & request specific connection settings. + public TResponse XpackSecurityHasPrivilegesGet(string user, HasPrivilegesRequestParameters requestParameters = null) + where TResponse : class, IElasticsearchResponse, new() => this.DoRequest(GET, Url($"_xpack/security/user/{user.NotNull("user")}/_has_privileges"), null, _params(requestParameters)); + ///GET on /_xpack/security/user/{user}/_has_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html + ///Username + ///A func that allows you to describe the querystring parameters & request specific connection settings. + public Task XpackSecurityHasPrivilegesGetAsync(string user, HasPrivilegesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) + where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync(GET, Url($"_xpack/security/user/{user.NotNull("user")}/_has_privileges"), ctx, null, _params(requestParameters)); + ///POST on /_xpack/security/user/_has_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html + ///The privileges to test + ///A func that allows you to describe the querystring parameters & request specific connection settings. + public TResponse XpackSecurityHasPrivileges(PostData body, HasPrivilegesRequestParameters requestParameters = null) + where TResponse : class, IElasticsearchResponse, new() => this.DoRequest(POST, Url($"_xpack/security/user/_has_privileges"), body, _params(requestParameters)); + ///POST on /_xpack/security/user/_has_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html + ///The privileges to test + ///A func that allows you to describe the querystring parameters & request specific connection settings. + public Task XpackSecurityHasPrivilegesAsync(PostData body, HasPrivilegesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) + where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync(POST, Url($"_xpack/security/user/_has_privileges"), ctx, body, _params(requestParameters)); + ///POST on /_xpack/security/user/{user}/_has_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html + ///Username + ///The privileges to test + ///A func that allows you to describe the querystring parameters & request specific connection settings. + public TResponse XpackSecurityHasPrivileges(string user, PostData body, HasPrivilegesRequestParameters requestParameters = null) + where TResponse : class, IElasticsearchResponse, new() => this.DoRequest(POST, Url($"_xpack/security/user/{user.NotNull("user")}/_has_privileges"), body, _params(requestParameters)); + ///POST on /_xpack/security/user/{user}/_has_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html + ///Username + ///The privileges to test + ///A func that allows you to describe the querystring parameters & request specific connection settings. + public Task XpackSecurityHasPrivilegesAsync(string user, PostData body, HasPrivilegesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) + where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync(POST, Url($"_xpack/security/user/{user.NotNull("user")}/_has_privileges"), ctx, body, _params(requestParameters)); ///DELETE on /_xpack/security/oauth2/token https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html ///The token to invalidate ///A func that allows you to describe the querystring parameters & request specific connection settings. @@ -4178,6 +4250,26 @@ public TResponse XpackSecurityInvalidateToken(PostData body, Invalida ///A func that allows you to describe the querystring parameters & request specific connection settings. public Task XpackSecurityInvalidateTokenAsync(PostData body, InvalidateUserAccessTokenRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync(DELETE, Url($"_xpack/security/oauth2/token"), ctx, body, _params(requestParameters)); + ///PUT on /_xpack/security/privilege/ TODO + ///The privilege(s) to add + ///A func that allows you to describe the querystring parameters & request specific connection settings. + public TResponse XpackSecurityPutPrivileges(PostData body, PutPrivilegesRequestParameters requestParameters = null) + where TResponse : class, IElasticsearchResponse, new() => this.DoRequest(PUT, Url($"_xpack/security/privilege/"), body, _params(requestParameters)); + ///PUT on /_xpack/security/privilege/ TODO + ///The privilege(s) to add + ///A func that allows you to describe the querystring parameters & request specific connection settings. + public Task XpackSecurityPutPrivilegesAsync(PostData body, PutPrivilegesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) + where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync(PUT, Url($"_xpack/security/privilege/"), ctx, body, _params(requestParameters)); + ///POST on /_xpack/security/privilege/ TODO + ///The privilege(s) to add + ///A func that allows you to describe the querystring parameters & request specific connection settings. + public TResponse XpackSecurityPutPrivilegesPost(PostData body, PutPrivilegesRequestParameters requestParameters = null) + where TResponse : class, IElasticsearchResponse, new() => this.DoRequest(POST, Url($"_xpack/security/privilege/"), body, _params(requestParameters)); + ///POST on /_xpack/security/privilege/ TODO + ///The privilege(s) to add + ///A func that allows you to describe the querystring parameters & request specific connection settings. + public Task XpackSecurityPutPrivilegesPostAsync(PostData body, PutPrivilegesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) + where TResponse : class, IElasticsearchResponse, new() => this.DoRequestAsync(POST, Url($"_xpack/security/privilege/"), ctx, body, _params(requestParameters)); ///PUT on /_xpack/security/role/{name} https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html ///Role name ///The role to add diff --git a/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs b/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs index 0885375ddb5..451794b7bbd 100644 --- a/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs +++ b/src/Elasticsearch.Net/IElasticLowLevelClient.Generated.cs @@ -3268,6 +3268,16 @@ public partial interface IElasticLowLevelClient ///Role name ///A func that allows you to describe the querystring parameters & request specific connection settings. Task XpackSecurityClearCachedRolesAsync(string name, ClearCachedRolesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new(); + ///DELETE on /_xpack/security/privilege/{application}/{name} TODO + ///Application name + ///Privilege name + ///A func that allows you to describe the querystring parameters & request specific connection settings. + TResponse XpackSecurityDeletePrivileges(string application, string name, DeletePrivilegesRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new(); + ///DELETE on /_xpack/security/privilege/{application}/{name} TODO + ///Application name + ///Privilege name + ///A func that allows you to describe the querystring parameters & request specific connection settings. + Task XpackSecurityDeletePrivilegesAsync(string application, string name, DeletePrivilegesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new(); ///DELETE on /_xpack/security/role/{name} https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role.html ///Role name ///A func that allows you to describe the querystring parameters & request specific connection settings. @@ -3324,6 +3334,16 @@ public partial interface IElasticLowLevelClient ///The username of the user to enable ///A func that allows you to describe the querystring parameters & request specific connection settings. Task XpackSecurityEnableUserPostAsync(string username, EnableUserRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new(); + ///GET on /_xpack/security/privilege/{application}/{name} TODO + ///Application name + ///Privilege name + ///A func that allows you to describe the querystring parameters & request specific connection settings. + TResponse XpackSecurityGetPrivileges(string application, string name, GetPrivilegesRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new(); + ///GET on /_xpack/security/privilege/{application}/{name} TODO + ///Application name + ///Privilege name + ///A func that allows you to describe the querystring parameters & request specific connection settings. + Task XpackSecurityGetPrivilegesAsync(string application, string name, GetPrivilegesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new(); ///GET on /_xpack/security/role/{name} https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html ///Role name ///A func that allows you to describe the querystring parameters & request specific connection settings. @@ -3374,6 +3394,44 @@ public partial interface IElasticLowLevelClient ///GET on /_xpack/security/user https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user.html ///A func that allows you to describe the querystring parameters & request specific connection settings. Task XpackSecurityGetUserAsync(GetUserRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new(); + ///GET on /_xpack/security/user/_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html + ///A func that allows you to describe the querystring parameters & request specific connection settings. + TResponse XpackSecurityGetUserPrivileges(GetUserPrivilegesRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new(); + ///GET on /_xpack/security/user/_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html + ///A func that allows you to describe the querystring parameters & request specific connection settings. + Task XpackSecurityGetUserPrivilegesAsync(GetUserPrivilegesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new(); + ///GET on /_xpack/security/user/_has_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html + ///A func that allows you to describe the querystring parameters & request specific connection settings. + TResponse XpackSecurityHasPrivilegesGet(HasPrivilegesRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new(); + ///GET on /_xpack/security/user/_has_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html + ///A func that allows you to describe the querystring parameters & request specific connection settings. + Task XpackSecurityHasPrivilegesGetAsync(HasPrivilegesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new(); + ///GET on /_xpack/security/user/{user}/_has_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html + ///Username + ///A func that allows you to describe the querystring parameters & request specific connection settings. + TResponse XpackSecurityHasPrivilegesGet(string user, HasPrivilegesRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new(); + ///GET on /_xpack/security/user/{user}/_has_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html + ///Username + ///A func that allows you to describe the querystring parameters & request specific connection settings. + Task XpackSecurityHasPrivilegesGetAsync(string user, HasPrivilegesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new(); + ///POST on /_xpack/security/user/_has_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html + ///The privileges to test + ///A func that allows you to describe the querystring parameters & request specific connection settings. + TResponse XpackSecurityHasPrivileges(PostData body, HasPrivilegesRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new(); + ///POST on /_xpack/security/user/_has_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html + ///The privileges to test + ///A func that allows you to describe the querystring parameters & request specific connection settings. + Task XpackSecurityHasPrivilegesAsync(PostData body, HasPrivilegesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new(); + ///POST on /_xpack/security/user/{user}/_has_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html + ///Username + ///The privileges to test + ///A func that allows you to describe the querystring parameters & request specific connection settings. + TResponse XpackSecurityHasPrivileges(string user, PostData body, HasPrivilegesRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new(); + ///POST on /_xpack/security/user/{user}/_has_privileges https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html + ///Username + ///The privileges to test + ///A func that allows you to describe the querystring parameters & request specific connection settings. + Task XpackSecurityHasPrivilegesAsync(string user, PostData body, HasPrivilegesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new(); ///DELETE on /_xpack/security/oauth2/token https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html ///The token to invalidate ///A func that allows you to describe the querystring parameters & request specific connection settings. @@ -3382,6 +3440,22 @@ public partial interface IElasticLowLevelClient ///The token to invalidate ///A func that allows you to describe the querystring parameters & request specific connection settings. Task XpackSecurityInvalidateTokenAsync(PostData body, InvalidateUserAccessTokenRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new(); + ///PUT on /_xpack/security/privilege/ TODO + ///The privilege(s) to add + ///A func that allows you to describe the querystring parameters & request specific connection settings. + TResponse XpackSecurityPutPrivileges(PostData body, PutPrivilegesRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new(); + ///PUT on /_xpack/security/privilege/ TODO + ///The privilege(s) to add + ///A func that allows you to describe the querystring parameters & request specific connection settings. + Task XpackSecurityPutPrivilegesAsync(PostData body, PutPrivilegesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new(); + ///POST on /_xpack/security/privilege/ TODO + ///The privilege(s) to add + ///A func that allows you to describe the querystring parameters & request specific connection settings. + TResponse XpackSecurityPutPrivilegesPost(PostData body, PutPrivilegesRequestParameters requestParameters = null) where TResponse : class, IElasticsearchResponse, new(); + ///POST on /_xpack/security/privilege/ TODO + ///The privilege(s) to add + ///A func that allows you to describe the querystring parameters & request specific connection settings. + Task XpackSecurityPutPrivilegesPostAsync(PostData body, PutPrivilegesRequestParameters requestParameters = null, CancellationToken ctx = default(CancellationToken)) where TResponse : class, IElasticsearchResponse, new(); ///PUT on /_xpack/security/role/{name} https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html ///Role name ///The role to add diff --git a/src/Nest/CommonAbstractions/Request/IProxyRequest.cs b/src/Nest/CommonAbstractions/Request/IProxyRequest.cs new file mode 100644 index 00000000000..ae987314231 --- /dev/null +++ b/src/Nest/CommonAbstractions/Request/IProxyRequest.cs @@ -0,0 +1,12 @@ +using System.IO; +using Elasticsearch.Net; + +namespace Nest +{ + //TODO: since this only deals with source serializer rename this to ISourceProxyRequest + /// A request that that does not necessarily (de)serializes itself + public interface IProxyRequest : IRequest + { + void WriteJson(IElasticsearchSerializer sourceSerializer, Stream s, SerializationFormatting serializationFormatting); + } +} diff --git a/src/Nest/CommonAbstractions/Request/RequestBase.cs b/src/Nest/CommonAbstractions/Request/RequestBase.cs index 34610417896..6817f3d7915 100644 --- a/src/Nest/CommonAbstractions/Request/RequestBase.cs +++ b/src/Nest/CommonAbstractions/Request/RequestBase.cs @@ -1,6 +1,5 @@ using System; using System.ComponentModel; -using System.IO; using Elasticsearch.Net; using Newtonsoft.Json; @@ -23,14 +22,6 @@ public interface IRequest : IRequest TParameters RequestParameters { get; set; } } - /// - /// A request that that does not necessarily (de)serializes itself - /// - public interface IProxyRequest : IRequest - { - void WriteJson(IElasticsearchSerializer sourceSerializer, Stream s, SerializationFormatting serializationFormatting); - } - public abstract class RequestBase : IRequest where TParameters : IRequestParameters, new() { protected RequestBase() => Initialize(); diff --git a/src/Nest/CommonAbstractions/Request/RouteValues.cs b/src/Nest/CommonAbstractions/Request/RouteValues.cs index a8156ce2988..16c14b67479 100644 --- a/src/Nest/CommonAbstractions/Request/RouteValues.cs +++ b/src/Nest/CommonAbstractions/Request/RouteValues.cs @@ -38,6 +38,8 @@ public class RouteValues public string ThreadPoolPatterns => GetResolved("thread_pool_patterns"); public string Timestamp => GetResolved("timestamp"); public string Type => GetResolved("type"); + public string Application => GetResolved("application"); + public string User => GetResolved("user"); public string Username => GetResolved("username"); public WatcherStatsMetric? WatcherStatsMetric => GetResolved("watcher_stats_metric").ToEnum(); public string WatchId => GetResolved("watch_id"); diff --git a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/GenericProxyRequestConverterBase.cs b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/DocumentProxyRequestConverterBase.cs similarity index 92% rename from src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/GenericProxyRequestConverterBase.cs rename to src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/DocumentProxyRequestConverterBase.cs index 9899465bb3e..48c7a97255a 100644 --- a/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/GenericProxyRequestConverterBase.cs +++ b/src/Nest/CommonAbstractions/SerializationBehavior/GenericJsonConverters/DocumentProxyRequestConverterBase.cs @@ -7,11 +7,11 @@ namespace Nest { - internal abstract class GenericProxyRequestConverterBase : JsonConverter + internal abstract class DocumentProxyRequestConverterBase : JsonConverter { private readonly Type _genericRequestType; - protected GenericProxyRequestConverterBase(Type genericRequestType) => + protected DocumentProxyRequestConverterBase(Type genericRequestType) => _genericRequestType = genericRequestType; public override bool CanRead => true; diff --git a/src/Nest/Document/Single/Create/CreateJsonConverter.cs b/src/Nest/Document/Single/Create/CreateJsonConverter.cs index d4fea2abadc..048769b557d 100644 --- a/src/Nest/Document/Single/Create/CreateJsonConverter.cs +++ b/src/Nest/Document/Single/Create/CreateJsonConverter.cs @@ -1,6 +1,6 @@ namespace Nest { - internal class CreateJsonConverter : GenericProxyRequestConverterBase + internal class CreateJsonConverter : DocumentProxyRequestConverterBase { public CreateJsonConverter() : base(typeof(CreateRequest<>)) { } } diff --git a/src/Nest/Document/Single/Index/IndexJsonConverter.cs b/src/Nest/Document/Single/Index/IndexJsonConverter.cs index 2eee74088a2..60d423552b4 100644 --- a/src/Nest/Document/Single/Index/IndexJsonConverter.cs +++ b/src/Nest/Document/Single/Index/IndexJsonConverter.cs @@ -1,6 +1,6 @@ namespace Nest { - internal class IndexJsonConverter : GenericProxyRequestConverterBase + internal class IndexJsonConverter : DocumentProxyRequestConverterBase { public IndexJsonConverter() : base(typeof(IndexRequest<>)) { } } diff --git a/src/Nest/XPack/Security/Privileges/DeletePrivileges/DeletePrivilegesRequest.cs b/src/Nest/XPack/Security/Privileges/DeletePrivileges/DeletePrivilegesRequest.cs new file mode 100644 index 00000000000..9bf7ff50b3a --- /dev/null +++ b/src/Nest/XPack/Security/Privileges/DeletePrivileges/DeletePrivilegesRequest.cs @@ -0,0 +1,9 @@ +namespace Nest +{ + [MapsApi("xpack.security.delete_privileges.json")] + public partial interface IDeletePrivilegesRequest { } + + public partial class DeletePrivilegesRequest { } + + public partial class DeletePrivilegesDescriptor { } +} diff --git a/src/Nest/XPack/Security/Privileges/DeletePrivileges/DeletePrivilegesResponse.cs b/src/Nest/XPack/Security/Privileges/DeletePrivileges/DeletePrivilegesResponse.cs new file mode 100644 index 00000000000..f77d9b91226 --- /dev/null +++ b/src/Nest/XPack/Security/Privileges/DeletePrivileges/DeletePrivilegesResponse.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Nest +{ + public interface IDeletePrivilegesResponse : IResponse + { + IReadOnlyDictionary> Applications { get; } + } + + [JsonObject(MemberSerialization.OptIn)] + [JsonConverter(typeof(DictionaryResponseJsonConverter>))] + public class DeletePrivilegesResponse : DictionaryResponseBase>, IDeletePrivilegesResponse + { + [JsonIgnore] + public IReadOnlyDictionary> Applications => Self.BackingDictionary; + } + + public class FoundUserPrivilege + { + [JsonProperty("found")] + public bool Found { get; internal set; } + } +} diff --git a/src/Nest/XPack/Security/Privileges/DeletePrivileges/ElasticClient-DeletePrivileges.cs b/src/Nest/XPack/Security/Privileges/DeletePrivileges/ElasticClient-DeletePrivileges.cs new file mode 100644 index 00000000000..ed0ff909b82 --- /dev/null +++ b/src/Nest/XPack/Security/Privileges/DeletePrivileges/ElasticClient-DeletePrivileges.cs @@ -0,0 +1,55 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Elasticsearch.Net; + +namespace Nest +{ + public partial interface IElasticClient + { + /// + /// Removes application privileges. + /// + IDeletePrivilegesResponse DeletePrivileges(Name application, Name name, Func selector = null); + + /// + IDeletePrivilegesResponse DeletePrivileges(IDeletePrivilegesRequest request); + + /// + Task DeletePrivilegesAsync(Name application, Name name, Func selector = null, + CancellationToken cancellationToken = default + ); + + /// + Task DeletePrivilegesAsync(IDeletePrivilegesRequest request, CancellationToken cancellationToken = default); + } + + public partial class ElasticClient + { + /// + public IDeletePrivilegesResponse DeletePrivileges(Name application, Name name, Func selector = null) => + DeletePrivileges(selector.InvokeOrDefault(new DeletePrivilegesDescriptor(application, name))); + + /// + public IDeletePrivilegesResponse DeletePrivileges(IDeletePrivilegesRequest request) => + Dispatcher.Dispatch( + request, + (p, d) => LowLevelDispatch.XpackSecurityDeletePrivilegesDispatch(p) + ); + + /// + public Task DeletePrivilegesAsync(Name application, Name name, Func selector = null, + CancellationToken cancellationToken = default + ) => + DeletePrivilegesAsync(selector.InvokeOrDefault(new DeletePrivilegesDescriptor(application, name)), cancellationToken); + + /// + public Task DeletePrivilegesAsync(IDeletePrivilegesRequest request, CancellationToken cancellationToken = default + ) => + Dispatcher.DispatchAsync( + request, + cancellationToken, + (p, d, c) => LowLevelDispatch.XpackSecurityDeletePrivilegesDispatchAsync(p, c) + ); + } +} diff --git a/src/Nest/XPack/Security/Privileges/GetPrivileges/ElasticClient-GetPrivileges.cs b/src/Nest/XPack/Security/Privileges/GetPrivileges/ElasticClient-GetPrivileges.cs new file mode 100644 index 00000000000..7c3c3e02280 --- /dev/null +++ b/src/Nest/XPack/Security/Privileges/GetPrivileges/ElasticClient-GetPrivileges.cs @@ -0,0 +1,54 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Elasticsearch.Net; + +namespace Nest +{ + public partial interface IElasticClient + { + /// + /// Retrieves application privileges. + /// + IGetPrivilegesResponse GetPrivileges(Func selector = null); + + /// + IGetPrivilegesResponse GetPrivileges(IGetPrivilegesRequest request); + + /// + Task GetPrivilegesAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); + + /// + Task GetPrivilegesAsync(IGetPrivilegesRequest request, CancellationToken cancellationToken = default(CancellationToken)); + } + + public partial class ElasticClient + { + /// + public IGetPrivilegesResponse GetPrivileges(Func selector = null) => + GetPrivileges(selector.InvokeOrDefault(new GetPrivilegesDescriptor())); + + /// + public IGetPrivilegesResponse GetPrivileges(IGetPrivilegesRequest request) => + Dispatcher.Dispatch( + request, + (p, d) => LowLevelDispatch.XpackSecurityGetPrivilegesDispatch(p) + ); + + /// + public Task GetPrivilegesAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => + GetPrivilegesAsync(selector.InvokeOrDefault(new GetPrivilegesDescriptor()), cancellationToken); + + /// + public Task GetPrivilegesAsync(IGetPrivilegesRequest request, CancellationToken cancellationToken = default(CancellationToken)) => + Dispatcher.DispatchAsync( + request, + cancellationToken, + (p, d, c) => LowLevelDispatch.XpackSecurityGetPrivilegesDispatchAsync(p, c) + ); + } +} diff --git a/src/Nest/XPack/Security/Privileges/GetPrivileges/GetPrivilegesRequest.cs b/src/Nest/XPack/Security/Privileges/GetPrivileges/GetPrivilegesRequest.cs new file mode 100644 index 00000000000..972f329a2f7 --- /dev/null +++ b/src/Nest/XPack/Security/Privileges/GetPrivileges/GetPrivilegesRequest.cs @@ -0,0 +1,9 @@ +namespace Nest +{ + [MapsApi("xpack.security.get_privileges.json")] + public partial interface IGetPrivilegesRequest { } + + public partial class GetPrivilegesRequest { } + + public partial class GetPrivilegesDescriptor { } +} diff --git a/src/Nest/XPack/Security/Privileges/GetPrivileges/GetPrivilegesResponse.cs b/src/Nest/XPack/Security/Privileges/GetPrivileges/GetPrivilegesResponse.cs new file mode 100644 index 00000000000..0f8455da271 --- /dev/null +++ b/src/Nest/XPack/Security/Privileges/GetPrivileges/GetPrivilegesResponse.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Nest +{ + public interface IGetPrivilegesResponse : IResponse + { + IReadOnlyDictionary> Applications { get; } + } + + [JsonObject(MemberSerialization.OptIn)] + [JsonConverter(typeof(DictionaryResponseJsonConverter>))] + public class GetPrivilegesResponse : DictionaryResponseBase>, IGetPrivilegesResponse + { + [JsonIgnore] + public IReadOnlyDictionary> Applications => Self.BackingDictionary; + } +} diff --git a/src/Nest/XPack/Security/Privileges/GetUserPrivileges/ElasticClient-GetUserPrivileges.cs b/src/Nest/XPack/Security/Privileges/GetUserPrivileges/ElasticClient-GetUserPrivileges.cs new file mode 100644 index 00000000000..cce3bc14566 --- /dev/null +++ b/src/Nest/XPack/Security/Privileges/GetUserPrivileges/ElasticClient-GetUserPrivileges.cs @@ -0,0 +1,52 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Elasticsearch.Net; + +namespace Nest +{ + public partial interface IElasticClient + { + /// + /// Retrieves application privileges for authenticated user. + /// + IGetUserPrivilegesResponse GetUserPrivileges(Func selector = null); + + /// + IGetUserPrivilegesResponse GetUserPrivileges(IGetUserPrivilegesRequest request); + + /// + Task GetUserPrivilegesAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ); + + /// + Task GetUserPrivilegesAsync(IGetUserPrivilegesRequest request, CancellationToken cancellationToken = default(CancellationToken)); + } + + public partial class ElasticClient + { + /// + public IGetUserPrivilegesResponse GetUserPrivileges(Func selector = null) => + GetUserPrivileges(selector.InvokeOrDefault(new GetUserPrivilegesDescriptor())); + /// + public IGetUserPrivilegesResponse GetUserPrivileges(IGetUserPrivilegesRequest request) => + Dispatcher.Dispatch( + request, + (p, d) => LowLevelDispatch.XpackSecurityGetUserPrivilegesDispatch(p) + ); + + /// + public Task GetUserPrivilegesAsync(Func selector = null, + CancellationToken cancellationToken = default(CancellationToken) + ) => GetUserPrivilegesAsync(selector.InvokeOrDefault(new GetUserPrivilegesDescriptor()), cancellationToken); + + /// + public Task GetUserPrivilegesAsync(IGetUserPrivilegesRequest request, CancellationToken cancellationToken = default(CancellationToken)) => + Dispatcher.DispatchAsync( + request, + cancellationToken, + (p, d, c) => LowLevelDispatch.XpackSecurityGetUserPrivilegesDispatchAsync(p, c) + ); + } +} diff --git a/src/Nest/XPack/Security/Privileges/GetUserPrivileges/GetUserPrivilegesRequest.cs b/src/Nest/XPack/Security/Privileges/GetUserPrivileges/GetUserPrivilegesRequest.cs new file mode 100644 index 00000000000..bd2193a5593 --- /dev/null +++ b/src/Nest/XPack/Security/Privileges/GetUserPrivileges/GetUserPrivilegesRequest.cs @@ -0,0 +1,9 @@ +namespace Nest +{ + [MapsApi("xpack.security.get_user_privileges.json")] + public partial interface IGetUserPrivilegesRequest { } + + public partial class GetUserPrivilegesRequest { } + + public partial class GetUserPrivilegesDescriptor { } +} diff --git a/src/Nest/XPack/Security/Privileges/GetUserPrivileges/GetUserPrivilegesResponse.cs b/src/Nest/XPack/Security/Privileges/GetUserPrivileges/GetUserPrivilegesResponse.cs new file mode 100644 index 00000000000..9fd4783fb48 --- /dev/null +++ b/src/Nest/XPack/Security/Privileges/GetUserPrivileges/GetUserPrivilegesResponse.cs @@ -0,0 +1,108 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Nest +{ + public interface IGetUserPrivilegesResponse : IResponse + { + [JsonProperty("cluster")] + IReadOnlyCollection Cluster { get; } + + [JsonProperty("global")] + IReadOnlyCollection Global { get; } + + [JsonProperty("indices")] + IReadOnlyCollection Indices { get; } + + [JsonProperty("applications")] + IReadOnlyCollection Applications { get; } + + [JsonProperty("run_as")] + IReadOnlyCollection RunAs { get; } + } + + public class ManageUserPrivileges + { + [JsonProperty("applications")] + public IReadOnlyCollection Applications { get; internal set; } + } + + public class ApplicationGlobalUserPrivileges + { + [JsonProperty("manage")] + public ManageUserPrivileges Manage { get; internal set; } + } + + public class GlobalPrivileges + { + [JsonProperty("application")] + public ApplicationGlobalUserPrivileges Application { get; internal set; } + } + + public class FieldSecuritySettings + { + [JsonProperty("grant")] + public IReadOnlyCollection Grant { get; internal set; } + + [JsonProperty("except")] + public IReadOnlyCollection Except { get; internal set; } + } + + public class TermUserPrivileges + { + [JsonProperty("apps")] + public bool Apps { get; internal set; } + } + + public class QueryUserPrivileges + { + [JsonProperty("term")] + public TermUserPrivileges Term { get; internal set; } + } + + public class UserIndicesPrivileges + { + [JsonProperty("names")] + public IReadOnlyCollection Names { get; internal set; } + + [JsonProperty("privileges")] + public IReadOnlyCollection Privileges { get; internal set; } + + [JsonProperty("field_security")] + public FieldSecuritySettings FieldSecurity { get; internal set; } + + [JsonProperty("query")] + public QueryUserPrivileges Query { get; internal set; } + } + + public class ApplicationResourcePrivileges + { + [JsonProperty("application")] + public string Application { get; internal set; } + + [JsonProperty("privileges")] + public IReadOnlyCollection Privileges { get; internal set; } + + [JsonProperty("resources")] + public IReadOnlyCollection Resources { get; internal set; } + } + + [JsonObject(MemberSerialization.OptIn)] + public class GetUserPrivilegesResponse : ResponseBase, IGetUserPrivilegesResponse + { + [JsonProperty("cluster")] + public IReadOnlyCollection Cluster { get; internal set; } = EmptyReadOnly.Collection; + + [JsonProperty("global")] + public IReadOnlyCollection Global { get; internal set; } = EmptyReadOnly.Collection; + + [JsonProperty("indices")] + public IReadOnlyCollection Indices { get; internal set; } = EmptyReadOnly.Collection; + + [JsonProperty("applications")] + public IReadOnlyCollection Applications { get; internal set; } = EmptyReadOnly.Collection; + + [JsonProperty("run_as")] + public IReadOnlyCollection RunAs { get; internal set; } = EmptyReadOnly.Collection; + } +} diff --git a/src/Nest/XPack/Security/Privileges/HasPrivileges/ElasticClient-HasPrivileges.cs b/src/Nest/XPack/Security/Privileges/HasPrivileges/ElasticClient-HasPrivileges.cs new file mode 100644 index 00000000000..e61b43eb9ed --- /dev/null +++ b/src/Nest/XPack/Security/Privileges/HasPrivileges/ElasticClient-HasPrivileges.cs @@ -0,0 +1,54 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Elasticsearch.Net; + +namespace Nest +{ + public partial interface IElasticClient + { + /// + /// Determine whether the authenticated user has a specified list of privileges. + /// + IHasPrivilegesResponse HasPrivileges(Func selector = null); + + /// + IHasPrivilegesResponse HasPrivileges(IHasPrivilegesRequest request); + + /// + Task HasPrivilegesAsync(Func selector = null, + CancellationToken cancellationToken = default + ); + + /// + Task HasPrivilegesAsync(IHasPrivilegesRequest request, CancellationToken cancellationToken = default); + } + + public partial class ElasticClient + { + /// + public IHasPrivilegesResponse HasPrivileges(Func selector = null) => + HasPrivileges(selector.InvokeOrDefault(new HasPrivilegesDescriptor())); + + /// + public IHasPrivilegesResponse HasPrivileges(IHasPrivilegesRequest request) => + Dispatcher.Dispatch( + request, + LowLevelDispatch.XpackSecurityHasPrivilegesDispatch + ); + + /// + public Task HasPrivilegesAsync(Func selector = null, + CancellationToken cancellationToken = default + ) => + HasPrivilegesAsync(selector.InvokeOrDefault(new HasPrivilegesDescriptor()), cancellationToken); + + /// + public Task HasPrivilegesAsync(IHasPrivilegesRequest request, CancellationToken cancellationToken = default) => + Dispatcher.DispatchAsync( + request, + cancellationToken, + LowLevelDispatch.XpackSecurityHasPrivilegesDispatchAsync + ); + } +} diff --git a/src/Nest/XPack/Security/Privileges/HasPrivileges/HasPrivilegesRequest.cs b/src/Nest/XPack/Security/Privileges/HasPrivileges/HasPrivilegesRequest.cs new file mode 100644 index 00000000000..5d04b500d08 --- /dev/null +++ b/src/Nest/XPack/Security/Privileges/HasPrivileges/HasPrivilegesRequest.cs @@ -0,0 +1,190 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Nest +{ + [MapsApi("xpack.security.has_privileges.json")] + public partial interface IHasPrivilegesRequest + { + /// + /// A list of the cluster privileges that you want to check. + /// + [JsonProperty("cluster")] + IEnumerable Cluster { get; set; } + + /// + /// A list of indices and a list of the privileges that you want to check for the specified indices. + /// + [JsonProperty("index")] + IEnumerable Index { get; set; } + + /// + /// The name of the application, a list of the privileges that you want to check for the specified resources, + /// (may be either application privilege names, or the names of actions that are granted by those privileges, + /// a list of resource names against which the privileges should be checked. + /// + [JsonProperty("application")] + IEnumerable Application { get; set; } + } + + public partial class HasPrivilegesRequest + { + /// + public IEnumerable Cluster { get; set; } + + /// + public IEnumerable Index { get; set; } + + /// + public IEnumerable Application { get; set; } + } + + [DescriptorFor("XpackSecurityHasPrivileges")] + public partial class HasPrivilegesDescriptor + { + /// + IEnumerable IHasPrivilegesRequest.Cluster { get; set; } + + /// + IEnumerable IHasPrivilegesRequest.Index { get; set; } + + /// + IEnumerable IHasPrivilegesRequest.Application { get; set; } + + /// + public HasPrivilegesDescriptor Cluster(IEnumerable cluster) => Assign(a => a.Cluster = cluster); + + /// + public HasPrivilegesDescriptor Cluster(params string[] cluster) => Assign(a => a.Cluster = cluster); + + /// + public HasPrivilegesDescriptor Indices(Func>> selector) => + Assign(a => a.Application = selector?.Invoke(new ApplicationPrivilegesChecksDescriptor())?.Value); + + /// + public HasPrivilegesDescriptor Applications(Func>> selector + ) => Assign(a => a.Application = selector?.Invoke(new ApplicationPrivilegesChecksDescriptor())?.Value); + } + + public interface IIndexPrivilegesCheck + { + /// + /// A list of indices. + /// + IEnumerable Names { get; set; } + + /// + /// A list of the privileges that you want to check for the specified indices. + /// + IEnumerable Privileges { get; set; } + } + + public class IndexPrivilegesCheck : IIndexPrivilegesCheck + { + /// + public IEnumerable Names { get; set; } + + /// + public IEnumerable Privileges { get; set; } + } + + public class IndexPrivilegesChecksDescriptor : DescriptorPromiseBase> + { + public IndexPrivilegesChecksDescriptor() : base(new List()) { } + + public IndexPrivilegesChecksDescriptor Index(Func selector) => + Assign(a => a.Add(selector.InvokeOrDefault(new IndexPrivilegesCheckDesciptor()))); + + public class IndexPrivilegesCheckDesciptor : DescriptorBase, IIndexPrivilegesCheck + { + /// + IEnumerable IIndexPrivilegesCheck.Names { get; set; } + + /// + IEnumerable IIndexPrivilegesCheck.Privileges { get; set; } + + /// + public IndexPrivilegesCheckDesciptor Privileges(params string[] privileges) => Assign(a => a.Privileges = privileges); + + /// + public IndexPrivilegesCheckDesciptor Privileges(IEnumerable privileges) => Assign(a => a.Privileges = privileges); + + /// + public IndexPrivilegesCheckDesciptor Names(params string[] names) => Assign(a => a.Names = names); + + /// + public IndexPrivilegesCheckDesciptor Names(IEnumerable names) => Assign(a => a.Names = names); + } + } + + public interface IApplicationPrivilegesCheck + { + /// + /// The name of the application. + /// + [JsonProperty("application")] + string Name { get; set; } + + /// + /// A list of the privileges that you want to check for the specified resources. + /// May be either application privilege names, or the names of actions + /// that are granted by those privileges. + /// + IEnumerable Privileges { get; set; } + + /// + /// A list of resource names against which the privileges should be checked. + /// + IEnumerable Resources { get; set; } + } + + public class ApplicationPrivilegesCheck : IApplicationPrivilegesCheck + { + /// + public string Name { get; set; } + + /// + public IEnumerable Privileges { get; set; } + + /// + public IEnumerable Resources { get; set; } + } + + public class ApplicationPrivilegesChecksDescriptor + : DescriptorPromiseBase> + { + public ApplicationPrivilegesChecksDescriptor() : base(new List()) { } + + public ApplicationPrivilegesChecksDescriptor Application(Func selector) => + Assign(a => a.Add(selector.InvokeOrDefault(new ApplicationPrivilegesCheckDescriptor()))); + + public class ApplicationPrivilegesCheckDescriptor + : DescriptorBase, IApplicationPrivilegesCheck + { + /// + string IApplicationPrivilegesCheck.Name { get; set; } + + /// + IEnumerable IApplicationPrivilegesCheck.Privileges { get; set; } + + /// + IEnumerable IApplicationPrivilegesCheck.Resources { get; set; } + + /// + public ApplicationPrivilegesCheckDescriptor Name(string name) => Assign(a => a.Name = name); + + /// + public ApplicationPrivilegesCheckDescriptor Privileges(params string[] privileges) => Assign(a => a.Privileges = privileges); + + /// + public ApplicationPrivilegesCheckDescriptor Privileges(IEnumerable privileges) => Assign(a => a.Privileges = privileges); + + /// + public ApplicationPrivilegesCheckDescriptor Resources(params string[] resources) => Assign(a => a.Resources = resources); + + /// + public ApplicationPrivilegesCheckDescriptor Resources(IEnumerable resources) => Assign(a => a.Resources = resources); + } + } +} diff --git a/src/Nest/XPack/Security/Privileges/HasPrivileges/HasPrivilegesResponse.cs b/src/Nest/XPack/Security/Privileges/HasPrivileges/HasPrivilegesResponse.cs new file mode 100644 index 00000000000..9ca6e872c2c --- /dev/null +++ b/src/Nest/XPack/Security/Privileges/HasPrivileges/HasPrivilegesResponse.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; +using static Nest.IndicesPrivilegesResponseJsonConverter; + +namespace Nest +{ + public interface IHasPrivilegesResponse : IResponse + { + [JsonProperty("application")] + [JsonConverter(typeof(ApplicationsPrivilegesResponseJsonConverter))] + IReadOnlyDictionary> Applications { get; } + + [JsonProperty("cluster")] + IReadOnlyDictionary Clusters { get; } + + [JsonProperty("has_all_requested")] + bool HasAllRequested { get; } + + [JsonProperty("index")] + [JsonConverter(typeof(IndicesPrivilegesResponseJsonConverter))] + IReadOnlyCollection Indices { get; } + + [JsonProperty("username")] + string Username { get; } + } + + public class HasPrivilegesResponse : ResponseBase, IHasPrivilegesResponse + { + public IReadOnlyDictionary> Applications { get; internal set; } = + EmptyReadOnly>.Dictionary; + + public IReadOnlyDictionary Clusters { get; internal set; } = EmptyReadOnly.Dictionary; + public bool HasAllRequested { get; internal set; } + + public IReadOnlyCollection Indices { get; internal set; } = EmptyReadOnly.Collection; + public string Username { get; internal set; } + } + + public class ResourcePrivileges + { + public IReadOnlyDictionary Privileges { get; internal set; } = EmptyReadOnly.Dictionary; + public string Resource { get; internal set; } + } + + internal class IndicesPrivilegesResponseJsonConverter : JsonConverter + { + public override bool CanWrite { get; } = false; + + public override bool CanConvert(Type objectType) => true; + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => throw new NotSupportedException(); + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) => + ReadResourcePrivileges(reader, objectType, existingValue, serializer); + + internal static IReadOnlyCollection ReadResourcePrivileges(JsonReader reader, Type objectType, object existingValue, + JsonSerializer serializer + ) + { + if (reader.TokenType != JsonToken.StartObject) + return null; + + var privileges = new List(); + while (reader.Read() && reader.TokenType != JsonToken.EndObject) + { + var resource = (string)reader.Value; + reader.Read(); + var resourcePrivileges = serializer.Deserialize>(reader); + privileges.Add(new ResourcePrivileges { Resource = resource, Privileges = resourcePrivileges }); + } + + return privileges; + } + } + + internal class ApplicationsPrivilegesResponseJsonConverter : JsonConverter + { + public override bool CanWrite { get; } = false; + + public override bool CanConvert(Type objectType) => true; + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => throw new NotSupportedException(); + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + if (reader.TokenType != JsonToken.StartObject) + return null; + + var apps = new Dictionary>(); + while (reader.Read() && reader.TokenType != JsonToken.EndObject) + { + var app = (string)reader.Value; + reader.Read(); + var privileges = ReadResourcePrivileges(reader, objectType, existingValue, serializer); + apps.Add(app, privileges); + } + + return apps; + } + } +} diff --git a/src/Nest/XPack/Security/Privileges/PutPrivileges/AppPrivileges.cs b/src/Nest/XPack/Security/Privileges/PutPrivileges/AppPrivileges.cs new file mode 100644 index 00000000000..55932cc5562 --- /dev/null +++ b/src/Nest/XPack/Security/Privileges/PutPrivileges/AppPrivileges.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Nest +{ + [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] + public interface IAppPrivileges : IIsADictionary { } + + public class AppPrivileges : IsADictionaryBase, IAppPrivileges + { + public AppPrivileges() {} + internal AppPrivileges(IDictionary backingDictionary) : base(backingDictionary) {} + + public void Add(string name, IPrivileges privileges) => BackingDictionary.Add(name, privileges); + } + + public class AppPrivilegesDescriptor : IsADictionaryDescriptorBase + { + public AppPrivilegesDescriptor() : base(new AppPrivileges()) { } + + public AppPrivilegesDescriptor Application(string applicationName, IPrivileges privileges) => Assign(applicationName, privileges); + + public AppPrivilegesDescriptor Application(string applicationName, Func> selector) => + Assign(applicationName, selector?.Invoke(new PrivilegesDescriptor())?.Value); + } + +} diff --git a/src/Nest/XPack/Security/Privileges/PutPrivileges/ElasticClient-PutPrivileges.cs b/src/Nest/XPack/Security/Privileges/PutPrivileges/ElasticClient-PutPrivileges.cs new file mode 100644 index 00000000000..d97b2b1b23e --- /dev/null +++ b/src/Nest/XPack/Security/Privileges/PutPrivileges/ElasticClient-PutPrivileges.cs @@ -0,0 +1,52 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Elasticsearch.Net; + +namespace Nest +{ + public partial interface IElasticClient + { + /// + /// Adds or updates application privileges. + /// + IPutPrivilegesResponse PutPrivileges(Func selector); + + /// + IPutPrivilegesResponse PutPrivileges(IPutPrivilegesRequest request); + + /// + Task PutPrivilegesAsync(Func selector, CancellationToken cancellationToken = default); + + /// + Task PutPrivilegesAsync(IPutPrivilegesRequest request, CancellationToken cancellationToken = default); + } + + public partial class ElasticClient + { + /// + public IPutPrivilegesResponse PutPrivileges(Func selector) => + PutPrivileges(selector.InvokeOrDefault(new PutPrivilegesDescriptor())); + + /// + public IPutPrivilegesResponse PutPrivileges(IPutPrivilegesRequest request) => + Dispatcher.Dispatch( + request, + LowLevelDispatch.XpackSecurityPutPrivilegesDispatch + ); + + /// + public Task PutPrivilegesAsync(Func selector, + CancellationToken cancellationToken = default + ) => + PutPrivilegesAsync(selector.InvokeOrDefault(new PutPrivilegesDescriptor()), cancellationToken); + + /// + public Task PutPrivilegesAsync(IPutPrivilegesRequest request, CancellationToken cancellationToken = default) => + Dispatcher.DispatchAsync( + request, + cancellationToken, + LowLevelDispatch.XpackSecurityPutPrivilegesDispatchAsync + ); + } +} diff --git a/src/Nest/XPack/Security/Privileges/PutPrivileges/Privileges.cs b/src/Nest/XPack/Security/Privileges/PutPrivileges/Privileges.cs new file mode 100644 index 00000000000..790b2a1813e --- /dev/null +++ b/src/Nest/XPack/Security/Privileges/PutPrivileges/Privileges.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Nest +{ + [JsonConverter(typeof(VerbatimDictionaryKeysJsonConverter))] + public interface IPrivileges : IIsADictionary { } + + public class Privileges : IsADictionaryBase, IPrivileges + { + public Privileges() {} + internal Privileges(IDictionary backingDictionary) : base(backingDictionary) {} + + public void Add(string name, IPrivilegesActions actions) => BackingDictionary.Add(name, actions); + } + + public class PrivilegesDescriptor : IsADictionaryDescriptorBase + { + public PrivilegesDescriptor() : base(new Privileges()) { } + + public PrivilegesDescriptor Privilege(string privilegesName, IPrivilegesActions actions) => Assign(privilegesName, actions); + + public PrivilegesDescriptor Privilege(string privilegesName, Func selector) => + Assign(privilegesName, selector?.Invoke(new PrivilegesActionsDescriptor())); + } +} diff --git a/src/Nest/XPack/Security/Privileges/PutPrivileges/PrivilegesActions.cs b/src/Nest/XPack/Security/Privileges/PutPrivileges/PrivilegesActions.cs new file mode 100644 index 00000000000..a27d4de73b8 --- /dev/null +++ b/src/Nest/XPack/Security/Privileges/PutPrivileges/PrivilegesActions.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; + +namespace Nest +{ + public interface IPrivilegesActions + { + /// + /// A list of action names that are granted by this privilege. This field must exist and cannot be an empty array. + /// Action names can contain any number of printable ASCII characters and must contain + /// at least one of the following characters: / *, : + /// + IEnumerable Actions { get; set; } + + /// + /// Optional meta-data. Within the metadata object, keys that begin with _ are reserved for system usage. + /// + IDictionary Metadata { get; set; } + } + + public class PrivilegesActions : IPrivilegesActions + { + /// + public IEnumerable Actions { get; set; } + + /// + public IDictionary Metadata { get; set; } + } + + public class PrivilegesActionsDescriptor : DescriptorBase, IPrivilegesActions + { + /// + IEnumerable IPrivilegesActions.Actions { get; set; } + + /// + IDictionary IPrivilegesActions.Metadata { get; set; } + + /// + public PrivilegesActionsDescriptor Actions(params string[] actions) => Assign(a => a.Actions = actions); + + /// + public PrivilegesActionsDescriptor Actions(IEnumerable actions) => Assign(a => a.Actions = actions); + + /// + public PrivilegesActionsDescriptor Metadata(IDictionary meta) => Assign(a => a.Metadata = meta); + + /// + public PrivilegesActionsDescriptor Metadata(Func, FluentDictionary> meta) => + Assign(a => a.Metadata = meta?.Invoke(new FluentDictionary())); + } +} diff --git a/src/Nest/XPack/Security/Privileges/PutPrivileges/PutPrivilegesRequest.cs b/src/Nest/XPack/Security/Privileges/PutPrivileges/PutPrivilegesRequest.cs new file mode 100644 index 00000000000..5261095af74 --- /dev/null +++ b/src/Nest/XPack/Security/Privileges/PutPrivileges/PutPrivilegesRequest.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Elasticsearch.Net; +using Newtonsoft.Json; + +namespace Nest +{ + [MapsApi("xpack.security.put_privileges.json")] + [JsonConverter(typeof(PutPrivilegesConverter))] + public partial interface IPutPrivilegesRequest : IProxyRequest + { + IAppPrivileges Applications { get; set; } + } + + public partial class PutPrivilegesRequest + { + void IProxyRequest.WriteJson(IElasticsearchSerializer sourceSerializer, Stream stream, SerializationFormatting formatting) => + sourceSerializer.Serialize(Self.Applications, stream, formatting); + + public IAppPrivileges Applications { get; set; } + } + + public partial class PutPrivilegesDescriptor + { + void IProxyRequest.WriteJson(IElasticsearchSerializer sourceSerializer, Stream stream, SerializationFormatting formatting) => + sourceSerializer.Serialize(Self.Applications, stream, formatting); + + IAppPrivileges IPutPrivilegesRequest.Applications { get; set; } + + public PutPrivilegesDescriptor Applications(Func> selector) => + Assign(a => a.Applications = selector?.Invoke(new AppPrivilegesDescriptor())?.Value); + } + + internal class PutPrivilegesConverter : VerbatimDictionaryKeysJsonConverter + { + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + if (!(value is IPutPrivilegesRequest request)) return; + base.WriteJson(writer, request.Applications, serializer); + } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + var appPrivileges = serializer.Deserialize(reader); + return new PutPrivilegesRequest { Applications = appPrivileges }; + } + } +} diff --git a/src/Nest/XPack/Security/Privileges/PutPrivileges/PutPrivilegesResponse.cs b/src/Nest/XPack/Security/Privileges/PutPrivileges/PutPrivilegesResponse.cs new file mode 100644 index 00000000000..823fa3779bd --- /dev/null +++ b/src/Nest/XPack/Security/Privileges/PutPrivileges/PutPrivilegesResponse.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Nest +{ + public interface IPutPrivilegesResponse : IResponse + { + IReadOnlyDictionary> Applications { get; } + } + + [JsonConverter(typeof(DictionaryResponseJsonConverter>))] + public class PutPrivilegesResponse : DictionaryResponseBase>, IPutPrivilegesResponse + { + [JsonIgnore] + public IReadOnlyDictionary> Applications => Self.BackingDictionary; + } + + public class PutPrivilegesStatus + { + /// + /// Whether the privilege has been created or updated. + /// When an existing privilege is updated, created is set to false. + /// + [JsonProperty("created")] + public bool Created { get; internal set; } + } +} diff --git a/src/Nest/XPack/Security/Role/PutRole/IApplicationPrivileges.cs b/src/Nest/XPack/Security/Role/PutRole/IApplicationPrivileges.cs index d4ab4b1d055..06ddbbee4dd 100644 --- a/src/Nest/XPack/Security/Role/PutRole/IApplicationPrivileges.cs +++ b/src/Nest/XPack/Security/Role/PutRole/IApplicationPrivileges.cs @@ -53,6 +53,9 @@ public ApplicationPrivilegesDescriptor Add(Func a.AddIfNotNull(selector?.Invoke(new ApplicationPrivilegesDescriptor()))); } + + // TODO this should not be generic, fix in NEST 7.x + /// public class ApplicationPrivilegesDescriptor : DescriptorBase, IApplicationPrivileges>, IApplicationPrivileges diff --git a/src/Nest/XPack/Watcher/PutWatch/PutWatchRequest.cs b/src/Nest/XPack/Watcher/PutWatch/PutWatchRequest.cs index 2ef97cb983c..631e2478f01 100644 --- a/src/Nest/XPack/Watcher/PutWatch/PutWatchRequest.cs +++ b/src/Nest/XPack/Watcher/PutWatch/PutWatchRequest.cs @@ -111,7 +111,7 @@ public PutWatchDescriptor Input(Func selector) /// public PutWatchDescriptor Metadata(Func, FluentDictionary> paramsDictionary) => - Assign(a => a.Metadata = paramsDictionary(new FluentDictionary())); + Assign(a => a.Metadata = paramsDictionary?.Invoke(new FluentDictionary())); /// public PutWatchDescriptor Metadata(Dictionary paramsDictionary) => diff --git a/src/Nest/_Generated/_Descriptors.generated.cs b/src/Nest/_Generated/_Descriptors.generated.cs index 6e0f6735751..4eea644f5fc 100644 --- a/src/Nest/_Generated/_Descriptors.generated.cs +++ b/src/Nest/_Generated/_Descriptors.generated.cs @@ -4917,6 +4917,22 @@ public ClearCachedRolesDescriptor(Names name) : base(r=>r.Required("name", name) // Request parameters } + ///descriptor for XpackSecurityDeletePrivileges
TODO
+ public partial class DeletePrivilegesDescriptor : RequestDescriptorBase, IDeletePrivilegesRequest + { + /// /_xpack/security/privilege/{application}/{name} + /// this parameter is required + /// this parameter is required + public DeletePrivilegesDescriptor(Name application, Name name) : base(r=>r.Required("application", application).Required("name", name)){} + // values part of the url path + Name IDeletePrivilegesRequest.Application => Self.RouteValues.Get("application"); + Name IDeletePrivilegesRequest.Name => Self.RouteValues.Get("name"); + + // Request parameters + + ///If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + public DeletePrivilegesDescriptor Refresh(Refresh? refresh) => Qs("refresh", refresh); + } ///descriptor for XpackSecurityDeleteRole
https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-delete-role.html
public partial class DeleteRoleDescriptor : RequestDescriptorBase, IDeleteRoleRequest { @@ -4991,6 +5007,24 @@ public EnableUserDescriptor() : base(){} ///If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. public EnableUserDescriptor Refresh(Refresh? refresh) => Qs("refresh", refresh); } + ///descriptor for XpackSecurityGetPrivileges
TODO
+ public partial class GetPrivilegesDescriptor : RequestDescriptorBase, IGetPrivilegesRequest + { + /// /_xpack/security/privilege/{application}/{name} + public GetPrivilegesDescriptor() : base(){} + // values part of the url path + Name IGetPrivilegesRequest.Application => Self.RouteValues.Get("application"); + Name IGetPrivilegesRequest.Name => Self.RouteValues.Get("name"); + + ///Application name + public GetPrivilegesDescriptor Application(Name application) => Assign(a=>a.RouteValues.Optional("application", application)); + + ///Privilege name + public GetPrivilegesDescriptor Name(Name name) => Assign(a=>a.RouteValues.Optional("name", name)); + + // Request parameters + + } ///descriptor for XpackSecurityGetRole
https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-role.html
public partial class GetRoleDescriptor : RequestDescriptorBase, IGetRoleRequest { @@ -5040,6 +5074,30 @@ public GetUserDescriptor() : base(){} // Request parameters + } + ///descriptor for XpackSecurityGetUserPrivileges
https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-get-user-privileges.html
+ public partial class GetUserPrivilegesDescriptor : RequestDescriptorBase, IGetUserPrivilegesRequest + { + // values part of the url path + + // Request parameters + + } + ///descriptor for XpackSecurityHasPrivileges
https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-has-privileges.html
+ public partial class HasPrivilegesDescriptor : RequestDescriptorBase, IHasPrivilegesRequest + { + /// /_xpack/security/user/_has_privileges + public HasPrivilegesDescriptor() : base(){} + // values part of the url path + Name IHasPrivilegesRequest.User => Self.RouteValues.Get("user"); + + ///Username + public HasPrivilegesDescriptor User(Name user) => Assign(a=>a.RouteValues.Optional("user", user)); + + // Request parameters + + //TODO THIS METHOD IS UNMAPPED! + } ///descriptor for XpackSecurityInvalidateToken
https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-invalidate-token.html
public partial class InvalidateUserAccessTokenDescriptor : RequestDescriptorBase, IInvalidateUserAccessTokenRequest @@ -5049,6 +5107,16 @@ public partial class InvalidateUserAccessTokenDescriptor : RequestDescriptorBas // Request parameters } + ///descriptor for XpackSecurityPutPrivileges
TODO
+ public partial class PutPrivilegesDescriptor : RequestDescriptorBase, IPutPrivilegesRequest + { + // values part of the url path + + // Request parameters + + ///If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes. + public PutPrivilegesDescriptor Refresh(Refresh? refresh) => Qs("refresh", refresh); + } ///descriptor for XpackSecurityPutRole
https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-role.html
public partial class PutRoleDescriptor : RequestDescriptorBase, IPutRoleRequest { diff --git a/src/Nest/_Generated/_LowLevelDispatch.generated.cs b/src/Nest/_Generated/_LowLevelDispatch.generated.cs index 7312d008d8d..488ddb7d4af 100644 --- a/src/Nest/_Generated/_LowLevelDispatch.generated.cs +++ b/src/Nest/_Generated/_LowLevelDispatch.generated.cs @@ -4620,6 +4620,28 @@ internal partial class LowLevelDispatch throw InvalidDispatch("XpackSecurityClearCachedRoles", p, new [] { POST }, "/_xpack/security/role/{name}/_clear_cache"); } + internal TResponse XpackSecurityDeletePrivilegesDispatch(IRequest p) where TResponse : class, IElasticsearchResponse, new() + { + switch(p.HttpMethod) + { + case DELETE: + if (AllSetNoFallback(p.RouteValues.Application, p.RouteValues.Name)) return _lowLevel.XpackSecurityDeletePrivileges(p.RouteValues.Application,p.RouteValues.Name,p.RequestParameters); + break; + } + throw InvalidDispatch("XpackSecurityDeletePrivileges", p, new [] { DELETE }, "/_xpack/security/privilege/{application}/{name}"); + } + + internal Task XpackSecurityDeletePrivilegesDispatchAsync(IRequest p, CancellationToken ct) where TResponse : class, IElasticsearchResponse, new() + { + switch(p.HttpMethod) + { + case DELETE: + if (AllSetNoFallback(p.RouteValues.Application, p.RouteValues.Name)) return _lowLevel.XpackSecurityDeletePrivilegesAsync(p.RouteValues.Application,p.RouteValues.Name,p.RequestParameters,ct); + break; + } + throw InvalidDispatch("XpackSecurityDeletePrivileges", p, new [] { DELETE }, "/_xpack/security/privilege/{application}/{name}"); + } + internal TResponse XpackSecurityDeleteRoleDispatch(IRequest p) where TResponse : class, IElasticsearchResponse, new() { switch(p.HttpMethod) @@ -4742,6 +4764,28 @@ internal partial class LowLevelDispatch throw InvalidDispatch("XpackSecurityEnableUser", p, new [] { PUT, POST }, "/_xpack/security/user/{username}/_enable"); } + internal TResponse XpackSecurityGetPrivilegesDispatch(IRequest p) where TResponse : class, IElasticsearchResponse, new() + { + switch(p.HttpMethod) + { + case GET: + if (AllSet(p.RouteValues.Application, p.RouteValues.Name)) return _lowLevel.XpackSecurityGetPrivileges(p.RouteValues.Application,p.RouteValues.Name,p.RequestParameters); + break; + } + throw InvalidDispatch("XpackSecurityGetPrivileges", p, new [] { GET }, "/_xpack/security/privilege/{application}/{name}"); + } + + internal Task XpackSecurityGetPrivilegesDispatchAsync(IRequest p, CancellationToken ct) where TResponse : class, IElasticsearchResponse, new() + { + switch(p.HttpMethod) + { + case GET: + if (AllSet(p.RouteValues.Application, p.RouteValues.Name)) return _lowLevel.XpackSecurityGetPrivilegesAsync(p.RouteValues.Application,p.RouteValues.Name,p.RequestParameters,ct); + break; + } + throw InvalidDispatch("XpackSecurityGetPrivileges", p, new [] { GET }, "/_xpack/security/privilege/{application}/{name}"); + } + internal TResponse XpackSecurityGetRoleDispatch(IRequest p) where TResponse : class, IElasticsearchResponse, new() { switch(p.HttpMethod) @@ -4828,6 +4872,54 @@ internal partial class LowLevelDispatch throw InvalidDispatch("XpackSecurityGetUser", p, new [] { GET }, "/_xpack/security/user/{username}", "/_xpack/security/user"); } + internal TResponse XpackSecurityGetUserPrivilegesDispatch(IRequest p) where TResponse : class, IElasticsearchResponse, new() + { + switch(p.HttpMethod) + { + case GET: + return _lowLevel.XpackSecurityGetUserPrivileges(p.RequestParameters); + } + throw InvalidDispatch("XpackSecurityGetUserPrivileges", p, new [] { GET }, "/_xpack/security/user/_privileges"); + } + + internal Task XpackSecurityGetUserPrivilegesDispatchAsync(IRequest p, CancellationToken ct) where TResponse : class, IElasticsearchResponse, new() + { + switch(p.HttpMethod) + { + case GET: + return _lowLevel.XpackSecurityGetUserPrivilegesAsync(p.RequestParameters,ct); + } + throw InvalidDispatch("XpackSecurityGetUserPrivileges", p, new [] { GET }, "/_xpack/security/user/_privileges"); + } + + internal TResponse XpackSecurityHasPrivilegesDispatch(IRequest p,SerializableData body) where TResponse : class, IElasticsearchResponse, new() + { + switch(p.HttpMethod) + { + case GET: + if (AllSet(p.RouteValues.User)) return _lowLevel.XpackSecurityHasPrivilegesGet(p.RouteValues.User,p.RequestParameters); + return _lowLevel.XpackSecurityHasPrivilegesGet(p.RequestParameters); + case POST: + if (AllSet(p.RouteValues.User)) return _lowLevel.XpackSecurityHasPrivileges(p.RouteValues.User,body,p.RequestParameters); + return _lowLevel.XpackSecurityHasPrivileges(body,p.RequestParameters); + } + throw InvalidDispatch("XpackSecurityHasPrivileges", p, new [] { GET, POST }, "/_xpack/security/user/_has_privileges", "/_xpack/security/user/{user}/_has_privileges"); + } + + internal Task XpackSecurityHasPrivilegesDispatchAsync(IRequest p,SerializableData body, CancellationToken ct) where TResponse : class, IElasticsearchResponse, new() + { + switch(p.HttpMethod) + { + case GET: + if (AllSet(p.RouteValues.User)) return _lowLevel.XpackSecurityHasPrivilegesGetAsync(p.RouteValues.User,p.RequestParameters,ct); + return _lowLevel.XpackSecurityHasPrivilegesGetAsync(p.RequestParameters,ct); + case POST: + if (AllSet(p.RouteValues.User)) return _lowLevel.XpackSecurityHasPrivilegesAsync(p.RouteValues.User,body,p.RequestParameters,ct); + return _lowLevel.XpackSecurityHasPrivilegesAsync(body,p.RequestParameters,ct); + } + throw InvalidDispatch("XpackSecurityHasPrivileges", p, new [] { GET, POST }, "/_xpack/security/user/_has_privileges", "/_xpack/security/user/{user}/_has_privileges"); + } + internal TResponse XpackSecurityInvalidateTokenDispatch(IRequest p,SerializableData body) where TResponse : class, IElasticsearchResponse, new() { switch(p.HttpMethod) @@ -4848,6 +4940,30 @@ internal partial class LowLevelDispatch throw InvalidDispatch("XpackSecurityInvalidateToken", p, new [] { DELETE }, "/_xpack/security/oauth2/token"); } + internal TResponse XpackSecurityPutPrivilegesDispatch(IRequest p,SerializableData body) where TResponse : class, IElasticsearchResponse, new() + { + switch(p.HttpMethod) + { + case PUT: + return _lowLevel.XpackSecurityPutPrivileges(body,p.RequestParameters); + case POST: + return _lowLevel.XpackSecurityPutPrivilegesPost(body,p.RequestParameters); + } + throw InvalidDispatch("XpackSecurityPutPrivileges", p, new [] { PUT, POST }, "/_xpack/security/privilege/"); + } + + internal Task XpackSecurityPutPrivilegesDispatchAsync(IRequest p,SerializableData body, CancellationToken ct) where TResponse : class, IElasticsearchResponse, new() + { + switch(p.HttpMethod) + { + case PUT: + return _lowLevel.XpackSecurityPutPrivilegesAsync(body,p.RequestParameters,ct); + case POST: + return _lowLevel.XpackSecurityPutPrivilegesPostAsync(body,p.RequestParameters,ct); + } + throw InvalidDispatch("XpackSecurityPutPrivileges", p, new [] { PUT, POST }, "/_xpack/security/privilege/"); + } + internal TResponse XpackSecurityPutRoleDispatch(IRequest p,SerializableData body) where TResponse : class, IElasticsearchResponse, new() { switch(p.HttpMethod) diff --git a/src/Nest/_Generated/_Requests.generated.cs b/src/Nest/_Generated/_Requests.generated.cs index 2215e2eeb0c..70a11978797 100644 --- a/src/Nest/_Generated/_Requests.generated.cs +++ b/src/Nest/_Generated/_Requests.generated.cs @@ -2015,6 +2015,31 @@ public DeletePipelineRequest(Id id) : base(r=>r.Required("id", id)){} public Time Timeout { get => Q