@salesforce/plugin-api
Version:
A plugin to call API endpoints via CLI commands
246 lines • 11.2 kB
JSON
{
"commands": {
"api:request:graphql": {
"aliases": [],
"args": {},
"description": "Specify the GraphQL statement with the \"--body\" flag, either directly at the command line or with a file that contains the statement. You can query Salesforce records using a \"query\" statement or use mutations to modify Salesforce records.\n\nThis command uses the GraphQL API to query or modify Salesforce objects. For details about the API, and examples of queries and mutations, see https://developer.salesforce.com/docs/platform/graphql/guide/graphql-about.html.",
"examples": [
"Execute a GraphQL query on the Account object by specifying the query directly to the \"--body\" flag; the command uses your default org:\n<%= config.bin %> <%= command.id %> --body \"query accounts { uiapi { query { Account { edges { node { Id \\n Name { value } } } } } } }\"",
"Read the GraphQL statement from a file called \"example.txt\" and execute it on an org with alias \"my-org\":\n<%= config.bin %> <%= command.id %> --body example.txt --target-org my-org",
"Pipe the GraphQL statement that you want to execute from standard input to the command:\n$ echo graphql | sf api request graphql --body -",
"Write the output of the command to a file called \"output.txt\" and include the HTTP response status and headers:\n<%= config.bin %> <%= command.id %> --body example.txt --stream-to-file output.txt --include"
],
"flags": {
"json": {
"description": "Format output as json.",
"helpGroup": "GLOBAL",
"name": "json",
"allowNo": false,
"type": "boolean"
},
"flags-dir": {
"helpGroup": "GLOBAL",
"name": "flags-dir",
"summary": "Import flag values from a directory.",
"hasDynamicHelp": false,
"multiple": false,
"type": "option"
},
"target-org": {
"char": "o",
"name": "target-org",
"noCacheDefault": true,
"required": true,
"summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
"hasDynamicHelp": true,
"multiple": false,
"type": "option"
},
"api-version": {
"description": "Override the api version used for api requests made by this command",
"name": "api-version",
"hasDynamicHelp": false,
"multiple": false,
"type": "option"
},
"stream-to-file": {
"char": "S",
"exclusive": [
"include"
],
"name": "stream-to-file",
"summary": "Stream responses to a file.",
"hasDynamicHelp": false,
"helpValue": "Example: report.xlsx",
"multiple": false,
"type": "option"
},
"include": {
"char": "i",
"exclusive": [
"stream-to-file"
],
"name": "include",
"summary": "Include the HTTP response status and headers in the output.",
"allowNo": false,
"type": "boolean"
},
"body": {
"name": "body",
"required": true,
"summary": "File or content with the GraphQL statement. Specify \"-\" to read from standard input.",
"hasDynamicHelp": false,
"helpValue": "file",
"multiple": false,
"type": "option"
}
},
"hasDynamicHelp": true,
"hiddenAliases": [],
"id": "api:request:graphql",
"pluginAlias": "@salesforce/plugin-api",
"pluginName": "@salesforce/plugin-api",
"pluginType": "core",
"state": "beta",
"strict": true,
"summary": "Execute a GraphQL statement.",
"enableJsonFlag": true,
"isESM": true,
"relativePath": [
"lib",
"commands",
"api",
"request",
"graphql.js"
],
"aliasPermutations": [],
"permutations": [
"api:request:graphql",
"request:api:graphql",
"request:graphql:api",
"api:graphql:request",
"graphql:api:request",
"graphql:request:api"
]
},
"api:request:rest": {
"aliases": [],
"args": {
"url": {
"description": "Salesforce API endpoint",
"name": "url",
"required": false
}
},
"description": "When sending the HTTP request with the \"--body\" flag, you can specify the request directly at the command line or with a file that contains the request.\n\nFor a full list of supported REST endpoints and resources, see https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_list.htm.",
"examples": [
"List information about limits in the org with alias \"my-org\":\n<%= config.bin %> <%= command.id %> 'services/data/v56.0/limits' --target-org my-org",
"List all endpoints in your default org; write the output to a file called \"output.txt\" and include the HTTP response status and headers:\n<%= config.bin %> <%= command.id %> '/services/data/v56.0/' --stream-to-file output.txt --include",
"Get the response in XML format by specifying the \"Accept\" HTTP header:\n<%= config.bin %> <%= command.id %> '/services/data/v56.0/limits' --header 'Accept: application/xml'",
"Create an account record using the POST method; specify the request details directly in the \"--body\" flag:\n<%= config.bin %> <%= command.id %> /services/data/v56.0/sobjects/account --body \"{\\\"Name\\\" : \\\"Account from REST API\\\",\\\"ShippingCity\\\" : \\\"Boise\\\"}\" --method POST",
"Create an account record using the information in a file called \"info.json\" (note the @ prefixing the file name):\n<%= config.bin %> <%= command.id %> '/services/data/v56.0/sobjects/account' --body @info.json --method POST",
"Update an account record using the PATCH method:\n<%= config.bin %> <%= command.id %> '/services/data/v56.0/sobjects/account/<Account ID>' --body \"{\\\"BillingCity\\\": \\\"San Francisco\\\"}\" --method PATCH",
"Store the values for the request header, body, and so on, in a file, which you then specify with the --file flag; see the description of --file for more information:\n<%= config.bin %> <%= command.id %> --file myFile.json"
],
"flags": {
"flags-dir": {
"helpGroup": "GLOBAL",
"name": "flags-dir",
"summary": "Import flag values from a directory.",
"hasDynamicHelp": false,
"multiple": false,
"type": "option"
},
"target-org": {
"char": "o",
"name": "target-org",
"noCacheDefault": true,
"required": true,
"summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
"hasDynamicHelp": true,
"multiple": false,
"type": "option"
},
"include": {
"char": "i",
"exclusive": [
"stream-to-file"
],
"name": "include",
"summary": "Include the HTTP response status and headers in the output.",
"allowNo": false,
"type": "boolean"
},
"method": {
"char": "X",
"name": "method",
"summary": "HTTP method for the request.",
"hasDynamicHelp": false,
"multiple": false,
"options": [
"GET",
"POST",
"PUT",
"PATCH",
"HEAD",
"DELETE",
"OPTIONS",
"TRACE"
],
"type": "option"
},
"header": {
"char": "H",
"name": "header",
"summary": "HTTP header in \"key:value\" format.",
"hasDynamicHelp": false,
"helpValue": "key:value",
"multiple": true,
"type": "option"
},
"file": {
"char": "f",
"description": "Use this flag instead of specifying the request details with individual flags, such as --body or --method. This schema defines how to create the JSON file:\n\n{\nurl: { raw: string } | string;\nmethod: 'GET', 'POST', 'PUT', 'PATCH', 'HEAD', 'DELETE', 'OPTIONS', 'TRACE';\ndescription?: string;\nheader: string | Array<Record<string, string>>;\nbody: { mode: 'raw' | 'formdata'; raw: string; formdata: FormData };\n}\n\nSalesforce CLI defined this schema to be mimic Postman schemas; both share similar properties. The CLI's schema also supports Postman Collections to reuse and share requests. As a result, you can build an API call using Postman, export and save it to a file, and then use the file as a value to this flag. For information about Postman, see https://learning.postman.com/.\n\nHere's a simple example of a JSON file that contains values for the request URL, method, and body:\n\n{\n\"url\": \"sobjects/Account/<Account ID>\",\n\"method\": \"PATCH\",\n\"body\" : {\n\"mode\": \"raw\",\n\"raw\": {\n\"BillingCity\": \"Boise\"\n}\n}\n}\n\nSee more examples in the plugin-api test directory, including JSON files that use \"formdata\" to define collections: https://github.com/salesforcecli/plugin-api/tree/main/test/test-files/data-project.",
"exclusive": [
"body"
],
"name": "file",
"summary": "JSON file that contains values for the request header, body, method, and URL.",
"hasDynamicHelp": false,
"helpValue": "file",
"multiple": false,
"type": "option"
},
"stream-to-file": {
"char": "S",
"exclusive": [
"include"
],
"name": "stream-to-file",
"summary": "Stream responses to a file.",
"hasDynamicHelp": false,
"helpValue": "Example: report.xlsx",
"multiple": false,
"type": "option"
},
"body": {
"char": "b",
"name": "body",
"summary": "File or content for the body of the HTTP request. Specify \"-\" to read from standard input or \"\" for an empty body. If passing a file, prefix the filename with '@'.",
"hasDynamicHelp": false,
"helpValue": "file",
"multiple": false,
"type": "option"
}
},
"hasDynamicHelp": true,
"hiddenAliases": [],
"id": "api:request:rest",
"pluginAlias": "@salesforce/plugin-api",
"pluginName": "@salesforce/plugin-api",
"pluginType": "core",
"state": "beta",
"strict": true,
"summary": "Make an authenticated HTTP request using the Salesforce REST API.",
"enableJsonFlag": false,
"isESM": true,
"relativePath": [
"lib",
"commands",
"api",
"request",
"rest.js"
],
"aliasPermutations": [],
"permutations": [
"api:request:rest",
"request:api:rest",
"request:rest:api",
"api:rest:request",
"rest:api:request",
"rest:request:api"
]
}
},
"version": "1.3.3"
}