Documentation
Organisations
Listes d'organisations et enregistrements d'organisations gérés.
Traduit automatiquement de l'anglais. Voir l'original en anglais
Envoyez ces demandes à votre propre sidecar en cours d’exécution. Les valeurs restent dans ce navigateur.
Comment ça marche
Le sidecar écoute sur un port de bouclage choisi au démarrage et l'imprime dans son ready doubler; utilisez cette URL et le CADCAMFUN_TOKEN ça a commencé avec. Les demandes vont directement de cette page à cette adresse.
Le sidecar envoie les en-têtes CORS uniquement aux origines Tauri et à http://localhost ou http://127.0.0.1 sur n'importe quel port. À partir des documents hébergés, le navigateur bloque la réponse, exécutez donc les documents localement (bun run dev dans packages/web) pour utiliser le terrain de jeu, ou copiez la requête sous forme curl. Pour expérimenter sans toucher aux données réelles, démarrez le sidecar avec CADCAMFUN_DATA_DIR pointé vers un répertoire jetable — voir la procédure pas à pas de l'API.
Opérations
5 endpoints dans le organizations groupe, généré à partir du propre sidecar Document OpenAPI. Les opérations protégées prennent Authorization: Bearer $CADCAMFUN_TOKEN; voir authentification. Le comportement et les limites sont en place le guide du sous-système.
| obtenir | /api/organizations | organizations.list |
| poste | /api/organizations | organizations.create |
| obtenir | /api/organizations/{id} | organizations.get |
| mettre | /api/organizations/{id} | organizations.update |
| supprimer | /api/organizations/{id} | organizations.remove |
/api/organizations
organizations.list Nécessite Authorization: Bearer <token>.
200 Tableau<objet> application/json
Array<{ id: string name: string description: string | null createdAt: string updatedAt: string role: "ADMIN" | "MANAGER" | "MEMBER" userCount: number | "Infinity" | "-Infinity" | "NaN" projectCount: number | "Infinity" | "-Infinity" | "NaN" }>
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
Exemple de réponse capturé · 200
[] Exemple de SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// no input
const result = await client.organizations.list() curl
curl --request GET "${CADCAMFUN_URL}/api/organizations" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" Essayez-le
organizations.create Nécessite Authorization: Bearer <token>.
{ name: string description?: string | null }
201 objet application/json
{ id: string name: string description: string | null createdAt: string updatedAt: string }
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
Exemple de SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// OrganizationsCreateInput
const result = await client.organizations.create({
name: "",
description: ""
}) curl
curl --request POST "${CADCAMFUN_URL}/api/organizations" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json Essayez-le
organizations.get Nécessite Authorization: Bearer <token>.
| Nom | Dans | Taper | Requis |
|---|---|---|---|
| identifiant | chemin | chaîne | requis |
200 objet application/json
{ id: string name: string description: string | null createdAt: string updatedAt: string members: Array<{ id: string name: string | null email: string | null image: string | null role: "ADMIN" | "MANAGER" | "MEMBER" joinedAt: string }> projectCount: number | "Infinity" | "-Infinity" | "NaN" userRole: "ADMIN" | "MANAGER" | "MEMBER" }
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
403 ForbiddenEncoded application/json
ForbiddenEncoded
404 NotFoundEncoded application/json
NotFoundEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
Exemple de SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// OrganizationsGetInput
const result = await client.organizations.get({
id: "<id>"
}) curl
curl --request GET "${CADCAMFUN_URL}/api/organizations/<id>" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" Essayez-le
organizations.update Nécessite Authorization: Bearer <token>.
| Nom | Dans | Taper | Requis |
|---|---|---|---|
| identifiant | chemin | chaîne | requis |
{ name: string description?: string | null }
200 objet application/json
{ id: string name: string description: string | null createdAt: string updatedAt: string }
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
403 ForbiddenEncoded application/json
ForbiddenEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
Exemple de SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// OrganizationsUpdateInput
const result = await client.organizations.update({
id: "<id>",
name: "",
description: ""
}) curl
curl --request PUT "${CADCAMFUN_URL}/api/organizations/<id>" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json Essayez-le
organizations.remove Nécessite Authorization: Bearer <token>.
| Nom | Dans | Taper | Requis |
|---|---|---|---|
| identifiant | chemin | chaîne | requis |
200 objet application/json
{ message: string }
400 BadRequestEncoded application/json
BadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
403 ForbiddenEncoded application/json
ForbiddenEncoded
500 InternalErrorEncoded application/json
InternalErrorEncoded
Exemple de SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// OrganizationsRemoveInput
const result = await client.organizations.remove({
id: "<id>"
}) curl
curl --request DELETE "${CADCAMFUN_URL}/api/organizations/<id>" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" Essayez-le
Schémas
Schémas nommés accessibles à partir des paramètres, des corps et des réponses de ce groupe. UN ? marque un champ facultatif ; | null marque un champ qui peut être présent avec une valeur nulle.
BadRequestEncoded{ _tag: "BadRequest" message: string }
ForbiddenEncoded{ _tag: "Forbidden" message: string }
InternalErrorEncoded{ _tag: "InternalError" message: string }
NotFoundEncoded{ _tag: "NotFound" message: string }
Appel à ce groupe
Les identifiants d'opération ont la forme organizations.<name>. Le SDK Promise généré (@cadcamfun/api/sdk) expose la plupart d'entre eux comme client.<namespace>.<method>(input), où input est un objet plat composé de paramètres de chemin et de champs de corps ; L'exemple de SDK de chaque carte montre l'accesseur exact et le type d'entrée. Les téléchargements en plusieurs parties, les réponses binaires ou JavaScript et les webhooks bruts ne sont pas générés ; ces cartes montrent fetch à la place.
import { CadCam, ClientError } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
try {
await client.projects.list()
} catch (error) {
if (error instanceof ClientError) {
// Transport | UnexpectedStatus | UnsupportedContentType | MalformedResponse | SseEventTooLarge
} else {
// a declared error body: switch on error._tag
}
} Dépannage
| Symptôme | Cause probable | Réparer |
|---|---|---|
| 401 à chaque appel | Jeton d'un lancement précédent, ou manquant Bearer préfixe | Envoyer Authorization: Bearer <token> avec le jeton avec lequel le sidecar a été démarré. |
| 400 avant que quoi que ce soit se produise | Le corps ou le paramètre ne correspond pas au schéma | Comparez la charge utile avec le schéma de demande sur la carte. |
| 403 ou 404 sur un enregistrement visible ailleurs | Le compte intérimaire diffère | Envoyez le droit x-session-token, ou utilisez le profil local propriétaire de l'enregistrement. |
| 409 | État conflictuel, tel qu'un nom en double ou un chef de succursale obsolète | Relisez la ressource et réessayez avec les données actuelles. |
| Essayez, il est écrit "bloqué par CORS" | Les documents sont servis à partir d'une origine sans bouclage | Exécutez la documentation localement ou copiez la demande en tant que curl. |
| Connexion rejetée | Le sidecar a redémarré sur un nouveau port | Lire le port du nouveau ready ligne. |