Skip to main content
REST client

Policies

The 6 operations under policies, as typed calls on the generated REST client.

1 min read
View MarkdownEdit on GitHub

Policies

Available from @codespar/sdk 0.12.0; the version on npm is 0.12.0. Every example on this page is compiled against the installed package when these docs build: a call that does not type-check fails the build.

Every call below is cs.api reaching one operation of the OpenAPI document this page was generated from; the REST client overview explains request, response, the option bag and the errors. The values are placeholders shaped by the document.

import {  } from "@codespar/sdk";

const  = new ({ : .. });

GET /v1/policies

GET/v1/policies

List policy rules for the authenticated org, sorted by order ASC.

const  = await ..("/v1/policies");

Parameters, body and every documented response: GET /v1/policies in the HTTP reference.

POST /v1/policies

POST/v1/policies

Create a new policy rule.

const  = await ..("/v1/policies", {
  : {
    : "Example",
    : "allow",
    : [],
    : [],
    : true
  }
});

Parameters, body and every documented response: POST /v1/policies in the HTTP reference.

POST /v1/policies/reorder

POST/v1/policies/reorder

Reorder policy rules. Atomic: if any id does not belong to the org, the entire operation rolls back and returns 404.

const  = await ..("/v1/policies/reorder", {
  : {
    : [
      "string"
    ]
  }
});

Parameters, body and every documented response: POST /v1/policies/reorder in the HTTP reference.

GET /v1/policies/{id}

GET/v1/policies/{id}

Read one policy rule

const  = await ..("/v1/policies/{id}");

Parameters, body and every documented response: GET /v1/policies/{id} in the HTTP reference.

PATCH /v1/policies/{id}

PATCH/v1/policies/{id}

Update a policy rule. Cross-org ids return 404. Invalidates the per-org cache on success.

const  = await ..("/v1/policies/{id}", {
  : {
    : "policie_0000000000000000"
  },
  : {
    : "Example",
    : "allow",
    : [
      "string"
    ],
    : [
      "string"
    ],
    : true
  }
});

Parameters, body and every documented response: PATCH /v1/policies/{id} in the HTTP reference.

DELETE /v1/policies/{id}

DELETE/v1/policies/{id}

Delete a policy rule. Cross-org ids return 404. Invalidates the per-org cache on success.

const  = await ..("/v1/policies/{id}", {
  : {
    : "policie_0000000000000000"
  }
});

Parameters, body and every documented response: DELETE /v1/policies/{id} in the HTTP reference.

Policies | CodeSpar