Skip to content

Commit 40810bb

Browse files
floberndgithub-actions[bot]
authored andcommitted
Add support for Security APIs (#8315)
1 parent 887c8f8 commit 40810bb

File tree

336 files changed

+45513
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

336 files changed

+45513
-1
lines changed

src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/ApiUrlLookup.g.cs

+47
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,53 @@ internal static class ApiUrlLookup
216216
internal static ApiUrls QueryRulesListRulesets = new ApiUrls(new[] { "_query_rules" });
217217
internal static ApiUrls QueryRulesPutRule = new ApiUrls(new[] { "_query_rules/{ruleset_id}/_rule/{rule_id}" });
218218
internal static ApiUrls QueryRulesPutRuleset = new ApiUrls(new[] { "_query_rules/{ruleset_id}" });
219+
internal static ApiUrls SecurityActivateUserProfile = new ApiUrls(new[] { "_security/profile/_activate" });
220+
internal static ApiUrls SecurityAuthenticate = new ApiUrls(new[] { "_security/_authenticate" });
221+
internal static ApiUrls SecurityBulkDeleteRole = new ApiUrls(new[] { "_security/role" });
222+
internal static ApiUrls SecurityBulkPutRole = new ApiUrls(new[] { "_security/role" });
223+
internal static ApiUrls SecurityClearApiKeyCache = new ApiUrls(new[] { "_security/api_key/{ids}/_clear_cache" });
224+
internal static ApiUrls SecurityClearCachedPrivileges = new ApiUrls(new[] { "_security/privilege/{application}/_clear_cache" });
225+
internal static ApiUrls SecurityClearCachedRealms = new ApiUrls(new[] { "_security/realm/{realms}/_clear_cache" });
226+
internal static ApiUrls SecurityClearCachedRoles = new ApiUrls(new[] { "_security/role/{name}/_clear_cache" });
227+
internal static ApiUrls SecurityClearCachedServiceTokens = new ApiUrls(new[] { "_security/service/{namespace}/{service}/credential/token/{name}/_clear_cache" });
228+
internal static ApiUrls SecurityCreateApiKey = new ApiUrls(new[] { "_security/api_key" });
229+
internal static ApiUrls SecurityCreateServiceToken = new ApiUrls(new[] { "_security/service/{namespace}/{service}/credential/token/{name}", "_security/service/{namespace}/{service}/credential/token" });
230+
internal static ApiUrls SecurityDeletePrivileges = new ApiUrls(new[] { "_security/privilege/{application}/{name}" });
231+
internal static ApiUrls SecurityDeleteRole = new ApiUrls(new[] { "_security/role/{name}" });
232+
internal static ApiUrls SecurityDeleteRoleMapping = new ApiUrls(new[] { "_security/role_mapping/{name}" });
233+
internal static ApiUrls SecurityDeleteServiceToken = new ApiUrls(new[] { "_security/service/{namespace}/{service}/credential/token/{name}" });
234+
internal static ApiUrls SecurityDisableUserProfile = new ApiUrls(new[] { "_security/profile/{uid}/_disable" });
235+
internal static ApiUrls SecurityEnableUserProfile = new ApiUrls(new[] { "_security/profile/{uid}/_enable" });
236+
internal static ApiUrls SecurityGetApiKey = new ApiUrls(new[] { "_security/api_key" });
237+
internal static ApiUrls SecurityGetBuiltinPrivileges = new ApiUrls(new[] { "_security/privilege/_builtin" });
238+
internal static ApiUrls SecurityGetPrivileges = new ApiUrls(new[] { "_security/privilege", "_security/privilege/{application}", "_security/privilege/{application}/{name}" });
239+
internal static ApiUrls SecurityGetRole = new ApiUrls(new[] { "_security/role/{name}", "_security/role" });
240+
internal static ApiUrls SecurityGetRoleMapping = new ApiUrls(new[] { "_security/role_mapping/{name}", "_security/role_mapping" });
241+
internal static ApiUrls SecurityGetServiceAccounts = new ApiUrls(new[] { "_security/service/{namespace}/{service}", "_security/service/{namespace}", "_security/service" });
242+
internal static ApiUrls SecurityGetServiceCredentials = new ApiUrls(new[] { "_security/service/{namespace}/{service}/credential" });
243+
internal static ApiUrls SecurityGetToken = new ApiUrls(new[] { "_security/oauth2/token" });
244+
internal static ApiUrls SecurityGetUserPrivileges = new ApiUrls(new[] { "_security/user/_privileges" });
245+
internal static ApiUrls SecurityGetUserProfile = new ApiUrls(new[] { "_security/profile/{uid}" });
246+
internal static ApiUrls SecurityGrantApiKey = new ApiUrls(new[] { "_security/api_key/grant" });
247+
internal static ApiUrls SecurityHasPrivileges = new ApiUrls(new[] { "_security/user/_has_privileges", "_security/user/{user}/_has_privileges" });
248+
internal static ApiUrls SecurityHasPrivilegesUserProfile = new ApiUrls(new[] { "_security/profile/_has_privileges" });
249+
internal static ApiUrls SecurityInvalidateApiKey = new ApiUrls(new[] { "_security/api_key" });
250+
internal static ApiUrls SecurityInvalidateToken = new ApiUrls(new[] { "_security/oauth2/token" });
251+
internal static ApiUrls SecurityPutPrivileges = new ApiUrls(new[] { "_security/privilege" });
252+
internal static ApiUrls SecurityPutRole = new ApiUrls(new[] { "_security/role/{name}" });
253+
internal static ApiUrls SecurityPutRoleMapping = new ApiUrls(new[] { "_security/role_mapping/{name}" });
254+
internal static ApiUrls SecurityQueryApiKeys = new ApiUrls(new[] { "_security/_query/api_key" });
255+
internal static ApiUrls SecurityQueryRole = new ApiUrls(new[] { "_security/_query/role" });
256+
internal static ApiUrls SecurityQueryUser = new ApiUrls(new[] { "_security/_query/user" });
257+
internal static ApiUrls SecuritySamlAuthenticate = new ApiUrls(new[] { "_security/saml/authenticate" });
258+
internal static ApiUrls SecuritySamlCompleteLogout = new ApiUrls(new[] { "_security/saml/complete_logout" });
259+
internal static ApiUrls SecuritySamlInvalidate = new ApiUrls(new[] { "_security/saml/invalidate" });
260+
internal static ApiUrls SecuritySamlLogout = new ApiUrls(new[] { "_security/saml/logout" });
261+
internal static ApiUrls SecuritySamlPrepareAuthentication = new ApiUrls(new[] { "_security/saml/prepare" });
262+
internal static ApiUrls SecuritySamlServiceProviderMetadata = new ApiUrls(new[] { "_security/saml/metadata/{realm_name}" });
263+
internal static ApiUrls SecuritySuggestUserProfiles = new ApiUrls(new[] { "_security/profile/_suggest" });
264+
internal static ApiUrls SecurityUpdateApiKey = new ApiUrls(new[] { "_security/api_key/{id}" });
265+
internal static ApiUrls SecurityUpdateUserProfileData = new ApiUrls(new[] { "_security/profile/{uid}/_data" });
219266
internal static ApiUrls SnapshotCleanupRepository = new ApiUrls(new[] { "_snapshot/{repository}/_cleanup" });
220267
internal static ApiUrls SnapshotClone = new ApiUrls(new[] { "_snapshot/{repository}/{snapshot}/_clone/{target_snapshot}" });
221268
internal static ApiUrls SnapshotCreate = new ApiUrls(new[] { "_snapshot/{repository}/{snapshot}" });
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information.
4+
//
5+
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
6+
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
7+
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
8+
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
9+
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
10+
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
11+
// ------------------------------------------------
12+
//
13+
// This file is automatically generated.
14+
// Please do not edit these files manually.
15+
//
16+
// ------------------------------------------------
17+
18+
#nullable restore
19+
20+
using Elastic.Clients.Elasticsearch.Serverless.Fluent;
21+
using Elastic.Clients.Elasticsearch.Serverless.Requests;
22+
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
23+
using Elastic.Transport;
24+
using System;
25+
using System.Collections.Generic;
26+
using System.Linq.Expressions;
27+
using System.Text.Json;
28+
using System.Text.Json.Serialization;
29+
30+
namespace Elastic.Clients.Elasticsearch.Serverless.Security;
31+
32+
public sealed partial class ActivateUserProfileRequestParameters : RequestParameters
33+
{
34+
}
35+
36+
/// <summary>
37+
/// <para>
38+
/// Creates or updates a user profile on behalf of another user.
39+
/// </para>
40+
/// </summary>
41+
public sealed partial class ActivateUserProfileRequest : PlainRequest<ActivateUserProfileRequestParameters>
42+
{
43+
internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityActivateUserProfile;
44+
45+
protected override HttpMethod StaticHttpMethod => HttpMethod.POST;
46+
47+
internal override bool SupportsBody => true;
48+
49+
internal override string OperationName => "security.activate_user_profile";
50+
51+
[JsonInclude, JsonPropertyName("access_token")]
52+
public string? AccessToken { get; set; }
53+
[JsonInclude, JsonPropertyName("grant_type")]
54+
public Elastic.Clients.Elasticsearch.Serverless.Security.GrantType GrantType { get; set; }
55+
[JsonInclude, JsonPropertyName("password")]
56+
public string? Password { get; set; }
57+
[JsonInclude, JsonPropertyName("username")]
58+
public string? Username { get; set; }
59+
}
60+
61+
/// <summary>
62+
/// <para>
63+
/// Creates or updates a user profile on behalf of another user.
64+
/// </para>
65+
/// </summary>
66+
public sealed partial class ActivateUserProfileRequestDescriptor : RequestDescriptor<ActivateUserProfileRequestDescriptor, ActivateUserProfileRequestParameters>
67+
{
68+
internal ActivateUserProfileRequestDescriptor(Action<ActivateUserProfileRequestDescriptor> configure) => configure.Invoke(this);
69+
70+
public ActivateUserProfileRequestDescriptor()
71+
{
72+
}
73+
74+
internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityActivateUserProfile;
75+
76+
protected override HttpMethod StaticHttpMethod => HttpMethod.POST;
77+
78+
internal override bool SupportsBody => true;
79+
80+
internal override string OperationName => "security.activate_user_profile";
81+
82+
private string? AccessTokenValue { get; set; }
83+
private Elastic.Clients.Elasticsearch.Serverless.Security.GrantType GrantTypeValue { get; set; }
84+
private string? PasswordValue { get; set; }
85+
private string? UsernameValue { get; set; }
86+
87+
public ActivateUserProfileRequestDescriptor AccessToken(string? accessToken)
88+
{
89+
AccessTokenValue = accessToken;
90+
return Self;
91+
}
92+
93+
public ActivateUserProfileRequestDescriptor GrantType(Elastic.Clients.Elasticsearch.Serverless.Security.GrantType grantType)
94+
{
95+
GrantTypeValue = grantType;
96+
return Self;
97+
}
98+
99+
public ActivateUserProfileRequestDescriptor Password(string? password)
100+
{
101+
PasswordValue = password;
102+
return Self;
103+
}
104+
105+
public ActivateUserProfileRequestDescriptor Username(string? username)
106+
{
107+
UsernameValue = username;
108+
return Self;
109+
}
110+
111+
protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
112+
{
113+
writer.WriteStartObject();
114+
if (!string.IsNullOrEmpty(AccessTokenValue))
115+
{
116+
writer.WritePropertyName("access_token");
117+
writer.WriteStringValue(AccessTokenValue);
118+
}
119+
120+
writer.WritePropertyName("grant_type");
121+
JsonSerializer.Serialize(writer, GrantTypeValue, options);
122+
if (!string.IsNullOrEmpty(PasswordValue))
123+
{
124+
writer.WritePropertyName("password");
125+
writer.WriteStringValue(PasswordValue);
126+
}
127+
128+
if (!string.IsNullOrEmpty(UsernameValue))
129+
{
130+
writer.WritePropertyName("username");
131+
writer.WriteStringValue(UsernameValue);
132+
}
133+
134+
writer.WriteEndObject();
135+
}
136+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information.
4+
//
5+
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
6+
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
7+
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
8+
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
9+
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
10+
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
11+
// ------------------------------------------------
12+
//
13+
// This file is automatically generated.
14+
// Please do not edit these files manually.
15+
//
16+
// ------------------------------------------------
17+
18+
#nullable restore
19+
20+
using Elastic.Clients.Elasticsearch.Serverless.Fluent;
21+
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
22+
using Elastic.Transport.Products.Elasticsearch;
23+
using System;
24+
using System.Collections.Generic;
25+
using System.Text.Json.Serialization;
26+
27+
namespace Elastic.Clients.Elasticsearch.Serverless.Security;
28+
29+
public sealed partial class ActivateUserProfileResponse : ElasticsearchResponse
30+
{
31+
[JsonInclude, JsonPropertyName("data")]
32+
public IReadOnlyDictionary<string, object> Data { get; init; }
33+
[JsonInclude, JsonPropertyName("_doc")]
34+
public Elastic.Clients.Elasticsearch.Serverless.Security.UserProfileHitMetadata Doc { get; init; }
35+
[JsonInclude, JsonPropertyName("enabled")]
36+
public bool? Enabled { get; init; }
37+
[JsonInclude, JsonPropertyName("labels")]
38+
public IReadOnlyDictionary<string, object> Labels { get; init; }
39+
[JsonInclude, JsonPropertyName("last_synchronized")]
40+
public long LastSynchronized { get; init; }
41+
[JsonInclude, JsonPropertyName("uid")]
42+
public string Uid { get; init; }
43+
[JsonInclude, JsonPropertyName("user")]
44+
public Elastic.Clients.Elasticsearch.Serverless.Security.UserProfileUser User { get; init; }
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information.
4+
//
5+
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
6+
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
7+
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
8+
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
9+
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
10+
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
11+
// ------------------------------------------------
12+
//
13+
// This file is automatically generated.
14+
// Please do not edit these files manually.
15+
//
16+
// ------------------------------------------------
17+
18+
#nullable restore
19+
20+
using Elastic.Clients.Elasticsearch.Serverless.Fluent;
21+
using Elastic.Clients.Elasticsearch.Serverless.Requests;
22+
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
23+
using Elastic.Transport;
24+
using System;
25+
using System.Collections.Generic;
26+
using System.Linq.Expressions;
27+
using System.Text.Json;
28+
using System.Text.Json.Serialization;
29+
30+
namespace Elastic.Clients.Elasticsearch.Serverless.Security;
31+
32+
public sealed partial class AuthenticateRequestParameters : RequestParameters
33+
{
34+
}
35+
36+
/// <summary>
37+
/// <para>
38+
/// Authenticate a user.
39+
/// Authenticates a user and returns information about the authenticated user.
40+
/// Include the user information in a <a href="https://en.wikipedia.org/wiki/Basic_access_authentication">basic auth header</a>.
41+
/// A successful call returns a JSON structure that shows user information such as their username, the roles that are assigned to the user, any assigned metadata, and information about the realms that authenticated and authorized the user.
42+
/// If the user cannot be authenticated, this API returns a 401 status code.
43+
/// </para>
44+
/// </summary>
45+
public sealed partial class AuthenticateRequest : PlainRequest<AuthenticateRequestParameters>
46+
{
47+
internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityAuthenticate;
48+
49+
protected override HttpMethod StaticHttpMethod => HttpMethod.GET;
50+
51+
internal override bool SupportsBody => false;
52+
53+
internal override string OperationName => "security.authenticate";
54+
}
55+
56+
/// <summary>
57+
/// <para>
58+
/// Authenticate a user.
59+
/// Authenticates a user and returns information about the authenticated user.
60+
/// Include the user information in a <a href="https://en.wikipedia.org/wiki/Basic_access_authentication">basic auth header</a>.
61+
/// A successful call returns a JSON structure that shows user information such as their username, the roles that are assigned to the user, any assigned metadata, and information about the realms that authenticated and authorized the user.
62+
/// If the user cannot be authenticated, this API returns a 401 status code.
63+
/// </para>
64+
/// </summary>
65+
public sealed partial class AuthenticateRequestDescriptor : RequestDescriptor<AuthenticateRequestDescriptor, AuthenticateRequestParameters>
66+
{
67+
internal AuthenticateRequestDescriptor(Action<AuthenticateRequestDescriptor> configure) => configure.Invoke(this);
68+
69+
public AuthenticateRequestDescriptor()
70+
{
71+
}
72+
73+
internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityAuthenticate;
74+
75+
protected override HttpMethod StaticHttpMethod => HttpMethod.GET;
76+
77+
internal override bool SupportsBody => false;
78+
79+
internal override string OperationName => "security.authenticate";
80+
81+
protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
82+
{
83+
}
84+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Licensed to Elasticsearch B.V under one or more agreements.
2+
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3+
// See the LICENSE file in the project root for more information.
4+
//
5+
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
6+
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
7+
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
8+
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
9+
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
10+
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
11+
// ------------------------------------------------
12+
//
13+
// This file is automatically generated.
14+
// Please do not edit these files manually.
15+
//
16+
// ------------------------------------------------
17+
18+
#nullable restore
19+
20+
using Elastic.Clients.Elasticsearch.Serverless.Fluent;
21+
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
22+
using Elastic.Transport.Products.Elasticsearch;
23+
using System;
24+
using System.Collections.Generic;
25+
using System.Text.Json.Serialization;
26+
27+
namespace Elastic.Clients.Elasticsearch.Serverless.Security;
28+
29+
public sealed partial class AuthenticateResponse : ElasticsearchResponse
30+
{
31+
[JsonInclude, JsonPropertyName("api_key")]
32+
public Elastic.Clients.Elasticsearch.Serverless.Security.ApiKey? ApiKey { get; init; }
33+
[JsonInclude, JsonPropertyName("authentication_realm")]
34+
public Elastic.Clients.Elasticsearch.Serverless.Security.RealmInfo AuthenticationRealm { get; init; }
35+
[JsonInclude, JsonPropertyName("authentication_type")]
36+
public string AuthenticationType { get; init; }
37+
[JsonInclude, JsonPropertyName("email")]
38+
public string? Email { get; init; }
39+
[JsonInclude, JsonPropertyName("enabled")]
40+
public bool Enabled { get; init; }
41+
[JsonInclude, JsonPropertyName("full_name")]
42+
public string? FullName { get; init; }
43+
[JsonInclude, JsonPropertyName("lookup_realm")]
44+
public Elastic.Clients.Elasticsearch.Serverless.Security.RealmInfo LookupRealm { get; init; }
45+
[JsonInclude, JsonPropertyName("metadata")]
46+
public IReadOnlyDictionary<string, object> Metadata { get; init; }
47+
[JsonInclude, JsonPropertyName("roles")]
48+
public IReadOnlyCollection<string> Roles { get; init; }
49+
[JsonInclude, JsonPropertyName("token")]
50+
public Elastic.Clients.Elasticsearch.Serverless.Security.AuthenticateToken? Token { get; init; }
51+
[JsonInclude, JsonPropertyName("username")]
52+
public string Username { get; init; }
53+
}

0 commit comments

Comments
 (0)