nexmo / nexmo-cli Goto Github PK
View Code? Open in Web Editor NEWNexmo CLI (Command Line Interface)
Home Page: https://nexmo.com
License: MIT License
Nexmo CLI (Command Line Interface)
Home Page: https://nexmo.com
License: MIT License
When I create an app the API responds with a private key, this is the only time that key is sent from Nexmo and can't be recorvered therefore it should be saved to a local file called something like [appid].key and a big red warning message displayed to the developer.
Would be great if the CLI reads the version from NPM.
Would be an interesting feature.
It would be great if the CLI could create a JWT. This functionality will eventually be within the library (we should probably add to nexmo-node
for this), but it would be very handy to be able to quickly create a JWT.
Something like:
nexmo jwt:generate application_id key_file_path
Open to improvements upon the above suggested command/parameters.
There may be a jwt:validate
or jwt:verify
. One thing to consider here is that we avoid confusion with the Verify product.
Wondering if its worth implementing number insight (at least basic maybe std to?)
something line nexmo insight:basic 447970513607
or nexmo insight:std 447970513607
advanced might be harder as I think that needs a webhook url
This will help with reading and browsing for answer. Proposed solution would be to have some simple samples in the README, and the full breakdown in /docs
.
I seem to be getting a new error for something that used to work. Wonder if the underlying API changed.
nexmo nb 447507332052 --confirm
Missing Mandatory fields (number and/or callback url)
As as user I want to be able to set the default number of results to be displayed, currently this is set to 10 across the system.
add nexmo config size XX
command to set a default request size
This value should then be saved in the .nexmorc file and used in the appropriate requests, unless a --size
param is passed with the request.
Not sure if we can get this from the API, but if an app is assigned to a number it would be nice to add it to the table shown when running number:list
.
undefined
outputAn appropriate error should be shown explaining why the command failed.
Current API does not support setting voiceCallbackType or voiceCallbackValue to blank which is a stopper for this.
Current if the nexmo cli is not logged in the nexmo account
command errors. This should probably be caught nicely.
➜ ~ nexmo account
fs.js:640
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open '/Users/cbetta/.nexmorc'
at Error (native)
at Object.fs.openSync (fs.js:640:18)
at Object.fs.readFileSync (fs.js:508:33)
at Config.read (/Users/cbetta/.nvm/versions/node/v6.3.1/lib/node_modules/nexmo-cli/lib/config.js:31:47)
at Request.accountInfo (/Users/cbetta/.nvm/versions/node/v6.3.1/lib/node_modules/nexmo-cli/lib/request.js:41:45)
at Command.listener (/Users/cbetta/.nvm/versions/node/v6.3.1/lib/node_modules/nexmo-cli/node_modules/commander/index.js:301:8)
at emitTwo (events.js:106:13)
at Command.emit (events.js:191:7)
at Command.parseArgs (/Users/cbetta/.nvm/versions/node/v6.3.1/lib/node_modules/nexmo-cli/node_modules/commander/index.js:615:12)
at Command.parse (/Users/cbetta/.nvm/versions/node/v6.3.1/lib/node_modules/nexmo-cli/node_modules/commander/index.js:458:21)
We should keep track of what changes in releases in a CHANGELOG
@sammachin could you clarify what API call you see this mapping too? I'm having difficulty determining this.
From the doc:
Setup Number
nexmo number:setup $number [app|sms|voicefwd|voicexml]
[app]
-name [$name|$appid]
[sms]
-url $url
[voicefwd]
-address [$e164Num|$sipuri]
-statusurl $statusCallbackURL *optional
[voicexml]
-url $URLofVXML
-statusurl $statusCallbackURL *optional
Sets up the number for either app usage or legacy SMS or Voice service, voice has the option of forwarding to a number/sip URI or to a VoiceXML application.
Note, currently you can setup a number for both app which will configure voice to goto VAPI and then legacy SMS to a URL, however app|voicexml|voicefwd are mutually exclusive
Seems https://www.npmjs.com/package/commander-tabtab should do what we want (at least on OSX/Linux)
Debug:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/6.7.0/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli 'nexmo-cli',
1 verbose cli '-g' ]
2 info using [email protected]
3 info using [email protected]
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData nexmo-cli
8 silly fetchDirectoryPackageData nexmo-cli
9 silly install normalizeTree
10 silly loadCurrentTree Finishing
11 silly loadIdealTree Starting
12 silly install loadIdealTree
13 silly cloneCurrentTree Starting
14 silly install cloneCurrentTreeToIdealTree
15 silly cloneCurrentTree Finishing
16 silly loadShrinkwrap Starting
17 silly install loadShrinkwrap
18 silly loadShrinkwrap Finishing
19 silly loadAllDepsIntoIdealTree Starting
20 silly install loadAllDepsIntoIdealTree
21 silly resolveWithNewModule [email protected] checking installable status
22 silly cache add args [ 'nexmo-cli', null ]
23 verbose cache add spec nexmo-cli
24 silly cache add parsed spec Result {
24 silly cache add raw: 'nexmo-cli',
24 silly cache add scope: null,
24 silly cache add escapedName: 'nexmo-cli',
24 silly cache add name: null,
24 silly cache add rawSpec: 'nexmo-cli',
24 silly cache add spec: '/Users/user_name/nexmo-cli',
24 silly cache add type: 'directory' }
25 verbose addLocalDirectory /Users/user_name/.npm/nexmo-cli/0.2.0/package.tgz not in flight; packing
26 verbose correctMkdir /Users/user_name/.npm correctMkdir not in flight; initializing
27 verbose makeDirectory /Users/user_name/.npm creation not in flight; initializing
28 silly makeDirectory /Users/user_name/.npm uid: 860087178 gid: 20
29 info lifecycle [email protected]~prepublish: [email protected]
30 verbose lifecycle [email protected]~prepublish: unsafe-perm in lifecycle true
31 verbose lifecycle [email protected]~prepublish: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/user_name/nexmo-cli/node_modules/.bin:/usr/local/Cellar/node/6.7.0/bin:/Users/user_name/DevApps/activator-dist-1.3.10/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
32 verbose lifecycle [email protected]~prepublish: CWD: /Users/user_name/nexmo-cli
33 silly lifecycle [email protected]~prepublish: Args: [ '-c', 'npm run build' ]
34 silly lifecycle [email protected]~prepublish: Returned: code: 1 signal: null
35 info lifecycle [email protected]~prepublish: Failed to exec prepublish script
36 error addLocal Could not install /Users/user_name/nexmo-cli
37 silly rollbackFailedOptional Starting
38 silly rollbackFailedOptional Finishing
39 silly runTopLevelLifecycles Finishing
40 silly install printInstalled
41 verbose stack Error: [email protected] prepublish: `npm run build`
41 verbose stack Exit status 1
41 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
41 verbose stack at emitTwo (events.js:106:13)
41 verbose stack at EventEmitter.emit (events.js:191:7)
41 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
41 verbose stack at emitTwo (events.js:106:13)
41 verbose stack at ChildProcess.emit (events.js:191:7)
41 verbose stack at maybeClose (internal/child_process.js:877:16)
41 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
42 verbose pkgid [email protected]
43 verbose cwd /Users/user_name
44 error Darwin 15.6.0
45 error argv "/usr/local/Cellar/node/6.7.0/bin/node" "/usr/local/bin/npm" "install" "nexmo-cli" "-g"
46 error node v6.7.0
47 error npm v3.10.7
48 error code ELIFECYCLE
49 error [email protected] prepublish: `npm run build`
49 error Exit status 1
50 error Failed at the [email protected] prepublish script 'npm run build'.
50 error Make sure you have the latest version of node.js and npm installed.
50 error If you do, this is most likely a problem with the nexmo-cli package,
50 error not with npm itself.
50 error Tell the author that this fails on your system:
50 error npm run build
50 error You can get information on how to open an issue for this project with:
50 error npm bugs nexmo-cli
50 error Or if that isn't available, you can get their info via:
50 error npm owner ls nexmo-cli
50 error There is likely additional logging output above.
51 verbose exit [ 1, true ]
Should install without error
Errors as shown in log
See: npm/npm#3059
Node version: v6.7.0
NPM version: 3.10.7
Operating system: Darwin 15.6.0
› nexmo insight:standard {Long Virtual Number} e.g. SMS Shortcode
This operation will charge your account.
Please type "confirm" to continue: confirm
/usr/local/lib/node_modules/nexmo-cli/distribution/response.js:185
this.emitter.list(response.international_format_number + ' | ' + response.country_code + ' | ' + response.current_carrier.name, response);
^
TypeError: Cannot read property 'name' of undefined
at Response.insightStandard (/usr/local/lib/node_modules/nexmo-cli/distribution/response.js:185:128)
at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/nexmo-cli/node_modules/easynexmo/lib/nexmo.js:257:19)
at emitNone (events.js:85:20)
at IncomingMessage.emit (events.js:179:7)
at endReadableNT (_stream_readable.js:913:12)
at _combinedTickCallback (node.js:377:13)
at process._tickCallback (node.js:401:11)
I would not expect an exception.
As above, we get an exception logged to the console.
Node version: v5.7.1
NPM version: 3.6.0
Operating system: OSX 10.11.4
I have more than 10 numbers on my account, nexmo numbers:list only returns the first 10, in the dashboard I can see more. By default the API pagenates at 10 numbers.
CLI should show all numbers on the account
CLI only shows the 10 'lowest' numbers
Node version:
NPM version:
Operating system:
IN the commands the term app and apps should be interchangable, sometimes the plural makes more sense.
eg nexmo app:create
or nexmo apps:list
are logical
However nexmo apps:create
and nexmo app:list
should also still work.
Sams-iMac:~ smachin$ nexmo app:create "CLI Test App 1" http://home.sammachin.com http://home.sammachin.com
_http_client.js:50
throw new TypeError('Request path contains unescaped characters.');
^
TypeError: Request path contains unescaped characters.
at new ClientRequest (_http_client.js:50:11)
at Object.exports.request (http.js:31:10)
at Object.socket.once.exports.request (https.js:182:15)
at sendRequest (/usr/local/lib/node_modules/nexmo-cli/node_modules/easynexmo/lib/nexmo.js:228:27)
at Object.exports.createApplication (/usr/local/lib/node_modules/nexmo-cli/node_modules/easynexmo/lib/nexmo.js:407:7)
at Request.applicationCreate (/usr/local/lib/node_modules/nexmo-cli/distribution/request.js:135:30)
at Command.listener (/usr/local/lib/node_modules/nexmo-cli/node_modules/commander/index.js:301:8)
at emitTwo (events.js:87:13)
at Command.emit (events.js:172:7)
at Command.parseArgs (/usr/local/lib/node_modules/nexmo-cli/node_modules/commander/index.js:615:12)
node v4.4.4
nexmo-cli v0.0.1
If the user enteres a number with a + the cli should strip that off currently you get a 'method failed' errror
nexmo price:sms +447970513607
method failed
For this the project needs to be public.
when I update an app and set —answer_method POST it doesn’t put an & in the query string so answer_method=POST gets added to the URL
Sams-Air:~ smachin$ nexmo app:update 26afecbf-28cb-42f5-b4a3-f1e98cb7de91 VAPI_Voicemail http://sammachin.ngrok.io/call http://sammachin.ngrok.io/call --answer_method POST --debug
{ host: 'api.nexmo.com',
port: 443,
path: '/beta/account/applications/26afecbf-28cb-42f5-b4a3-f1e98cb7de91?name=VAPI_Voicemail&type=voice&answer_url=http://sammachin.ngrok.io/call&event_url=http://sammachin.ngrok.io/callanswer_method=POST&&api_key=XXX&api_secret=XXX',
method: 'PUT',
headers:
{ 'Content-Type': 'application/x-www-form-urlencoded',
accept: 'application/json' } }
response ended
Validator.response() - Error:
null
Validator.response() - Response:
{ id: '26afecbf-28cb-42f5-b4a3-f1e98cb7de91',
name: 'VAPI_Voicemail',
voice: { webhooks: [ [Object], [Object] ] },
keys: { public_key: '-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnRW29LazggDtIeiD0TV5\n+/Xv0jjbYSoKKa4m4K6RVk+b2WW6HFCUkIM0GDAwws7L5MRObfQD2Q5BRyH6idwY\n7eKxqsNJQ0Ut5IaQQZHMsOKDUl/FbuXOjzjR8NkSuqb7BmC/ZuVuwhI5CHV449AM\nJmD07gV9VkwpX3toTb66D3v1AZJxdErZFbmQvOKNXYBe858ojfCfZzRGpTqxf7AJ\ngAiSWCprkgwxDD1JahQri1o2vknuI4H5q4MyXHXo3ysvoBU1gYiQN5WiilCI3xGD\nPFv1QzS1RAH1rivH6KY7eQ7GolK5pVYGy4F/tEsP065pkJXzd7NLlgA7KK6H0xhn\nEQIDAQAB\n-----END PUBLIC KEY-----\n' },
_links: { self: { href: '/applications/26afecbf-28cb-42f5-b4a3-f1e98cb7de91' } } }
End Validator.response()
Application updated: 26afecbf-28cb-42f5-b4a3-f1e98cb7de91
Currently bin.js
has a lot of replication because commander.js
doesn't support multiple aliases per command. I've opened a proposal to add this: tj/commander.js#531
Currently the API allows for searching of numbers by certain specifications and then buying the number.
> nexmo number:search NL --pattern *007
31635251007
31635252007
31635253007
31635254007
31635255007
31635256007
31635257007
31635258007
31635259007
> nexmo number:buy 31635251007
This is operation will charge your account.
Please type "confirm" to continue: confirm
Number purchased
It would be interesting if we could achieve this all in 1 step:
> nexmo number:buy NL --pattern *007 --confirm
Number purchased: 31635251007
# or
> nexmo number:search NL --pattern *007 --buy --confirm
Number purchased: 31635251007
# or
> nexmo number:smartbuy NL --pattern *007 --confirm
Number purchased: 31635251007
The first 2 options have the downside of overcomplicating the now relatively simple number:buy
and number:search
. The latter has the downside of being a new command.
Seeing as there is a synchronous version of Number Insights Advanced we should probably add this to the CLI.
In the following command I would expect 50 entries to be shown. But only 10 are shown.
› nexmo apps:list --verbose --size 50
Item 1-50 of 52
id | name
------------------------------------------------------
019cb774-4ad0-4b22-a9db-86a8e7df1d34 | nexmo-node-test
01f7e4a5-ea15-48da-a3c3-f792089443a0 | First Voice App
03f31f24-c2e9-4193-9d71-7a5fd9fc0c70 | First Voice App
0b5d3fec-eac5-4b55-b71c-60874f981659 | First Voice App
0b5f2c87-1355-438b-99b9-7046eec89476 | 1473368357732
0ce0271e-a438-4fdb-8eb2-ca03932b5f2c | my-voice-app
178c9b62-571c-4328-959c-0cf9a49b354f | watson-test
18cdaa6c-e69f-475a-b2e6-b63b9ce20674 | First Voice App
1cc45c5a-0d08-4bff-9f36-5b0dbfa69881 | Blah
22edf392-bd50-42ad-b885-98f891da4b6a | First Voice App
A simple version of this has currently been implemented for the app
type but there are other types.
I'm thinking it would be nice to be able to run the CLI without first signing in. This can be useful on shared PCs but mainly is also useful for running it as a one of command as part of build scripts or CI servers:
Example:
nexmo sms 447555555555 "Build succeeded" --api-key abc123 --api-secret cde234
Currently my go-to method to get my API key and secret is to run: cat ~/.nexmorc
as it is faster than going to my dashboard. It might be interesting to just add this to the CLI itself. It would also be handy when trying to see what API credentials a project is using.
The API will always return the account balance as EUR as that is the nexmo 'virtual currency' however within the dashboard users can opt to display their balance in USD but we still hold that internally as EUR.
Therefore can we add an EUR label to the output of the nexmo balance command in case they get confused.
As I'm building apps I'm frequently thinking to myself "What numbers are associated with this application?"
It'd be great to be able to do something like:
nexmo app:numbers APP_ID
And get a list of the numbers that are associated with the APP_ID.
For the moment, the only way I can do this is:
nexmo numbers --verbose --size 50
And manually look for my application ID in the output.
Open to the feedback that I'm just being lazy or rubbish at CLIs 😄
If you try to use the private key when it's downloaded, upon signing you are likely to get an error:
asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
If you're seeing errors such as asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
then you should run the following on your key.txt:
openssl rsa -in key.txt -out key.txt
It may be that there are newline characters in the downloaded file that need to be stripped. Or some other set of characters. I've been informed that it's newline characters, but I haven't checked.
Currently buying and cancelling numbers is free. It would be great to add a confirmation step.
If I have a number with a current linked SMS url (moHTTPUrl) and I then go to set a voice link for example to forward it to a tel number nexmo link:tel 44..
it removes the SMS link.
I can set the SMS after the voice and it keeps both.
I should be able to set voice without removing sms.
What are the main motivations for the CLI? Who is it for? How should it be used?
Some background: We decided to create the CLI so that we could more quickly (in a few commands) get to the point where we could start building (writing code) Voice API v2 functionality.
We then realised that a CLI is just really handy. We can perform quick number lookups (insight), buy numbers, check account balance etc. Others at Nexmo are also finding it really useful e.g. support and sales engineers.
I think we should be able to create a few bullet points that help us guide the decisions we make about the CLI.
Not all APIs or methods in the Node library support pagination. Once this has been added we can add pagination to the appropriate CLI methods.
Currently the number:add
and number:cancel
require a country code, even though this should be derivable from the number.
A good idea would be to derive this using Number Insights Basic but this doesn't seem to be present in the Node lib.
It'll be really handy if we can track usage of the library via interactions with our API endpoints.
This will require an update to nexmo-node
so that the User-Agent
is added to the headers and so that the value can be configured.
Maybe a value of nexmo-cli/node/{version}
.
nexmo-cli
is the client. node
is the runtime (maybe we'll create another CLI in another language?) and {version}
is the nexmo-cli version pulled from package.json
.
Oh, and nexmo-cli
could also be retrieved from the package.json
.
Known issue with the commander library seems to truncate the help: tj/commander.js#530
Currently we do not actually verify the credentials on setup. We should probably do so, maybe make a simple balance query and see if it fails.
It's specifically a problem if you do something like the following which purchases the first number returned from a search:
nexmo number:search GB | sed -n 1p | xargs -I{} nexmo number:buy {} --confirm
Because the output of the first command isn't show and is instead piped to sed
and then accessed via xargs
.
Result:
› nexmo number:search GB | sed -n 1p | xargs -I{} nexmo number:buy {} --confirm
Number purchased
What number did I purchase?
There may be a way to also output the number via the above command. But this request seems reasonable none the less.
We have some 'longer than normal' dutch numbers in inventory which support SMS.
for example +31 970 1024 0032
Unfortunalty the Number Insight API fails to validate them which means that you can't configure them using the CLI tool.
I've raised this as bug with number insight but putting here mainly for tracking
nexmo price GB # returns prices for ranges
nexmo price 4475555555 # returns price for this number
Problems with tests on Node 6.3.0 due to some errors in MockFS. @cbetta has raised a ticket on tschaub/mock-fs#137
Just a reminder to do so before first release.
When you try to execute a command and nexmo setup
hasn't been run you will see an error as outlined in the title of this issue. It should be changed to state the "CLI" cannot be initialized..
For some counties (for example GB) the SMS Price can vary depending on the network being sent to, the default country price returned is 0.0314 whereas all the known mobile networks are 0.0333. (The 0.0314 is for UNKNOWN
e.g. landlines)
The problem for users is that the price:country command without -v just returns the default country price and in the UK case nearly all mobile will be slightly higher and may mislead users causing additional support overhead.
I suggest we modify the price:country
non verbose response to be a range of the lowest and highest values returned by the API so for GB it should show 0.0314 - 0.0333 EUR
The number specific price queries are unaffected as this will always be a single value returned from our rating system
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.