MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / create_org

Function create_org

atomic-teams/src/org.rs:25–43  ·  view source on GitHub ↗

Create a new organization. # Arguments `client` — Authenticated storage client. `name` — Human-readable display name for the organization. `email` — Optional contact email. # Errors Returns [`TeamsError::AlreadyExists`](crate::error::TeamsError::AlreadyExists) if an organization with the derived slug already exists.

(
    client: &StorageClient,
    name: &str,
    email: Option<&str>,
)

Source from the content-addressed store, hash-verified

23/// Returns [`TeamsError::AlreadyExists`](crate::error::TeamsError::AlreadyExists)
24/// if an organization with the derived slug already exists.
25pub async fn create_org(
26 client: &StorageClient,
27 name: &str,
28 email: Option<&str>,
29) -> TeamsResult<OrgInfo> {
30 debug!("Creating organization: name={name}");
31 let slug = slugify(name);
32 let body = CreateOrgRequest {
33 slug: &slug,
34 name,
35 email,
36 };
37 let info: OrgInfo = client
38 .post("/orgs", &body)
39 .await
40 .map_err(|e| map_remote_error(e, format!("org {name}")))?;
41 debug!("Created organization: slug={}, id={}", info.slug, info.id);
42 Ok(info)
43}
44
45/// Fetch an organization by slug.
46///

Callers 1

executeMethod · 0.85

Calls 3

slugifyFunction · 0.85
map_remote_errorFunction · 0.85
postMethod · 0.80

Tested by

no test coverage detected