Skip to content

Commit

Permalink
feat: add getOrgSecurityPolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
typicode committed Jan 2, 2025
1 parent f542552 commit 745f052
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ const { SocketSdk } = require('@socketsecurity/sdk')
* `getOrganizations()`
* `postSettings(selectors)`
* `selectors`: An array of settings selectors, e.g. `[{ organization: 'id' }]`
* `getOrgSecurityPolicy(orgSlug)`
* `orgSlug`: the slug of the organization

## Additional exports

Expand Down
16 changes: 16 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,22 @@ class SocketSdk {
}
}

/**
* @param {string} orgSlug
* @returns {Promise<SocketSdkResultType<'getOrgSecurityPolicy'>>}
*/
async getOrgSecurityPolicy (orgSlug) {
const orgSlugParam = encodeURIComponent(orgSlug)

try {
const client = await this.#getClient()
const data = await client.get(`orgs/${orgSlugParam}/settings/security-policy`).json()
return { success: true, status: 200, data }
} catch (err) {
return /** @type {SocketSdkErrorType<'getOrgSecurityPolicy'>} */ (this.#handleApiError(err))
}
}

/**
* @param {unknown} err
* @returns {{ success: false, status: number, error: Record<string,unknown> }}
Expand Down

0 comments on commit 745f052

Please sign in to comment.