跳转到内容
EN

Lock a target's OpenTofu state

Code Mode: praxis.devops.projects.environments.targets.state.lock.create

HTTP: POST /devops/v1/projects/{project}/environments/{environment}/targets/{target}/state/lock

Take the lock on one target’s state before OpenTofu plans or applies; this is the POST that praxis devops deploy configures as OpenTofu’s lock_method (the default LOCK verb on the state path works too). Exactly one holder can hold the lock. A held lock answers 423 with the holder’s lock info, which names who is deploying; wait for them or, if they are gone, release it with a force-unlock using the ID in that answer.

签名

praxis.devops.projects.environments.targets.state.lock.create(args:{path:{/** e.g. "dvp_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ project:string;/** e.g. "dve_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ environment:string;/** e.g. "services%2Fontology" */ target:string};body:{/** Identifies the lock; every write and the unlock must carry it. e.g. "4c1f0a52-8f4e-9d6c-1b0e-5a7d3c2e9f10" */ ID:string;/** What the holder is doing, such as OperationTypeApply. e.g. "OperationTypeApply" */ Operation?:string;/** The holder, user@host, shown to the caller that finds the lock held. e.g. "ci@build-7" */ Who?:string;/** When the holder took the lock, RFC 3339. e.g. "2026-11-08T03:00:00Z" */ Created?:string;/** Where the holder keeps its working state, informational. e.g. "" */ Path?:string;[key:string]:unknown}}):Promise<{/** Identifies the lock; every write and the unlock must carry it. e.g. "4c1f0a52-8f4e-9d6c-1b0e-5a7d3c2e9f10" */ ID:string;/** What the holder is doing, such as OperationTypeApply. e.g. "OperationTypeApply" */ Operation?:string;/** The holder, user@host, shown to the caller that finds the lock held. e.g. "ci@build-7" */ Who?:string;/** When the holder took the lock, RFC 3339. e.g. "2026-11-08T03:00:00Z" */ Created?:string;/** Where the holder keeps its working state, informational. e.g. "" */ Path?:string;[key:string]:unknown}>;

参数

名称位置类型必填说明
projectpathstring是Identifies the project whose data you are reading, from the project list or create answer.
environmentpathstring是Identifies the DevOps environment (dve_…) whose deploy state you address, from the project’s environment list.
targetpathstring是The deploy target’s repository path, URL-encoded as one segment: services/ontology is written services%2Fontology.

请求体

必填内容类型说明
是application/jsonThe lock info OpenTofu sends; ID is required and Who names the holder.

响应

状态码内容类型说明
200application/jsonThe lock is yours; the answer repeats the lock info.
400application/jsonINVALID_PARAMS or INVALID_ARGUMENT means a field, query value or identifier violates the documented format or range — an unknown enum value, a pageSize outside 1..100, an unsupported filter or orderBy field, or an id with the wrong prefix. Correct the named input; nothing was read or written.
401application/jsonThe API key is missing or invalid; send a valid Praxis API key in the Authorization header before retrying.
404application/jsonNOT_FOUND means the project or environment does not exist for this organization, or, on a read, that the target has no state yet. Nothing is revealed about another organization’s projects. OpenTofu reads a missing state as empty.
423application/jsonLOCKED means another holder has the lock; the body is that holder’s lock info. Nothing changed.
500application/jsonINTERNAL means the service could not complete the request; retry once, and if it repeats report the request id. A read is safe to repeat; a write that failed this way should be re-read before it is sent again.