-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add listOrganizations to sdk-for-cli
- Loading branch information
1 parent
490d525
commit 35f982f
Showing
3 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const { sdkForProject } = require('../sdks') | ||
const { parse } = require('../parser') | ||
const { showConsoleLink } = require('../utils.js'); | ||
|
||
/** | ||
* @typedef {Object} OrganizationsListRequestParams | ||
* @property {string[]} queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total, billingPlan | ||
* @property {string} search Search term to filter your list results. Max length: 256 chars. | ||
* @property {boolean} parseOutput | ||
* @property {libClient | undefined} sdk | ||
*/ | ||
|
||
/** | ||
* @param {OrganizationsListRequestParams} params | ||
*/ | ||
const organizationsList = async ({queries, search, parseOutput = true, sdk = undefined, console}) => { | ||
let client = !sdk ? await sdkForProject() : | ||
sdk; | ||
let apiPath = '/organizations'; | ||
let payload = {}; | ||
if (typeof queries !== 'undefined') { | ||
payload['queries'] = queries; | ||
} | ||
if (typeof search !== 'undefined') { | ||
payload['search'] = search; | ||
} | ||
|
||
let response = undefined; | ||
|
||
response = await client.call('get', apiPath, { | ||
'content-type': 'application/json', | ||
}, payload); | ||
|
||
if (parseOutput) { | ||
if(console) { | ||
showConsoleLink('organizations', 'list'); | ||
} else { | ||
parse(response) | ||
} | ||
} | ||
|
||
return response; | ||
|
||
} | ||
|
||
module.exports = { | ||
organizationsList | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters