Skip to content

Commit

Permalink
Add support for Security APIs (#8315) (#8317)
Browse files Browse the repository at this point in the history
Co-authored-by: Florian Bernd <[email protected]>
  • Loading branch information
github-actions[bot] and flobernd authored Aug 27, 2024
1 parent 73b423d commit 88dc423
Show file tree
Hide file tree
Showing 336 changed files with 45,513 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,53 @@ internal static class ApiUrlLookup
internal static ApiUrls QueryRulesListRulesets = new ApiUrls(new[] { "_query_rules" });
internal static ApiUrls QueryRulesPutRule = new ApiUrls(new[] { "_query_rules/{ruleset_id}/_rule/{rule_id}" });
internal static ApiUrls QueryRulesPutRuleset = new ApiUrls(new[] { "_query_rules/{ruleset_id}" });
internal static ApiUrls SecurityActivateUserProfile = new ApiUrls(new[] { "_security/profile/_activate" });
internal static ApiUrls SecurityAuthenticate = new ApiUrls(new[] { "_security/_authenticate" });
internal static ApiUrls SecurityBulkDeleteRole = new ApiUrls(new[] { "_security/role" });
internal static ApiUrls SecurityBulkPutRole = new ApiUrls(new[] { "_security/role" });
internal static ApiUrls SecurityClearApiKeyCache = new ApiUrls(new[] { "_security/api_key/{ids}/_clear_cache" });
internal static ApiUrls SecurityClearCachedPrivileges = new ApiUrls(new[] { "_security/privilege/{application}/_clear_cache" });
internal static ApiUrls SecurityClearCachedRealms = new ApiUrls(new[] { "_security/realm/{realms}/_clear_cache" });
internal static ApiUrls SecurityClearCachedRoles = new ApiUrls(new[] { "_security/role/{name}/_clear_cache" });
internal static ApiUrls SecurityClearCachedServiceTokens = new ApiUrls(new[] { "_security/service/{namespace}/{service}/credential/token/{name}/_clear_cache" });
internal static ApiUrls SecurityCreateApiKey = new ApiUrls(new[] { "_security/api_key" });
internal static ApiUrls SecurityCreateServiceToken = new ApiUrls(new[] { "_security/service/{namespace}/{service}/credential/token/{name}", "_security/service/{namespace}/{service}/credential/token" });
internal static ApiUrls SecurityDeletePrivileges = new ApiUrls(new[] { "_security/privilege/{application}/{name}" });
internal static ApiUrls SecurityDeleteRole = new ApiUrls(new[] { "_security/role/{name}" });
internal static ApiUrls SecurityDeleteRoleMapping = new ApiUrls(new[] { "_security/role_mapping/{name}" });
internal static ApiUrls SecurityDeleteServiceToken = new ApiUrls(new[] { "_security/service/{namespace}/{service}/credential/token/{name}" });
internal static ApiUrls SecurityDisableUserProfile = new ApiUrls(new[] { "_security/profile/{uid}/_disable" });
internal static ApiUrls SecurityEnableUserProfile = new ApiUrls(new[] { "_security/profile/{uid}/_enable" });
internal static ApiUrls SecurityGetApiKey = new ApiUrls(new[] { "_security/api_key" });
internal static ApiUrls SecurityGetBuiltinPrivileges = new ApiUrls(new[] { "_security/privilege/_builtin" });
internal static ApiUrls SecurityGetPrivileges = new ApiUrls(new[] { "_security/privilege", "_security/privilege/{application}", "_security/privilege/{application}/{name}" });
internal static ApiUrls SecurityGetRole = new ApiUrls(new[] { "_security/role/{name}", "_security/role" });
internal static ApiUrls SecurityGetRoleMapping = new ApiUrls(new[] { "_security/role_mapping/{name}", "_security/role_mapping" });
internal static ApiUrls SecurityGetServiceAccounts = new ApiUrls(new[] { "_security/service/{namespace}/{service}", "_security/service/{namespace}", "_security/service" });
internal static ApiUrls SecurityGetServiceCredentials = new ApiUrls(new[] { "_security/service/{namespace}/{service}/credential" });
internal static ApiUrls SecurityGetToken = new ApiUrls(new[] { "_security/oauth2/token" });
internal static ApiUrls SecurityGetUserPrivileges = new ApiUrls(new[] { "_security/user/_privileges" });
internal static ApiUrls SecurityGetUserProfile = new ApiUrls(new[] { "_security/profile/{uid}" });
internal static ApiUrls SecurityGrantApiKey = new ApiUrls(new[] { "_security/api_key/grant" });
internal static ApiUrls SecurityHasPrivileges = new ApiUrls(new[] { "_security/user/_has_privileges", "_security/user/{user}/_has_privileges" });
internal static ApiUrls SecurityHasPrivilegesUserProfile = new ApiUrls(new[] { "_security/profile/_has_privileges" });
internal static ApiUrls SecurityInvalidateApiKey = new ApiUrls(new[] { "_security/api_key" });
internal static ApiUrls SecurityInvalidateToken = new ApiUrls(new[] { "_security/oauth2/token" });
internal static ApiUrls SecurityPutPrivileges = new ApiUrls(new[] { "_security/privilege" });
internal static ApiUrls SecurityPutRole = new ApiUrls(new[] { "_security/role/{name}" });
internal static ApiUrls SecurityPutRoleMapping = new ApiUrls(new[] { "_security/role_mapping/{name}" });
internal static ApiUrls SecurityQueryApiKeys = new ApiUrls(new[] { "_security/_query/api_key" });
internal static ApiUrls SecurityQueryRole = new ApiUrls(new[] { "_security/_query/role" });
internal static ApiUrls SecurityQueryUser = new ApiUrls(new[] { "_security/_query/user" });
internal static ApiUrls SecuritySamlAuthenticate = new ApiUrls(new[] { "_security/saml/authenticate" });
internal static ApiUrls SecuritySamlCompleteLogout = new ApiUrls(new[] { "_security/saml/complete_logout" });
internal static ApiUrls SecuritySamlInvalidate = new ApiUrls(new[] { "_security/saml/invalidate" });
internal static ApiUrls SecuritySamlLogout = new ApiUrls(new[] { "_security/saml/logout" });
internal static ApiUrls SecuritySamlPrepareAuthentication = new ApiUrls(new[] { "_security/saml/prepare" });
internal static ApiUrls SecuritySamlServiceProviderMetadata = new ApiUrls(new[] { "_security/saml/metadata/{realm_name}" });
internal static ApiUrls SecuritySuggestUserProfiles = new ApiUrls(new[] { "_security/profile/_suggest" });
internal static ApiUrls SecurityUpdateApiKey = new ApiUrls(new[] { "_security/api_key/{id}" });
internal static ApiUrls SecurityUpdateUserProfileData = new ApiUrls(new[] { "_security/profile/{uid}/_data" });
internal static ApiUrls SnapshotCleanupRepository = new ApiUrls(new[] { "_snapshot/{repository}/_cleanup" });
internal static ApiUrls SnapshotClone = new ApiUrls(new[] { "_snapshot/{repository}/{snapshot}/_clone/{target_snapshot}" });
internal static ApiUrls SnapshotCreate = new ApiUrls(new[] { "_snapshot/{repository}/{snapshot}" });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Requests;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.Security;

public sealed partial class ActivateUserProfileRequestParameters : RequestParameters
{
}

/// <summary>
/// <para>
/// Creates or updates a user profile on behalf of another user.
/// </para>
/// </summary>
public sealed partial class ActivateUserProfileRequest : PlainRequest<ActivateUserProfileRequestParameters>
{
internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityActivateUserProfile;

protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

internal override bool SupportsBody => true;

internal override string OperationName => "security.activate_user_profile";

[JsonInclude, JsonPropertyName("access_token")]
public string? AccessToken { get; set; }
[JsonInclude, JsonPropertyName("grant_type")]
public Elastic.Clients.Elasticsearch.Serverless.Security.GrantType GrantType { get; set; }
[JsonInclude, JsonPropertyName("password")]
public string? Password { get; set; }
[JsonInclude, JsonPropertyName("username")]
public string? Username { get; set; }
}

/// <summary>
/// <para>
/// Creates or updates a user profile on behalf of another user.
/// </para>
/// </summary>
public sealed partial class ActivateUserProfileRequestDescriptor : RequestDescriptor<ActivateUserProfileRequestDescriptor, ActivateUserProfileRequestParameters>
{
internal ActivateUserProfileRequestDescriptor(Action<ActivateUserProfileRequestDescriptor> configure) => configure.Invoke(this);

public ActivateUserProfileRequestDescriptor()
{
}

internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityActivateUserProfile;

protected override HttpMethod StaticHttpMethod => HttpMethod.POST;

internal override bool SupportsBody => true;

internal override string OperationName => "security.activate_user_profile";

private string? AccessTokenValue { get; set; }
private Elastic.Clients.Elasticsearch.Serverless.Security.GrantType GrantTypeValue { get; set; }
private string? PasswordValue { get; set; }
private string? UsernameValue { get; set; }

public ActivateUserProfileRequestDescriptor AccessToken(string? accessToken)
{
AccessTokenValue = accessToken;
return Self;
}

public ActivateUserProfileRequestDescriptor GrantType(Elastic.Clients.Elasticsearch.Serverless.Security.GrantType grantType)
{
GrantTypeValue = grantType;
return Self;
}

public ActivateUserProfileRequestDescriptor Password(string? password)
{
PasswordValue = password;
return Self;
}

public ActivateUserProfileRequestDescriptor Username(string? username)
{
UsernameValue = username;
return Self;
}

protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
{
writer.WriteStartObject();
if (!string.IsNullOrEmpty(AccessTokenValue))
{
writer.WritePropertyName("access_token");
writer.WriteStringValue(AccessTokenValue);
}

writer.WritePropertyName("grant_type");
JsonSerializer.Serialize(writer, GrantTypeValue, options);
if (!string.IsNullOrEmpty(PasswordValue))
{
writer.WritePropertyName("password");
writer.WriteStringValue(PasswordValue);
}

if (!string.IsNullOrEmpty(UsernameValue))
{
writer.WritePropertyName("username");
writer.WriteStringValue(UsernameValue);
}

writer.WriteEndObject();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using Elastic.Transport.Products.Elasticsearch;
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.Security;

public sealed partial class ActivateUserProfileResponse : ElasticsearchResponse
{
[JsonInclude, JsonPropertyName("data")]
public IReadOnlyDictionary<string, object> Data { get; init; }
[JsonInclude, JsonPropertyName("_doc")]
public Elastic.Clients.Elasticsearch.Serverless.Security.UserProfileHitMetadata Doc { get; init; }
[JsonInclude, JsonPropertyName("enabled")]
public bool? Enabled { get; init; }
[JsonInclude, JsonPropertyName("labels")]
public IReadOnlyDictionary<string, object> Labels { get; init; }
[JsonInclude, JsonPropertyName("last_synchronized")]
public long LastSynchronized { get; init; }
[JsonInclude, JsonPropertyName("uid")]
public string Uid { get; init; }
[JsonInclude, JsonPropertyName("user")]
public Elastic.Clients.Elasticsearch.Serverless.Security.UserProfileUser User { get; init; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Requests;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.Security;

public sealed partial class AuthenticateRequestParameters : RequestParameters
{
}

/// <summary>
/// <para>
/// Authenticate a user.
/// Authenticates a user and returns information about the authenticated user.
/// Include the user information in a <a href="https://en.wikipedia.org/wiki/Basic_access_authentication">basic auth header</a>.
/// 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.
/// If the user cannot be authenticated, this API returns a 401 status code.
/// </para>
/// </summary>
public sealed partial class AuthenticateRequest : PlainRequest<AuthenticateRequestParameters>
{
internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityAuthenticate;

protected override HttpMethod StaticHttpMethod => HttpMethod.GET;

internal override bool SupportsBody => false;

internal override string OperationName => "security.authenticate";
}

/// <summary>
/// <para>
/// Authenticate a user.
/// Authenticates a user and returns information about the authenticated user.
/// Include the user information in a <a href="https://en.wikipedia.org/wiki/Basic_access_authentication">basic auth header</a>.
/// 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.
/// If the user cannot be authenticated, this API returns a 401 status code.
/// </para>
/// </summary>
public sealed partial class AuthenticateRequestDescriptor : RequestDescriptor<AuthenticateRequestDescriptor, AuthenticateRequestParameters>
{
internal AuthenticateRequestDescriptor(Action<AuthenticateRequestDescriptor> configure) => configure.Invoke(this);

public AuthenticateRequestDescriptor()
{
}

internal override ApiUrls ApiUrls => ApiUrlLookup.SecurityAuthenticate;

protected override HttpMethod StaticHttpMethod => HttpMethod.GET;

internal override bool SupportsBody => false;

internal override string OperationName => "security.authenticate";

protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using Elastic.Transport.Products.Elasticsearch;
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.Security;

public sealed partial class AuthenticateResponse : ElasticsearchResponse
{
[JsonInclude, JsonPropertyName("api_key")]
public Elastic.Clients.Elasticsearch.Serverless.Security.ApiKey? ApiKey { get; init; }
[JsonInclude, JsonPropertyName("authentication_realm")]
public Elastic.Clients.Elasticsearch.Serverless.Security.RealmInfo AuthenticationRealm { get; init; }
[JsonInclude, JsonPropertyName("authentication_type")]
public string AuthenticationType { get; init; }
[JsonInclude, JsonPropertyName("email")]
public string? Email { get; init; }
[JsonInclude, JsonPropertyName("enabled")]
public bool Enabled { get; init; }
[JsonInclude, JsonPropertyName("full_name")]
public string? FullName { get; init; }
[JsonInclude, JsonPropertyName("lookup_realm")]
public Elastic.Clients.Elasticsearch.Serverless.Security.RealmInfo LookupRealm { get; init; }
[JsonInclude, JsonPropertyName("metadata")]
public IReadOnlyDictionary<string, object> Metadata { get; init; }
[JsonInclude, JsonPropertyName("roles")]
public IReadOnlyCollection<string> Roles { get; init; }
[JsonInclude, JsonPropertyName("token")]
public Elastic.Clients.Elasticsearch.Serverless.Security.AuthenticateToken? Token { get; init; }
[JsonInclude, JsonPropertyName("username")]
public string Username { get; init; }
}
Loading

0 comments on commit 88dc423

Please sign in to comment.