3scale-archive / 3scale-cli Goto Github PK
View Code? Open in Web Editor NEWDEPRECATED Beta of 3scale CLI, manage your 3scale installation directly from terminal (community supported)
Home Page: https://www.3scale.net
License: MIT License
DEPRECATED Beta of 3scale CLI, manage your 3scale installation directly from terminal (community supported)
Home Page: https://www.3scale.net
License: MIT License
This is an open repo and so should make clear the license that applies.
I suggest our common MIT license.
I am quite new to nodejs so I might be missing some obvious solutions, if that was the case please be patient with me.
I am using 3scale-cli as a the way to achieve automation on deployment on 3scale gateways. I could have used 3scale REST API if I just had the corresponding swagger file, then with Swagger Codegen I was set to create a client SDK, but that swagger file is nowhere to be found. The product source code in ruby does have the tags for https://github.com/solso/source2swagger, but I do not know how to use it properly and imagine that swagger should be public somewhere? I just could not find it.
Too bad, I based my automation scripts on calling 3scale-cli and data scraping the output to get the ids of the different entities created or listed.
Then I found that some commands require interactive input via 'Inquirer.js'. Initially only 'config' was a problem, I coded an extra command to configure from script with no keyboard input.
But after the last changes I find that also the 'import' command now has interactive prompt.
Unless there is some trick to specify input to be accepted by Inquirer with no human intervention, may I suggest that all functionalities of this tool are made compatible with unattended execution? Many thanks in advance for your suggestions and feedback!
Give the possibility to make an exact copy of the Application Plan (on the same service).
some Application Plans have very complex configuration and reproducing it manually is tedious.
Add functionnality to push OpenAPI/Swagger spec to Activedocs
I would expect the field in the tool to take into account the private url backend field and automatically copy that into the Private Base URL field.
I attached the definition and here is the command I'm executing:
3scale-cli import swagger -f inditex.json -p {method}_{path} [inditex.json.txt](https://github.com/3scale/3scale-cli/files/1084507/inditex.json.txt)
Auto import is very cool as is. It would be better if it imported the Swagger to 3scale as an Active Doc and displayed it on the Dev Portal.
Hello
The current version of 3scale-cli does not seem to support on-prem. Can you please confirm? If so, are you planning to support it soon please?
Thanks
Launched the following command:
3scale-cli import swagger -f swagger-mock.yaml -p {method}_{path}
with the attached file
swagger-mock.yaml.txt
and received the following error while processing it:
[3scale-cli] ERROR encountered on creating Mapping rule: undefined
/usr/lib/node_modules/node-3scale-cli/node_modules/q/q.js:155
throw e;
^
Error: Server responded with status code 422 undefined
at /usr/lib/node_modules/node-3scale-cli/lib/mappingrules.js:29:13
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
From previous event:
at createMappingRulePromise (/usr/lib/node_modules/node-3scale-cli/lib/swagger.js:123:113)
at /usr/lib/node_modules/node-3scale-cli/node_modules/delay-promise/index.js:15:18
at delay.then (/usr/lib/node_modules/node-3scale-cli/node_modules/delay-promise/index.js:8:33)
From previous event:
at threescale_waterfall (/usr/lib/node_modules/node-3scale-cli/lib/swagger.js:88:4)
at /usr/lib/node_modules/node-3scale-cli/lib/swagger.js:36:11
The following excerpt of a valid Swagger spec fails when creating the mapping rule:
paths:
/coffees/{id}:
get:
tags:
- "CoffeeObject"
description: ""
operationId: "getCoffeeObject"
consumes:
- "application/json"
produces:
- "application/json"
parameters:
- name: "user_key"
in: "query"
description: ""
required: false
type: "string"
responses:
200:
description: ""
schema:
$ref: "#/definitions/Coffee"
parameters:
- name: "id"
in: "path"
description: ""
required: true
type: "string"
The second parameter declaration is defined as a direct child of the path
item which results in the following error:
ERROR encountered on creating Mapping rule: {"http_method":["is not included in the list"]}
On the output of the import
command you can see that the method is created in 3scale with the wrong HTTP
verb:
Method _coffees__id__PARAMETERS with system_name _coffees__id__PARAMETERS created on 3scale.
Once the parameters
object is moved inside the operation
item the tool is able to import the swagger spec successfully.
cc @picsoung
Ask for tenant_name
Ask for wildcard_domain
and generate API url for it
Error when importing swagger doc for Research API (https://onega-services.wkgadev.net/api-docs/research)
3scale-cli import swagger -f research.swagger.json -s 2555417754871
[ 3scale-cli ] ERROR: Swagger schema validation failed.
Array items are not unique (indexes 2 and 40) at #/tags
JSON_OBJECT_VALIDATION_FAILED
This section is showing up twice under tags:
{"name":"Search","description":"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."}
Entering '3scale-cli services create --serviceName mytest', you get a feedback message 'Service with name mytest created. However the actual name of the service created is something like 'mytestXX' where XX is a random number. The reason for this can be seen directly in the source file 'services.js', line 11 that reads:
"var n = name+Math.floor((Math.random() * 50) + 10)".
When the base path is just a slash (like in the attached definition) instead of removing it, the cli add that to the endpoint, resulting in invalid ones (like //image).
https://app.box.com/s/5p9dr7rua19ebam1cvas0hmchcgtdul8
when installing as:
sudo npm install -g node-3scale-cli
I'm seeing this error:
npm ERR! Darwin 14.3.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "node-3scale-cli"
npm ERR! node v0.12.6
npm ERR! npm v2.11.2
npm ERR! code ETARGET
npm ERR! notarget No compatible version found: raml-1-parser@'*'
npm ERR! notarget Valid install targets:
npm ERR! notarget ["0.1.0-beta","0.1.0-beta.0","0.1.0-beta.1","0.1.0-beta.2","0.1.0-beta.3","0.1.0-beta.5","0.1.0-beta.6"]
npm ERR! notarget
npm ERR! notarget This is most likely not a problem with npm itself.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'node-3scale-cli'
npm ERR! notarget
Any suggestions?
To reproduce the issue try to create a limit setting the value different 1, for instance:
3scale-cli limits create --service 6 --appplan 13 --metric 14 --period week --unit 0
I thought the parameter value is missed in command-limits.js or it's using "unit" parameter instead. Also it seems the place where is set to 1 is: file limits.js file 17
Just installed 3scale-cli on Ubuntu 16.04. Ran 3scale-cli config and got the following error. Bug?
$ 3scale-cli config
/usr/local/lib/node_modules/node-3scale-cli/node_modules/delay-promise/index.js:11
function creator(...args) {
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/usr/local/lib/node_modules/node-3scale-cli/lib/swagger.js:6:17)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
here is the command:
3scale-cli activedocs create -f cortica.json
here is the error:
ERROR encountered: undefined
(node:32607) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Server responded with status code 422 undefined
and the swagger is here:
https://app.box.com/s/5p9dr7rua19ebam1cvas0hmchcgtdul8
3scale-cli import <spec_type> -f /path/to/apidefinition -s SERVICE_ID
The -f argument could accept a url to the file, eg:
3scale-cli import <spec_type> -f http://someurl.com/api/apidefinition.json -s SERVICE_ID
When importing a spec, create mapping rules for each path/method and link them to the methods (which are already created by the tool).
As for #33 we will now use access token to identify to 3scale API, docs needs to be updated to relay this change.
At the moment we are just giving a prettier version of the JSON response from the API
enhancement: a table
Trying to use 3scale-cli but fails at configuration.
C:> 3scale-cli config
[ 3scale-cli ] Please answer the following questions to configure 3scale cli.
? 3scale access token 015e77038cccbxxxxxxxxxxxxxxxxxxxxxxxxxxxxxad8f2d0854f352
? 3scale id myaccount
? 3scale wildcard domain 3scale.net
[3scale-cli] ERROR encountered: Your credentials are invalid. Check them and try again.
The access token have read&write to Billing API, Account Management API, and Analytics API
I have also tried with another access token (that I am using for gateway and getting config) - same fault.
Any idea what could be wrong?
When a service is created using the cli, it assumes that the gateway inbuilt in the SaaS will be used.
One cannot change this to self-managed gateway.
The cli should probably be parametrized to accept user input on what gateway to choose: Saas inbuilt or self-managed. The corresponding management api does provide a 'deployment' option parameter.
For active docs to show up in an API catalog, we need the service's systemname to be the same as the apidocs systemname.
Currently the systemname for activedocs is randomly generated by the cli and so one has to manually re-create active docs if not the same as the service's systemname.
Request: make systemname a user-defined parameter for 'create activedocs' command
Many 3scale On-Premises test installations use self-signed certificates. The CLI currently fails as the API calls aren't configured to allow insecure traffic.
Adding this allows them:
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
Request to be able to pass in a flag that sets this in the code.
It looks like there is some synchronization issue between the tags of the released versions here in GitHub and in https://www.npmjs.com/package/node-3scale-cli.
Namely, I think that it would be great to:
While importing RAML automatically generates an application plan, swagger import doesn't and using the relative argument '-a' doesn't help
being able to define the service name upon creation from swagger definition instead of using a random name
When trying to execute the following:
3scale-cli import swagger -f json_vcc.json
I received the following error:```
[ 3scale-cli ] Loading Profiles API37 swagger definition.
[ 3scale-cli ] Service with id 2555417747254 created on 3scale
[ 3scale-cli ] Hits metric with id 2555418049462 found on 3scale
[ 3scale-cli ] Method ndefined_about_assembly_version_GET with system_name ndefined_about_assembly_version_GET created on 3scale.
[ 3scale-cli ] Method ndefined_self_GET with system_name ndefined_self_GET created on 3scale.
[ 3scale-cli ] Method ndefined_self_PUT with system_name ndefined_self_PUT created on 3scale.
[ 3scale-cli ] Method ndefined_settings_market_GET with system_name ndefined_settings_market_GET created on 3scale.
[ 3scale-cli ] Method ndefined_settings_fields_GET with system_name ndefined_settings_fields_GET created on 3scale.
[3scale-cli] ERROR encountered on creating Mapping rule: undefined
/usr/lib/node_modules/node-3scale-cli/node_modules/q/q.js:155
throw e;
^
Error: Server responded with status code 422 undefined
at /usr/lib/node_modules/node-3scale-cli/lib/mappingrules.js:29:13
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
From previous event:
at createMappingRulePromise (/usr/lib/node_modules/node-3scale-cli/lib/swagger.js:131:116)
at /usr/lib/node_modules/node-3scale-cli/node_modules/delay-promise/index.js:15:18
at delay.then (/usr/lib/node_modules/node-3scale-cli/node_modules/delay-promise/index.js:8:33)
From previous event:
at threescale_waterfall (/usr/lib/node_modules/node-3scale-cli/lib/swagger.js:92:4)
at /usr/lib/node_modules/node-3scale-cli/lib/swagger.js:40:11
the swagger definition is attached.
[swagger.json.txt](https://github.com/3scale/3scale-cli/files/1207820/swagger.json.txt)
Delete default mapping rules /
otherwise it counts "twice"
3scale-cli import from swagger creates a system name say 'Customer30'.
However 3scale-cli activedocs create, creates a system name that is different say 'Customer59'.
These system names, i believe, have to be the same for the Developer portal catalog to work.
Can this be fixed please so that activedocs asks for userinput on systemname- if there is an existing system name to use.
Thanks!
Review commands
Update with latest commands added (e.g. activedocs)
Add screenshots where necessary
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.