vaultrs/api/identity/group/requests.rs
1use super::responses::{
2 CreateGroupResponse, ListGroupsByIdResponse, ListGroupsByNameResponse, ReadGroupByIdResponse,
3 ReadGroupByNameResponse,
4};
5use rustify_derive::Endpoint;
6use serde::Serialize;
7use std::{collections::HashMap, fmt::Debug};
8
9/// ## Create an group
10///
11/// This endpoint creates or updates a group.
12///
13/// Note that it's not possible to set the ID or the name to update an existing group, [`identity::group::update_by_id`]
14/// is the function to call for that use case.
15///
16/// * Path: identity/group
17/// * Method: POST
18/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/identity/group#create-a-group>
19///
20/// [`identity::group::update_by_id`]: crate::identity::group::update_by_id
21#[derive(Builder, Debug, Default, Endpoint, Serialize)]
22#[endpoint(
23 path = "identity/group",
24 method = "POST",
25 builder = "true",
26 response = "CreateGroupResponse"
27)]
28#[builder(setter(into, strip_option), default)]
29pub struct CreateGroupRequest {
30 /// Type of the group, internal or external. Defaults to internal.
31 #[serde(rename = "type")]
32 pub group_type: Option<String>,
33 /// Metadata to be associated with the entity.
34 pub metadata: Option<HashMap<String, String>>,
35 /// Policies to be tied to the group.
36 pub policies: Option<Vec<String>>,
37 /// Group IDs to be assigned as group members.
38 pub member_group_ids: Option<Vec<String>>,
39 /// Entity IDs to be assigned as group members.
40 pub member_entity_ids: Option<Vec<String>>,
41}
42
43/// ## Read group by ID
44///
45/// This endpoint queries the group by its identifier.
46///
47/// * Path: identity/group/id/{self.id}
48/// * Method: GET
49/// * Response: [ReadGroupByIdResponse]
50/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/identity/group#read-group-by-id>
51#[derive(Builder, Debug, Endpoint)]
52#[endpoint(
53 path = "identity/group/id/{self.id}",
54 method = "GET",
55 builder = "true",
56 response = "ReadGroupByIdResponse"
57)]
58#[builder(setter(into))]
59pub struct ReadGroupByIdRequest {
60 /// Identifier of the group.
61 #[endpoint(skip)]
62 pub id: String,
63}
64
65/// ## Update group by ID
66///
67/// This endpoint is used to update a existing group.
68///
69/// * Path: identity/group/id/{self.id}
70/// * Method: POST
71/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/identity/group#update-group-by-id>
72#[derive(Builder, Debug, Default, Endpoint, Serialize)]
73#[endpoint(
74 path = "identity/group/id/{self.id}",
75 method = "POST",
76 builder = "true"
77)]
78#[builder(setter(into, strip_option), default)]
79pub struct UpdateGroupByIdRequest {
80 /// Identifier of the group.
81 #[endpoint(skip)]
82 pub id: String,
83 /// Name of the group.
84 pub name: Option<String>,
85 /// Type of the group, internal or external. Defaults to internal.
86 #[serde(rename = "type")]
87 pub group_type: Option<String>,
88 /// Metadata to be associated with the group.
89 pub metadata: Option<HashMap<String, String>>,
90 /// Policies to be tied to the group.
91 pub policies: Option<Vec<String>>,
92 /// Group IDs to be assigned as group members.
93 pub member_group_ids: Option<Vec<String>>,
94 /// Entity IDs to be assigned as group members.
95 pub member_entity_ids: Option<Vec<String>>,
96}
97
98/// ## Delete group by ID
99///
100/// This endpoint deletes a group.
101///
102/// * Path: identity/group/id/{self.id}
103/// * Method: DELETE
104/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/identity/group#delete-group-by-id>
105#[derive(Builder, Debug, Default, Endpoint)]
106#[endpoint(
107 path = "identity/group/id/{self.id}",
108 method = "DELETE",
109 builder = "true"
110)]
111#[builder(setter(into, strip_option), default)]
112pub struct DeleteGroupByIdRequest {
113 /// Identifier of the group.
114 #[endpoint(skip)]
115 pub id: String,
116}
117
118/// ## List groups by ID
119///
120/// This endpoint returns a list of available groups by their identifiers.
121///
122/// * Path: identity/group/id
123/// * Method: LIST
124/// * Response: [ListGroupsByIdResponse]
125/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/identity/group#list-groups-by-id>
126#[derive(Builder, Debug, Endpoint, Default)]
127#[endpoint(
128 path = "identity/group/id",
129 method = "LIST",
130 builder = "true",
131 response = "ListGroupsByIdResponse"
132)]
133#[builder(setter(into, strip_option), default)]
134pub struct ListGroupsByIdRequest {}
135
136/// ## Create an group
137///
138/// This endpoint creates or updates a group.
139///
140/// * Path: identity/group/name/{self.name}
141/// * Method: POST
142/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/identity/group#create-a-group>
143#[derive(Builder, Debug, Default, Endpoint, Serialize)]
144#[endpoint(
145 path = "identity/group/name/{self.name}",
146 method = "POST",
147 builder = "true"
148)]
149#[builder(setter(into, strip_option), default)]
150pub struct CreateGroupByNameRequest {
151 /// Name of the group.
152 pub name: String,
153 /// Type of the group, internal or external. Defaults to internal.
154 #[serde(rename = "type")]
155 pub group_type: Option<String>,
156 /// Metadata to be associated with the entity.
157 pub metadata: Option<HashMap<String, String>>,
158 /// Policies to be tied to the group.
159 pub policies: Option<Vec<String>>,
160 /// Group IDs to be assigned as group members.
161 pub member_group_ids: Option<Vec<String>>,
162 /// Entity IDs to be assigned as group members.
163 pub member_entity_ids: Option<Vec<String>>,
164}
165
166/// ## Read group by name
167///
168/// This endpoint queries the group by its identifier.
169///
170/// * Path: identity/group/name/{self.name}
171/// * Method: GET
172/// * Response: [ReadGroupByNameResponse]
173/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/identity/group#read-group-by-name>
174#[derive(Builder, Debug, Endpoint)]
175#[endpoint(
176 path = "identity/group/name/{self.name}",
177 method = "GET",
178 builder = "true",
179 response = "ReadGroupByNameResponse"
180)]
181#[builder(setter(into))]
182pub struct ReadGroupByNameRequest {
183 /// Name of the group.
184 #[endpoint(skip)]
185 pub name: String,
186}
187
188/// ## Delete group by name
189///
190/// This endpoint deletes a group.
191///
192/// * Path: identity/group/name/{self.name}
193/// * Method: DELETE
194/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/identity/group#delete-group-by-name>
195#[derive(Builder, Debug, Default, Endpoint)]
196#[endpoint(
197 path = "identity/group/name/{self.name}",
198 method = "DELETE",
199 builder = "true"
200)]
201#[builder(setter(into, strip_option), default)]
202pub struct DeleteGroupByNameRequest {
203 /// Identifier of the group.
204 #[endpoint(skip)]
205 pub name: String,
206}
207
208/// ## List groups by name
209///
210/// This endpoint returns a list of available groups by their identifiers.
211///
212/// * Path: identity/group/name
213/// * Method: LIST
214/// * Response: [ListGroupsByNameResponse]
215/// * Reference: <https://developer.hashicorp.com/vault/api-docs/secret/identity/group#list-groups-by-name>
216#[derive(Builder, Debug, Endpoint, Default)]
217#[endpoint(
218 path = "identity/group/name",
219 method = "LIST",
220 builder = "true",
221 response = "ListGroupsByNameResponse"
222)]
223#[builder(setter(into, strip_option), default)]
224pub struct ListGroupsByNameRequest {}