vaultrs/api/identity/entity_alias/requests.rs
1use super::responses::{
2 CreateEntityAliasResponse, ListEntityAliasesByIdResponse, ReadEntityAliasByIdResponse,
3};
4use rustify_derive::Endpoint;
5use serde::Serialize;
6use std::{collections::HashMap, fmt::Debug};
7
8/// ## Create an entity alias
9///
10/// This endpoint creates a new alias for an entity.
11///
12/// * Path: identity/entity-alias
13/// * Method: POST
14/// * Response: [`Option<CreateEntityAliasResponse>`]
15/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/identity/entity-alias#create-an-entity-alias>
16#[derive(Builder, Debug, Default, Endpoint)]
17#[endpoint(
18 path = "identity/entity-alias",
19 response = "CreateEntityAliasResponse",
20 method = "POST",
21 builder = "true"
22)]
23#[builder(setter(into, strip_option), default)]
24pub struct CreateEntityAliasRequest {
25 /// Name of the alias. Name should be the identifier of the client in the authentication source.
26 /// For example, if the alias belongs to userpass backend, the name should be a valid username within userpass auth method.
27 /// If the alias belongs to GitHub, it should be the GitHub username.
28 /// If the alias belongs to an approle auth method, the name should be a valid RoleID.
29 pub name: String,
30 /// Entity ID to which this alias belongs to.
31 pub canonical_id: String,
32 /// Accessor of the mount to which the alias should belong to.
33 pub mount_accessor: String,
34 /// ID of the entity alias. If set, updates the corresponding entity alias.
35 pub id: Option<String>,
36 /// A map of arbitrary string to string valued user-provided metadata meant to describe the alias.
37 pub custom_metadata: Option<HashMap<String, String>>,
38}
39
40/// ## Read entity alias by ID
41///
42/// This endpoint queries the entity alias by its identifier.
43///
44/// * Path: identity/entity-alias/id/{self.id}
45/// * Method: GET
46/// * Response: [ReadEntityAliasByIdResponse]
47/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/identity/entity-alias#read-entity-alias-by-id>
48#[derive(Builder, Debug, Endpoint)]
49#[endpoint(
50 path = "identity/entity-alias/id/{self.id}",
51 method = "GET",
52 builder = "true",
53 response = "ReadEntityAliasByIdResponse"
54)]
55#[builder(setter(into))]
56pub struct ReadEntityAliasByIdRequest {
57 /// Identifier of the entity alias.
58 #[endpoint(skip)]
59 pub id: String,
60}
61
62/// ## Update entity alias by ID
63///
64/// This endpoint is used to update an existing entity alias.
65///
66/// * Path: identity/entity-alias/id/{self.id}
67/// * Method: POST
68/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/identity/entity-alias#update-entity-alias-by-id>
69#[derive(Builder, Debug, Default, Endpoint)]
70#[endpoint(
71 path = "identity/entity-alias/id/{self.id}",
72 method = "POST",
73 builder = "true"
74)]
75#[builder(setter(into, strip_option), default)]
76pub struct UpdateEntityAliasByIdRequest {
77 /// Identifier of the entity alias.
78 #[endpoint(skip)]
79 pub id: String,
80 /// Name of the alias. Name should be the identifier of the client in the authentication source.
81 /// For example, if the alias belongs to userpass backend, the name should be a valid username within userpass backend.
82 /// If alias belongs to GitHub, it should be the GitHub username.
83 pub name: Option<String>,
84 /// Entity ID to which this alias belongs to.
85 pub canonical_id: Option<String>,
86 /// Accessor of the mount to which the alias should belong to.
87 pub mount_accessor: Option<String>,
88 /// A map of arbitrary string to string valued user-provided metadata meant to describe the alias.
89 pub custom_metadata: Option<HashMap<String, String>>,
90}
91
92/// ## Delete entity alias by ID
93///
94/// This endpoint deletes an alias from its corresponding entity.
95///
96/// * Path: identity/entity-alias/id/{self.id}
97/// * Method: DELETE
98/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/identity/entity-alias#delete-entity-alias-by-id>
99#[derive(Builder, Debug, Default, Endpoint)]
100#[endpoint(
101 path = "identity/entity-alias/id/{self.id}",
102 method = "DELETE",
103 builder = "true"
104)]
105#[builder(setter(into, strip_option), default)]
106pub struct DeleteEntityAliasByIdRequest {
107 /// Identifier of the entity alias.
108 #[endpoint(skip)]
109 pub id: String,
110}
111
112/// ## List entity alias by ID
113///
114/// The list by ID endpoint returns the available entity aliases and key data by their identifiers.
115///
116/// * Path: identity/entity-alias/id
117/// * Method: LIST
118/// * Response: [ListEntityAliasesByIdResponse]
119/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/identity/entity-alias#list-entity-alias-by-id>
120#[derive(Builder, Debug, Endpoint, Default)]
121#[endpoint(
122 path = "identity/entity-alias/id",
123 method = "LIST",
124 builder = "true",
125 response = "ListEntityAliasesByIdResponse"
126)]
127#[builder(setter(into, strip_option), default)]
128pub struct ListEntityAliasesByIdRequest {}