diff --git a/crates/bitwarden-json/src/client.rs b/crates/bitwarden-json/src/client.rs index 20f960e91..7e879dc90 100644 --- a/crates/bitwarden-json/src/client.rs +++ b/crates/bitwarden-json/src/client.rs @@ -61,7 +61,10 @@ impl Client { Command::Projects(cmd) => match cmd { ProjectsCommand::Get(req) => self.0.projects().get(&req).await.into_string(), + ProjectsCommand::Create(req) => self.0.projects().create(&req).await.into_string(), ProjectsCommand::List(req) => self.0.projects().list(&req).await.into_string(), + ProjectsCommand::Update(req) => self.0.projects().update(&req).await.into_string(), + ProjectsCommand::Delete(req) => self.0.projects().delete(req).await.into_string(), }, } } diff --git a/crates/bitwarden-napi/src-ts/bitwarden_client/schemas.ts b/crates/bitwarden-napi/src-ts/bitwarden_client/schemas.ts index 828eaf54b..354f0936e 100644 --- a/crates/bitwarden-napi/src-ts/bitwarden_client/schemas.ts +++ b/crates/bitwarden-napi/src-ts/bitwarden_client/schemas.ts @@ -203,13 +203,47 @@ export interface PasswordLoginRequest { * Returns: [ProjectResponse](crate::sdk::response::projects_response::ProjectResponse) * * > Requires Authentication > Requires using an Access Token for login or calling Sync at + * least once Creates a new project in the provided organization using the given data + * + * Returns: [ProjectResponse](crate::sdk::response::projects_response::ProjectResponse) + * + * > Requires Authentication > Requires using an Access Token for login or calling Sync at * least once Lists all projects of the given organization * * Returns: [ProjectsResponse](crate::sdk::response::projects_response::ProjectsResponse) + * + * > Requires Authentication > Requires using an Access Token for login or calling Sync at + * least once Updates an existing project with the provided ID using the given data + * + * Returns: [ProjectResponse](crate::sdk::response::projects_response::ProjectResponse) + * + * > Requires Authentication > Requires using an Access Token for login or calling Sync at + * least once Deletes all the projects whose IDs match the provided ones + * + * Returns: + * [ProjectsDeleteResponse](crate::sdk::response::projects_response::ProjectsDeleteResponse) */ export interface ProjectsCommand { - get?: ProjectGetRequest; - list?: ProjectsListRequest; + get?: ProjectGetRequest; + create?: ProjectCreateRequest; + list?: ProjectsListRequest; + update?: ProjectPutRequest; + delete?: ProjectsDeleteRequest; +} + +export interface ProjectCreateRequest { + name: string; + /** + * Organization where the project will be created + */ + organizationId: string; +} + +export interface ProjectsDeleteRequest { + /** + * IDs of the projects to delete + */ + ids: string[]; } export interface ProjectGetRequest { @@ -226,6 +260,18 @@ export interface ProjectsListRequest { organizationId: string; } +export interface ProjectPutRequest { + /** + * ID of the project to modify + */ + id: string; + name: string; + /** + * Organization ID of the project to modify + */ + organizationId: string; +} + /** * > Requires Authentication > Requires using an Access Token for login or calling Sync at * least once Retrieve a secret by the provided identifier @@ -966,7 +1012,17 @@ const typeMap: any = { ], false), "ProjectsCommand": o([ { json: "get", js: "get", typ: u(undefined, r("ProjectGetRequest")) }, + { json: "create", js: "create", typ: u(undefined, r("ProjectCreateRequest")) }, { json: "list", js: "list", typ: u(undefined, r("ProjectsListRequest")) }, + { json: "update", js: "update", typ: u(undefined, r("ProjectPutRequest")) }, + { json: "delete", js: "delete", typ: u(undefined, r("ProjectsDeleteRequest")) }, + ], false), + "ProjectCreateRequest": o([ + { json: "name", js: "name", typ: "" }, + { json: "organizationId", js: "organizationId", typ: "" }, + ], false), + "ProjectsDeleteRequest": o([ + { json: "ids", js: "ids", typ: a("") }, ], false), "ProjectGetRequest": o([ { json: "id", js: "id", typ: "" }, @@ -974,6 +1030,11 @@ const typeMap: any = { "ProjectsListRequest": o([ { json: "organizationId", js: "organizationId", typ: "" }, ], false), + "ProjectPutRequest": o([ + { json: "id", js: "id", typ: "" }, + { json: "name", js: "name", typ: "" }, + { json: "organizationId", js: "organizationId", typ: "" }, + ], false), "SecretsCommand": o([ { json: "get", js: "get", typ: u(undefined, r("SecretGetRequest")) }, { json: "create", js: "create", typ: u(undefined, r("SecretCreateRequest")) }, diff --git a/crates/bitwarden/src/client/client_projects.rs b/crates/bitwarden/src/client/client_projects.rs index 6beffc826..4be6e7ad9 100644 --- a/crates/bitwarden/src/client/client_projects.rs +++ b/crates/bitwarden/src/client/client_projects.rs @@ -1,9 +1,12 @@ use crate::{ - commands::{get_project, list_projects}, + commands::{create_project, delete_projects, get_project, list_projects, update_project}, error::Result, sdk::{ - request::projects_request::{ProjectGetRequest, ProjectsListRequest}, - response::projects_response::{ProjectResponse, ProjectsResponse}, + request::projects_request::{ + ProjectCreateRequest, ProjectGetRequest, ProjectPutRequest, ProjectsDeleteRequest, + ProjectsListRequest, + }, + response::projects_response::{ProjectResponse, ProjectsDeleteResponse, ProjectsResponse}, }, }; @@ -16,7 +19,19 @@ impl<'a> ClientProjects<'a> { get_project(self.client, input).await } + pub async fn create(&mut self, input: &ProjectCreateRequest) -> Result { + create_project(self.client, input).await + } + pub async fn list(&mut self, input: &ProjectsListRequest) -> Result { list_projects(self.client, input).await } + + pub async fn update(&mut self, input: &ProjectPutRequest) -> Result { + update_project(self.client, input).await + } + + pub async fn delete(&mut self, input: ProjectsDeleteRequest) -> Result { + delete_projects(self.client, input).await + } } diff --git a/crates/bitwarden/src/commands/projects.rs b/crates/bitwarden/src/commands/projects.rs index 5ed6a461e..6f17aec0f 100644 --- a/crates/bitwarden/src/commands/projects.rs +++ b/crates/bitwarden/src/commands/projects.rs @@ -1,9 +1,14 @@ +use bitwarden_api_api::models::{ProjectCreateRequestModel, ProjectUpdateRequestModel}; + use crate::{ client::Client, error::{Error, Result}, sdk::{ - request::projects_request::{ProjectGetRequest, ProjectsListRequest}, - response::projects_response::{ProjectResponse, ProjectsResponse}, + request::projects_request::{ + ProjectCreateRequest, ProjectGetRequest, ProjectPutRequest, ProjectsDeleteRequest, + ProjectsListRequest, + }, + response::projects_response::{ProjectResponse, ProjectsDeleteResponse, ProjectsResponse}, }, }; @@ -23,6 +28,37 @@ pub(crate) async fn get_project( ProjectResponse::process_response(res, enc) } +pub(crate) async fn create_project( + client: &mut Client, + input: &ProjectCreateRequest, +) -> Result { + let enc = client + .get_encryption_settings() + .as_ref() + .ok_or(Error::VaultLocked)?; + + let org_id = Some(input.organization_id); + + let project = Some(ProjectCreateRequestModel { + name: enc.encrypt(input.name.as_bytes(), org_id)?.to_string(), + }); + + let config = client.get_api_configurations().await; + let res = bitwarden_api_api::apis::projects_api::organizations_organization_id_projects_post( + &config.api, + input.organization_id, + project, + ) + .await?; + + let enc = client + .get_encryption_settings() + .as_ref() + .ok_or(Error::VaultLocked)?; + + ProjectResponse::process_response(res, enc) +} + pub(crate) async fn list_projects( client: &mut Client, input: &ProjectsListRequest, @@ -41,3 +77,43 @@ pub(crate) async fn list_projects( ProjectsResponse::process_response(res, enc) } + +pub(crate) async fn update_project( + client: &mut Client, + input: &ProjectPutRequest, +) -> Result { + let enc = client + .get_encryption_settings() + .as_ref() + .ok_or(Error::VaultLocked)?; + + let org_id = Some(input.organization_id); + + let project = Some(ProjectUpdateRequestModel { + name: enc.encrypt(input.name.as_bytes(), org_id)?.to_string(), + }); + + let config = client.get_api_configurations().await; + let res = + bitwarden_api_api::apis::projects_api::projects_id_put(&config.api, input.id, project) + .await?; + + let enc = client + .get_encryption_settings() + .as_ref() + .ok_or(Error::VaultLocked)?; + + ProjectResponse::process_response(res, enc) +} + +pub(crate) async fn delete_projects( + client: &mut Client, + input: ProjectsDeleteRequest, +) -> Result { + let config = client.get_api_configurations().await; + let res = + bitwarden_api_api::apis::projects_api::projects_delete_post(&config.api, Some(input.ids)) + .await?; + + ProjectsDeleteResponse::process_response(res) +} diff --git a/crates/bitwarden/src/sdk/request/command.rs b/crates/bitwarden/src/sdk/request/command.rs index 2c0b4b955..0388dd2af 100644 --- a/crates/bitwarden/src/sdk/request/command.rs +++ b/crates/bitwarden/src/sdk/request/command.rs @@ -5,7 +5,10 @@ use serde::{Deserialize, Serialize}; use crate::sdk::{ auth::request::{AccessTokenLoginRequest, ApiKeyLoginRequest, PasswordLoginRequest}, request::{ - projects_request::{ProjectGetRequest, ProjectsListRequest}, + projects_request::{ + ProjectCreateRequest, ProjectGetRequest, ProjectPutRequest, ProjectsDeleteRequest, + ProjectsListRequest, + }, secret_verification_request::SecretVerificationRequest, secrets_request::{ SecretCreateRequest, SecretGetRequest, SecretIdentifiersRequest, SecretPutRequest, @@ -133,6 +136,14 @@ pub enum ProjectsCommand { /// Get(ProjectGetRequest), + /// > Requires Authentication + /// > Requires using an Access Token for login or calling Sync at least once + /// Creates a new project in the provided organization using the given data + /// + /// Returns: [ProjectResponse](crate::sdk::response::projects_response::ProjectResponse) + /// + Create(ProjectCreateRequest), + /// > Requires Authentication /// > Requires using an Access Token for login or calling Sync at least once /// Lists all projects of the given organization @@ -140,4 +151,20 @@ pub enum ProjectsCommand { /// Returns: [ProjectsResponse](crate::sdk::response::projects_response::ProjectsResponse) /// List(ProjectsListRequest), + + /// > Requires Authentication + /// > Requires using an Access Token for login or calling Sync at least once + /// Updates an existing project with the provided ID using the given data + /// + /// Returns: [ProjectResponse](crate::sdk::response::projects_response::ProjectResponse) + /// + Update(ProjectPutRequest), + + /// > Requires Authentication + /// > Requires using an Access Token for login or calling Sync at least once + /// Deletes all the projects whose IDs match the provided ones + /// + /// Returns: [ProjectsDeleteResponse](crate::sdk::response::projects_response::ProjectsDeleteResponse) + /// + Delete(ProjectsDeleteRequest), } diff --git a/crates/bitwarden/src/sdk/request/projects_request.rs b/crates/bitwarden/src/sdk/request/projects_request.rs index 876087bbe..6f78d064e 100644 --- a/crates/bitwarden/src/sdk/request/projects_request.rs +++ b/crates/bitwarden/src/sdk/request/projects_request.rs @@ -9,9 +9,36 @@ pub struct ProjectGetRequest { pub id: Uuid, } +#[derive(Serialize, Deserialize, Debug, JsonSchema)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct ProjectCreateRequest { + /// Organization where the project will be created + pub organization_id: Uuid, + + pub name: String, +} + +#[derive(Serialize, Deserialize, Debug, JsonSchema)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct ProjectPutRequest { + /// ID of the project to modify + pub id: Uuid, + /// Organization ID of the project to modify + pub organization_id: Uuid, + + pub name: String, +} + #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct ProjectsListRequest { /// Organization to retrieve all the projects from pub organization_id: Uuid, } + +#[derive(Serialize, Deserialize, Debug, JsonSchema)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct ProjectsDeleteRequest { + /// IDs of the projects to delete + pub ids: Vec, +} diff --git a/crates/bitwarden/src/sdk/response/projects_response.rs b/crates/bitwarden/src/sdk/response/projects_response.rs index cbaaafce0..380b904e5 100644 --- a/crates/bitwarden/src/sdk/response/projects_response.rs +++ b/crates/bitwarden/src/sdk/response/projects_response.rs @@ -1,4 +1,7 @@ -use bitwarden_api_api::models::{ProjectResponseModel, ProjectResponseModelListResponseModel}; +use bitwarden_api_api::models::{ + BulkDeleteResponseModel, BulkDeleteResponseModelListResponseModel, ProjectResponseModel, + ProjectResponseModelListResponseModel, +}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; @@ -65,3 +68,42 @@ impl ProjectsResponse { }) } } + +#[derive(Serialize, Deserialize, Debug, JsonSchema)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct ProjectsDeleteResponse { + pub data: Vec, +} + +impl ProjectsDeleteResponse { + pub(crate) fn process_response( + response: BulkDeleteResponseModelListResponseModel, + ) -> Result { + Ok(ProjectsDeleteResponse { + data: response + .data + .unwrap_or_default() + .into_iter() + .map(ProjectDeleteResponse::process_response) + .collect::>()?, + }) + } +} + +#[derive(Serialize, Deserialize, Debug, JsonSchema)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct ProjectDeleteResponse { + pub id: Uuid, + pub error: Option, +} + +impl ProjectDeleteResponse { + pub(crate) fn process_response( + response: BulkDeleteResponseModel, + ) -> Result { + Ok(ProjectDeleteResponse { + id: response.id.ok_or(Error::MissingFields)?, + error: response.error, + }) + } +} diff --git a/languages/csharp/schemas.cs b/languages/csharp/schemas.cs index fdec22410..d4c29b3d7 100644 --- a/languages/csharp/schemas.cs +++ b/languages/csharp/schemas.cs @@ -227,17 +227,63 @@ public partial class PasswordLoginRequest /// Returns: [ProjectResponse](crate::sdk::response::projects_response::ProjectResponse) /// /// > Requires Authentication > Requires using an Access Token for login or calling Sync at + /// least once Creates a new project in the provided organization using the given data + /// + /// Returns: [ProjectResponse](crate::sdk::response::projects_response::ProjectResponse) + /// + /// > Requires Authentication > Requires using an Access Token for login or calling Sync at /// least once Lists all projects of the given organization /// /// Returns: [ProjectsResponse](crate::sdk::response::projects_response::ProjectsResponse) + /// + /// > Requires Authentication > Requires using an Access Token for login or calling Sync at + /// least once Updates an existing project with the provided ID using the given data + /// + /// Returns: [ProjectResponse](crate::sdk::response::projects_response::ProjectResponse) + /// + /// > Requires Authentication > Requires using an Access Token for login or calling Sync at + /// least once Deletes all the projects whose IDs match the provided ones + /// + /// Returns: + /// [ProjectsDeleteResponse](crate::sdk::response::projects_response::ProjectsDeleteResponse) /// public partial class ProjectsCommand { [JsonProperty("get", NullValueHandling = NullValueHandling.Ignore)] public ProjectGetRequest Get { get; set; } + [JsonProperty("create", NullValueHandling = NullValueHandling.Ignore)] + public ProjectCreateRequest Create { get; set; } + [JsonProperty("list", NullValueHandling = NullValueHandling.Ignore)] public ProjectsListRequest List { get; set; } + + [JsonProperty("update", NullValueHandling = NullValueHandling.Ignore)] + public ProjectPutRequest Update { get; set; } + + [JsonProperty("delete", NullValueHandling = NullValueHandling.Ignore)] + public ProjectsDeleteRequest Delete { get; set; } + } + + public partial class ProjectCreateRequest + { + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// Organization where the project will be created + /// + [JsonProperty("organizationId")] + public Guid OrganizationId { get; set; } + } + + public partial class ProjectsDeleteRequest + { + /// + /// IDs of the projects to delete + /// + [JsonProperty("ids")] + public Guid[] Ids { get; set; } } public partial class ProjectGetRequest @@ -258,6 +304,24 @@ public partial class ProjectsListRequest public Guid OrganizationId { get; set; } } + public partial class ProjectPutRequest + { + /// + /// ID of the project to modify + /// + [JsonProperty("id")] + public Guid Id { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// Organization ID of the project to modify + /// + [JsonProperty("organizationId")] + public Guid OrganizationId { get; set; } + } + /// /// > Requires Authentication > Requires using an Access Token for login or calling Sync at /// least once Retrieve a secret by the provided identifier diff --git a/languages/js_webassembly/bitwarden_client/schemas.ts b/languages/js_webassembly/bitwarden_client/schemas.ts index 828eaf54b..354f0936e 100644 --- a/languages/js_webassembly/bitwarden_client/schemas.ts +++ b/languages/js_webassembly/bitwarden_client/schemas.ts @@ -203,13 +203,47 @@ export interface PasswordLoginRequest { * Returns: [ProjectResponse](crate::sdk::response::projects_response::ProjectResponse) * * > Requires Authentication > Requires using an Access Token for login or calling Sync at + * least once Creates a new project in the provided organization using the given data + * + * Returns: [ProjectResponse](crate::sdk::response::projects_response::ProjectResponse) + * + * > Requires Authentication > Requires using an Access Token for login or calling Sync at * least once Lists all projects of the given organization * * Returns: [ProjectsResponse](crate::sdk::response::projects_response::ProjectsResponse) + * + * > Requires Authentication > Requires using an Access Token for login or calling Sync at + * least once Updates an existing project with the provided ID using the given data + * + * Returns: [ProjectResponse](crate::sdk::response::projects_response::ProjectResponse) + * + * > Requires Authentication > Requires using an Access Token for login or calling Sync at + * least once Deletes all the projects whose IDs match the provided ones + * + * Returns: + * [ProjectsDeleteResponse](crate::sdk::response::projects_response::ProjectsDeleteResponse) */ export interface ProjectsCommand { - get?: ProjectGetRequest; - list?: ProjectsListRequest; + get?: ProjectGetRequest; + create?: ProjectCreateRequest; + list?: ProjectsListRequest; + update?: ProjectPutRequest; + delete?: ProjectsDeleteRequest; +} + +export interface ProjectCreateRequest { + name: string; + /** + * Organization where the project will be created + */ + organizationId: string; +} + +export interface ProjectsDeleteRequest { + /** + * IDs of the projects to delete + */ + ids: string[]; } export interface ProjectGetRequest { @@ -226,6 +260,18 @@ export interface ProjectsListRequest { organizationId: string; } +export interface ProjectPutRequest { + /** + * ID of the project to modify + */ + id: string; + name: string; + /** + * Organization ID of the project to modify + */ + organizationId: string; +} + /** * > Requires Authentication > Requires using an Access Token for login or calling Sync at * least once Retrieve a secret by the provided identifier @@ -966,7 +1012,17 @@ const typeMap: any = { ], false), "ProjectsCommand": o([ { json: "get", js: "get", typ: u(undefined, r("ProjectGetRequest")) }, + { json: "create", js: "create", typ: u(undefined, r("ProjectCreateRequest")) }, { json: "list", js: "list", typ: u(undefined, r("ProjectsListRequest")) }, + { json: "update", js: "update", typ: u(undefined, r("ProjectPutRequest")) }, + { json: "delete", js: "delete", typ: u(undefined, r("ProjectsDeleteRequest")) }, + ], false), + "ProjectCreateRequest": o([ + { json: "name", js: "name", typ: "" }, + { json: "organizationId", js: "organizationId", typ: "" }, + ], false), + "ProjectsDeleteRequest": o([ + { json: "ids", js: "ids", typ: a("") }, ], false), "ProjectGetRequest": o([ { json: "id", js: "id", typ: "" }, @@ -974,6 +1030,11 @@ const typeMap: any = { "ProjectsListRequest": o([ { json: "organizationId", js: "organizationId", typ: "" }, ], false), + "ProjectPutRequest": o([ + { json: "id", js: "id", typ: "" }, + { json: "name", js: "name", typ: "" }, + { json: "organizationId", js: "organizationId", typ: "" }, + ], false), "SecretsCommand": o([ { json: "get", js: "get", typ: u(undefined, r("SecretGetRequest")) }, { json: "create", js: "create", typ: u(undefined, r("SecretCreateRequest")) }, diff --git a/languages/python/BitwardenClient/schemas.py b/languages/python/BitwardenClient/schemas.py index da1695855..253927c8c 100644 --- a/languages/python/BitwardenClient/schemas.py +++ b/languages/python/BitwardenClient/schemas.py @@ -1,6 +1,6 @@ from enum import Enum from dataclasses import dataclass -from typing import Any, Optional, List, TypeVar, Type, cast, Callable +from typing import Any, Optional, List, TypeVar, Type, Callable, cast from uuid import UUID @@ -32,16 +32,16 @@ def from_union(fs, x): assert False -def to_class(c: Type[T], x: Any) -> dict: - assert isinstance(x, c) - return cast(Any, x).to_dict() - - def from_list(f: Callable[[Any], T], x: Any) -> List[T]: assert isinstance(x, list) return [f(y) for y in x] +def to_class(c: Type[T], x: Any) -> dict: + assert isinstance(x, c) + return cast(Any, x).to_dict() + + def from_bool(x: Any) -> bool: assert isinstance(x, bool) return x @@ -234,6 +234,43 @@ def to_dict(self) -> dict: return result +@dataclass +class ProjectCreateRequest: + name: str + """Organization where the project will be created""" + organization_id: UUID + + @staticmethod + def from_dict(obj: Any) -> 'ProjectCreateRequest': + assert isinstance(obj, dict) + name = from_str(obj.get("name")) + organization_id = UUID(obj.get("organizationId")) + return ProjectCreateRequest(name, organization_id) + + def to_dict(self) -> dict: + result: dict = {} + result["name"] = from_str(self.name) + result["organizationId"] = str(self.organization_id) + return result + + +@dataclass +class ProjectsDeleteRequest: + """IDs of the projects to delete""" + ids: List[UUID] + + @staticmethod + def from_dict(obj: Any) -> 'ProjectsDeleteRequest': + assert isinstance(obj, dict) + ids = from_list(lambda x: UUID(x), obj.get("ids")) + return ProjectsDeleteRequest(ids) + + def to_dict(self) -> dict: + result: dict = {} + result["ids"] = from_list(lambda x: str(x), self.ids) + return result + + @dataclass class ProjectGetRequest: """ID of the project to retrieve""" @@ -268,6 +305,30 @@ def to_dict(self) -> dict: return result +@dataclass +class ProjectPutRequest: + """ID of the project to modify""" + id: UUID + name: str + """Organization ID of the project to modify""" + organization_id: UUID + + @staticmethod + def from_dict(obj: Any) -> 'ProjectPutRequest': + assert isinstance(obj, dict) + id = UUID(obj.get("id")) + name = from_str(obj.get("name")) + organization_id = UUID(obj.get("organizationId")) + return ProjectPutRequest(id, name, organization_id) + + def to_dict(self) -> dict: + result: dict = {} + result["id"] = str(self.id) + result["name"] = from_str(self.name) + result["organizationId"] = str(self.organization_id) + return result + + @dataclass class ProjectsCommand: """> Requires Authentication > Requires using an Access Token for login or calling Sync at @@ -275,27 +336,55 @@ class ProjectsCommand: Returns: [ProjectResponse](crate::sdk::response::projects_response::ProjectResponse) + > Requires Authentication > Requires using an Access Token for login or calling Sync at + least once Creates a new project in the provided organization using the given data + + Returns: [ProjectResponse](crate::sdk::response::projects_response::ProjectResponse) + > Requires Authentication > Requires using an Access Token for login or calling Sync at least once Lists all projects of the given organization Returns: [ProjectsResponse](crate::sdk::response::projects_response::ProjectsResponse) + + > Requires Authentication > Requires using an Access Token for login or calling Sync at + least once Updates an existing project with the provided ID using the given data + + Returns: [ProjectResponse](crate::sdk::response::projects_response::ProjectResponse) + + > Requires Authentication > Requires using an Access Token for login or calling Sync at + least once Deletes all the projects whose IDs match the provided ones + + Returns: + [ProjectsDeleteResponse](crate::sdk::response::projects_response::ProjectsDeleteResponse) """ get: Optional[ProjectGetRequest] = None + create: Optional[ProjectCreateRequest] = None list: Optional[ProjectsListRequest] = None + update: Optional[ProjectPutRequest] = None + delete: Optional[ProjectsDeleteRequest] = None @staticmethod def from_dict(obj: Any) -> 'ProjectsCommand': assert isinstance(obj, dict) get = from_union([ProjectGetRequest.from_dict, from_none], obj.get("get")) + create = from_union([ProjectCreateRequest.from_dict, from_none], obj.get("create")) list = from_union([ProjectsListRequest.from_dict, from_none], obj.get("list")) - return ProjectsCommand(get, list) + update = from_union([ProjectPutRequest.from_dict, from_none], obj.get("update")) + delete = from_union([ProjectsDeleteRequest.from_dict, from_none], obj.get("delete")) + return ProjectsCommand(get, create, list, update, delete) def to_dict(self) -> dict: result: dict = {} if self.get is not None: result["get"] = from_union([lambda x: to_class(ProjectGetRequest, x), from_none], self.get) + if self.create is not None: + result["create"] = from_union([lambda x: to_class(ProjectCreateRequest, x), from_none], self.create) if self.list is not None: result["list"] = from_union([lambda x: to_class(ProjectsListRequest, x), from_none], self.list) + if self.update is not None: + result["update"] = from_union([lambda x: to_class(ProjectPutRequest, x), from_none], self.update) + if self.delete is not None: + result["delete"] = from_union([lambda x: to_class(ProjectsDeleteRequest, x), from_none], self.delete) return result diff --git a/support/schemas/request/Command.json b/support/schemas/request/Command.json index 071692175..125b2008d 100644 --- a/support/schemas/request/Command.json +++ b/support/schemas/request/Command.json @@ -181,6 +181,24 @@ }, "additionalProperties": false }, + "ProjectCreateRequest": { + "type": "object", + "required": [ + "name", + "organizationId" + ], + "properties": { + "name": { + "type": "string" + }, + "organizationId": { + "description": "Organization where the project will be created", + "type": "string", + "format": "uuid" + } + }, + "additionalProperties": false + }, "ProjectGetRequest": { "type": "object", "required": [ @@ -195,6 +213,30 @@ }, "additionalProperties": false }, + "ProjectPutRequest": { + "type": "object", + "required": [ + "id", + "name", + "organizationId" + ], + "properties": { + "id": { + "description": "ID of the project to modify", + "type": "string", + "format": "uuid" + }, + "name": { + "type": "string" + }, + "organizationId": { + "description": "Organization ID of the project to modify", + "type": "string", + "format": "uuid" + } + }, + "additionalProperties": false + }, "ProjectsCommand": { "oneOf": [ { @@ -210,6 +252,19 @@ }, "additionalProperties": false }, + { + "description": "> Requires Authentication > Requires using an Access Token for login or calling Sync at least once Creates a new project in the provided organization using the given data\n\nReturns: [ProjectResponse](crate::sdk::response::projects_response::ProjectResponse)", + "type": "object", + "required": [ + "create" + ], + "properties": { + "create": { + "$ref": "#/definitions/ProjectCreateRequest" + } + }, + "additionalProperties": false + }, { "description": "> Requires Authentication > Requires using an Access Token for login or calling Sync at least once Lists all projects of the given organization\n\nReturns: [ProjectsResponse](crate::sdk::response::projects_response::ProjectsResponse)", "type": "object", @@ -222,9 +277,52 @@ } }, "additionalProperties": false + }, + { + "description": "> Requires Authentication > Requires using an Access Token for login or calling Sync at least once Updates an existing project with the provided ID using the given data\n\nReturns: [ProjectResponse](crate::sdk::response::projects_response::ProjectResponse)", + "type": "object", + "required": [ + "update" + ], + "properties": { + "update": { + "$ref": "#/definitions/ProjectPutRequest" + } + }, + "additionalProperties": false + }, + { + "description": "> Requires Authentication > Requires using an Access Token for login or calling Sync at least once Deletes all the projects whose IDs match the provided ones\n\nReturns: [ProjectsDeleteResponse](crate::sdk::response::projects_response::ProjectsDeleteResponse)", + "type": "object", + "required": [ + "delete" + ], + "properties": { + "delete": { + "$ref": "#/definitions/ProjectsDeleteRequest" + } + }, + "additionalProperties": false } ] }, + "ProjectsDeleteRequest": { + "type": "object", + "required": [ + "ids" + ], + "properties": { + "ids": { + "description": "IDs of the projects to delete", + "type": "array", + "items": { + "type": "string", + "format": "uuid" + } + } + }, + "additionalProperties": false + }, "ProjectsListRequest": { "type": "object", "required": [