akamai / cli-eaa

CLI for Enterprise Application Access (EAA)
https://www.akamai.com/us/en/products/security/enterprise-application-access.jsp
Apache License 2.0
24 stars 7 forks source link

Create or Modify Application using Akamai Cli #8

Closed rahul8172q closed 1 year ago

rahul8172q commented 3 years ago

I am new to API stuff. I am trying to create an automated call to create an Applicaiton with some set parameters and just pass Name , connector and destination seperately while making the call.

I saw with POSTMAN, there is a way bit cna anyone help with CLI, is tere any options.

rahul8172q commented 3 years ago

Any help here ??

bitonio commented 3 years ago

Hi there,

Sorry for the long delay. You can do that with the cli as well, although there is a learning curve. The best way is to create a app using the UI and once you're satisfy you can dump it as a JSON file, example:

$ akamai eaa app app://mD_Pw1XASpyVJc2JwgICTg > ~/eaa_app_datascience_v3.json

From there you can modify the JSON file with the option you like (new CNAME, app name etc...) with the command akamai eaa app - create it will read the new app definition as JSON from stdin.

$ cat mynewapp.json | akamai eaa app - create

JSON file can contain some Jinja code if you like to use some variables, loop etc...

I provided some example in the 0.2.6 release notes: https://github.com/akamai/cli-eaa/releases/tag/0.2.6

You might need to repeat this process for different app type (web vs. rdp vs. client/tunnel).

I hope that helps

rahul8172q commented 3 years ago

Thanks a lot for your help. I get you point . I am new to this so need a bit more help.

I created the app from UI. Now I need to build a template and fix the connector, Access and Advanced settings . This one I will use to create an app. and Secondly. I want to use the same template to add or modify host and ports of the app.

As I said, I created the app and exported this onto json. Can you help me with what can I do next from below:

$ cat mynewapp.json.j2 | akamai eaa app - create -- I ran the same, haven't. hanged anything but got an error.

(venv) rmisra@C02DDKNMMD6M AkamaiOPEN-edgegrid-python % cat mynewapp.json.j2 | akamai eaa -v app - create cat: mynewapp.json.j2: No such file or directory 2021-10-14 16:39:46,979 root I Initialized with base_url https://akab-vjvrxfqmio6nvhsu-pcl6upso5meugshk.luna.akamaiapis.net/crux/v1/ 2021-10-14 16:39:46,980 root E cli-eaa general exception Traceback (most recent call last): File "/Users/rmisra/.akamai-cli/src/cli-eaa/bin/akamai-eaa", line 185, in a.process_command() File "/Users/rmisra/.akamai-cli/src/cli-eaa/libeaa/application.py", line 107, in process_command self.create(new_config) File "/Users/rmisra/.akamai-cli/src/cli-eaa/libeaa/application.py", line 266, in create app_config = json.loads(self.parse_template(raw_app_config)) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/json/init.py", line 357, in loads return _default_decoder.decode(s) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Please bear with me, I am a novice on this stuff.

bitonio commented 3 years ago

Let's follow up by email it will be easier. I had some idea about putting together some dedicated documentation around this topic, you give me a good opportunity here.

W.r.t the error, the cat mynewapp.json.j2 returns an error (very first line, easy to miss)

cat: mynewapp.json.j2: No such file or directory

Then cli-eaa try to read the input and find nothing, I will add a basic test to have a better error message/handling.

bitonio commented 1 year ago

Solved over email.