Skip to content

Commit 894ac1d

Browse files
Add missing params to secret endpoints
1 parent eaf1f82 commit 894ac1d

File tree

2 files changed

+56
-14
lines changed

2 files changed

+56
-14
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ secrets = client.secrets.list_secrets(
109109

110110
**Parameters:**
111111
- `project_id` (str): The ID of your project.
112+
- `project_slug` (str): The slug of your project.
112113
- `environment_slug` (str): The environment in which to list secrets (e.g., "dev").
113114
- `secret_path` (str): The path to the secrets.
114115
- `expand_secret_references` (bool): Whether to expand secret references.
@@ -117,6 +118,8 @@ secrets = client.secrets.list_secrets(
117118
- `include_imports` (bool): Whether to include imported secrets.
118119
- `tag_filters` (List[str]): Tags to filter secrets.
119120

121+
**Note:** Exactly one of `project_id` or `project_slug` is required. If both are provided, `project_id` takes precedence.
122+
120123
**Returns:**
121124
- `ListSecretsResponse`: The response containing the list of secrets.
122125

@@ -133,19 +136,26 @@ new_secret = client.secrets.create_secret_by_name(
133136
skip_multiline_encoding=False,
134137
secret_reminder_repeat_days=30, # Optional
135138
secret_reminder_note="Remember to update this secret" # Optional
139+
secret_metadata=[{"key": "metadata_key", "value": "metadata_value"}], # Optional
140+
tags_ids=["tag_id_1", "tag_id_2"] # Optional
136141
)
137142
```
138143

139144
**Parameters:**
140145
- `secret_name` (str): The name of the secret.
141146
- `project_id` (str): The ID of your project.
147+
- `project_slug` (str): The slug of your project.
142148
- `secret_path` (str): The path to the secret.
143149
- `environment_slug` (str): The environment in which to create the secret.
144150
- `secret_value` (str): The value of the secret.
145151
- `secret_comment` (str, optional): A comment associated with the secret.
146152
- `skip_multiline_encoding` (bool, optional): Whether to skip encoding for multiline secrets.
147153
- `secret_reminder_repeat_days` (Union[float, int], optional): Number of days after which to repeat secret reminders.
148154
- `secret_reminder_note` (str, optional): A note for the secret reminder.
155+
- `secret_metadata` (List[Dict[str, Any]], optional): Metadata associated with the secret.
156+
- `tags_ids` (List[str], optional): IDs of tags to associate with the secret.
157+
158+
**Note:** Exactly one of `project_id` or `project_slug` is required. If both are provided, `project_id` takes precedence.
149159

150160
**Returns:**
151161
- `BaseSecret`: The response after creating the secret.
@@ -156,6 +166,7 @@ new_secret = client.secrets.create_secret_by_name(
156166
updated_secret = client.secrets.update_secret_by_name(
157167
current_secret_name="EXISTING_SECRET",
158168
project_id="<project-id>",
169+
project_slug="<project-slug>",
159170
secret_path="/",
160171
environment_slug="dev",
161172
secret_value="new_secret_value",
@@ -164,12 +175,15 @@ updated_secret = client.secrets.update_secret_by_name(
164175
secret_reminder_repeat_days=30, # Optional
165176
secret_reminder_note="Updated reminder note", # Optional
166177
new_secret_name="NEW_NAME" # Optional
178+
secret_metadata=[{"key": "metadata_key", "value": "metadata_value"}], # Optional
179+
tags_ids=["tag_id_1", "tag_id_2"] # Optional
167180
)
168181
```
169182

170183
**Parameters:**
171184
- `current_secret_name` (str): The current name of the secret.
172185
- `project_id` (str): The ID of your project.
186+
- `project_slug` (str): The slug of your project.
173187
- `secret_path` (str): The path to the secret.
174188
- `environment_slug` (str): The environment in which to update the secret.
175189
- `secret_value` (str, optional): The new value of the secret.
@@ -178,6 +192,10 @@ updated_secret = client.secrets.update_secret_by_name(
178192
- `secret_reminder_repeat_days` (Union[float, int], optional): Updated number of days after which to repeat secret reminders.
179193
- `secret_reminder_note` (str, optional): An updated note for the secret reminder.
180194
- `new_secret_name` (str, optional): A new name for the secret.
195+
- `secret_metadata` (List[Dict[str, Any]], optional): Metadata associated with the secret.
196+
- `tags_ids` (List[str], optional): IDs of tags to associate with the secret.
197+
198+
**Note:** Exactly one of `project_id` or `project_slug` is required. If both are provided, `project_id` takes precedence.
181199

182200
**Returns:**
183201
- `BaseSecret`: The response after updating the secret.
@@ -200,13 +218,16 @@ secret = client.secrets.get_secret_by_name(
200218
**Parameters:**
201219
- `secret_name` (str): The name of the secret.
202220
- `project_id` (str): The ID of your project.
221+
- `project_slug` (str): The slug of your project.
203222
- `environment_slug` (str): The environment in which to retrieve the secret.
204223
- `secret_path` (str): The path to the secret.
205224
- `expand_secret_references` (bool): Whether to expand secret references.
206225
- `view_secret_value` (bool): Whether or not to include the secret value in the response. If set to false, the `secretValue` will be masked with `<hidden-by-infisical>`. Defaults to true.
207226
- `include_imports` (bool): Whether to include imported secrets.
208227
- `version` (str, optional): The version of the secret to retrieve. Fetches the latest by default.
209228

229+
**Note:** Exactly one of `project_id` or `project_slug` is required. If both are provided, `project_id` takes precedence.
230+
210231
**Returns:**
211232
- `BaseSecret`: The response containing the secret.
212233

@@ -224,9 +245,12 @@ deleted_secret = client.secrets.delete_secret_by_name(
224245
**Parameters:**
225246
- `secret_name` (str): The name of the secret to delete.
226247
- `project_id` (str): The ID of your project.
248+
- `project_slug` (str): The slug of your project.
227249
- `environment_slug` (str): The environment in which to delete the secret.
228250
- `secret_path` (str): The path to the secret.
229251

252+
**Note:** Exactly one of `project_id` or `project_slug` is required. If both are provided, `project_id` takes precedence.
253+
230254
**Returns:**
231255
- `BaseSecret`: The response after deleting the secret.
232256

infisical_sdk/resources/secrets.py

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List, Union
1+
from typing import List, Union, Optional, Dict, Any
22

33
from infisical_sdk.infisical_requests import InfisicalRequests
44
from infisical_sdk.api_types import ListSecretsResponse, SingleSecretResponse, BaseSecret
@@ -14,14 +14,15 @@ def __init__(self, requests: InfisicalRequests, cache: SecretsCache) -> None:
1414

1515
def list_secrets(
1616
self,
17-
project_id: str,
1817
environment_slug: str,
1918
secret_path: str,
19+
project_id: str = None,
2020
expand_secret_references: bool = True,
2121
view_secret_value: bool = True,
2222
recursive: bool = False,
2323
include_imports: bool = True,
24-
tag_filters: List[str] = []) -> ListSecretsResponse:
24+
tag_filters: List[str] = [],
25+
project_slug: str = None) -> ListSecretsResponse:
2526

2627
params = {
2728
"workspaceId": project_id,
@@ -31,6 +32,7 @@ def list_secrets(
3132
"expandSecretReferences": str(expand_secret_references).lower(),
3233
"recursive": str(recursive).lower(),
3334
"include_imports": str(include_imports).lower(),
35+
"workspaceSlug": project_slug
3436
}
3537

3638
if tag_filters:
@@ -58,16 +60,18 @@ def list_secrets(
5860
def get_secret_by_name(
5961
self,
6062
secret_name: str,
61-
project_id: str,
6263
environment_slug: str,
6364
secret_path: str,
65+
project_id: str = None,
66+
project_slug: str = None,
6467
expand_secret_references: bool = True,
6568
include_imports: bool = True,
6669
view_secret_value: bool = True,
6770
version: str = None) -> BaseSecret:
6871

6972
params = {
7073
"workspaceId": project_id,
74+
"workspaceSlug": project_slug,
7175
"viewSecretValue": str(view_secret_value).lower(),
7276
"environment": environment_slug,
7377
"secretPath": secret_path,
@@ -105,26 +109,32 @@ def get_secret_by_name(
105109
def create_secret_by_name(
106110
self,
107111
secret_name: str,
108-
project_id: str,
109112
secret_path: str,
110113
environment_slug: str,
114+
project_id: str = None,
111115
secret_value: str = None,
112116
secret_comment: str = None,
113117
skip_multiline_encoding: bool = False,
114118
secret_reminder_repeat_days: Union[float, int] = None,
115-
secret_reminder_note: str = None) -> BaseSecret:
119+
secret_reminder_note: str = None,
120+
project_slug: str = None,
121+
secret_metadata: Optional[List[Dict[str, Any]]] = None,
122+
tags_ids: Optional[List[str]] = None,
123+
) -> BaseSecret:
116124

117125
requestBody = {
118126
"workspaceId": project_id,
127+
"projectSlug": project_slug,
119128
"environment": environment_slug,
120129
"secretPath": secret_path,
121130
"secretValue": secret_value,
122131
"secretComment": secret_comment,
123-
"tagIds": None,
132+
"tagIds": tags_ids,
124133
"skipMultilineEncoding": skip_multiline_encoding,
125134
"type": "shared",
126135
"secretReminderRepeatDays": secret_reminder_repeat_days,
127-
"secretReminderNote": secret_reminder_note
136+
"secretReminderNote": secret_reminder_note,
137+
"secretMetadata": secret_metadata,
128138
}
129139
result = self.requests.post(
130140
path=f"/api/v3/secrets/raw/{secret_name}",
@@ -152,28 +162,34 @@ def create_secret_by_name(
152162
def update_secret_by_name(
153163
self,
154164
current_secret_name: str,
155-
project_id: str,
156165
secret_path: str,
157166
environment_slug: str,
167+
project_id: str = None,
158168
secret_value: str = None,
159169
secret_comment: str = None,
160170
skip_multiline_encoding: bool = False,
161171
secret_reminder_repeat_days: Union[float, int] = None,
162172
secret_reminder_note: str = None,
163-
new_secret_name: str = None) -> BaseSecret:
173+
new_secret_name: str = None,
174+
project_slug: str = None,
175+
secret_metadata: Optional[List[Dict[str, Any]]] = None,
176+
tags_ids: Optional[List[str]] = None,
177+
) -> BaseSecret:
164178

165179
requestBody = {
166180
"workspaceId": project_id,
181+
"projectSlug": project_slug,
167182
"environment": environment_slug,
168183
"secretPath": secret_path,
169184
"secretValue": secret_value,
170185
"secretComment": secret_comment,
171186
"newSecretName": new_secret_name,
172-
"tagIds": None,
187+
"tagIds": tags_ids,
173188
"skipMultilineEncoding": skip_multiline_encoding,
174189
"type": "shared",
175190
"secretReminderRepeatDays": secret_reminder_repeat_days,
176-
"secretReminderNote": secret_reminder_note
191+
"secretReminderNote": secret_reminder_note,
192+
"secretMetadata": secret_metadata,
177193
}
178194

179195
result = self.requests.patch(
@@ -201,12 +217,14 @@ def update_secret_by_name(
201217
def delete_secret_by_name(
202218
self,
203219
secret_name: str,
204-
project_id: str,
205220
secret_path: str,
206-
environment_slug: str) -> BaseSecret:
221+
environment_slug: str,
222+
project_id: str = None,
223+
project_slug: str = None) -> BaseSecret:
207224

208225
requestBody = {
209226
"workspaceId": project_id,
227+
"projectSlug": project_slug,
210228
"environment": environment_slug,
211229
"secretPath": secret_path,
212230
"type": "shared",

0 commit comments

Comments
 (0)