anaconda / ae5-tools

A command-line tool for scripting AE5 actions
https://www.anaconda.com/enterprise/
BSD 3-Clause "New" or "Revised" License
9 stars 8 forks source link

Add debug logging to requests #198

Closed mcg1969 closed 1 month ago

mcg1969 commented 1 month ago

Adds a response hook to print each and every request to stderr. By doing it this way we minimize changes to the code flow. And by printing it to stderr we should keep testing undisturbed

Example output:

(base) ae5-tools $ ae5 project list
Connecting to user account anaconda-enterprise@anaconda.example.com.
                                                     project
                     resource                        _create  --- s3_ ---    ...
name  owner  editor  _profile  id  created  updated  _status  bucket  path  s...
----  -----  ------  --------  --  -------  -------  -------  ------  ----  ----
(base) ae5-tools $ API_DEBUG=1 ae5 project list
Connecting to user account anaconda-enterprise@anaconda.example.com.
GET https://anaconda.example.com/api/v2/projects 200
                                                     project
                     resource                        _create  --- s3_ ---    ...
name  owner  editor  _profile  id  created  updated  _status  bucket  path  s...
----  -----  ------  --------  --  -------  -------  -------  ------  ----  ----
(base) ae5-tools $ API_DEBUG=1 ae5 logout
Connecting to user account anaconda-enterprise@anaconda.example.com.
GET https://anaconda.example.com/logout 302
-> GET https://anaconda.example.com/auth/realms/AnacondaPlatform/protocol/openid-connect/logout?... 302
-> GET https://anaconda.example.com/ 200
Logged out as anaconda-enterprise@anaconda.example.com.
(base) ae5-tools $ API_DEBUG=1 ae5 project list
Connecting to user account anaconda-enterprise@anaconda.example.com.
Password for anaconda-enterprise@anaconda.example.com: 
GET https://anaconda.example.com/auth/realms/AnacondaPlatform/protocol/openid-connect/auth?... 200
POST https://anaconda.example.com/auth/realms/AnacondaPlatform/login-actions/authenticate?... 302
-> GET https://anaconda.example.com/login?... 302
GET https://anaconda.example.com/ 200
GET https://anaconda.example.com/api/v2/projects 200
                                                     project
                     resource                        _create  --- s3_ ---    ...
name  owner  editor  _profile  id  created  updated  _status  bucket  path  s...
----  -----  ------  --------  --  -------  -------  -------  ------  ----  ----
(base) ae5-tools $ API_DEBUG=1 ae5 logout
Connecting to user account anaconda-enterprise@anaconda.example.com.
GET https://anaconda.example.com/logout 302
-> GET https://anaconda.example.com/auth/realms/AnacondaPlatform/protocol/openid-connect/logout?... 302
-> GET https://anaconda.example.com/ 200
Logged out as anaconda-enterprise@anaconda.example.com.
(base) ae5-tools $ API_DEBUG=1 ae5 project list --impersonate
Connecting to user account anaconda-enterprise@anaconda.example.com.
Connecting to admin account admin@anaconda.example.com.
POST https://anaconda.example.com/auth/realms/master/protocol/openid-connect/token 200
GET https://anaconda.example.com/auth/admin/realms/AnacondaPlatform/users?... 200
GET https://anaconda.example.com/auth/admin/realms/AnacondaPlatform/roles?... 200
GET https://anaconda.example.com/auth/admin/realms/AnacondaPlatform/roles/ae-admin/users?... 200
GET https://anaconda.example.com/auth/admin/realms/AnacondaPlatform/roles/ae-creator/users?... 200
GET https://anaconda.example.com/auth/admin/realms/AnacondaPlatform/roles/ae-deployer/users?... 200
GET https://anaconda.example.com/auth/admin/realms/AnacondaPlatform/roles/ae-uploader/users?... 200
GET https://anaconda.example.com/auth/admin/realms/AnacondaPlatform/roles/ae-userview/users?... 200
GET https://anaconda.example.com/auth/admin/realms/AnacondaPlatform/roles/default-roles-anaconda-platform/users?... 200
GET https://anaconda.example.com/auth/admin/realms/AnacondaPlatform/roles/default-roles-anacondaplatform/users?... 200
GET https://anaconda.example.com/auth/admin/realms/AnacondaPlatform/roles/offline_access/users?... 200
GET https://anaconda.example.com/auth/admin/realms/AnacondaPlatform/roles/uma_authorization/users?... 200
GET https://anaconda.example.com/auth/admin/realms/AnacondaPlatform/groups?... 200
GET https://anaconda.example.com/auth/admin/realms/AnacondaPlatform/groups/41a03f1d-306d-4f19-a819-97a60e10f049/members?... 200
GET https://anaconda.example.com/auth/admin/realms/AnacondaPlatform/groups/a753d069-2cbf-4663-884e-37c8a44ac7d9/members?... 200
GET https://anaconda.example.com/auth/admin/realms/AnacondaPlatform/groups/d0f377c9-6c9c-4140-bfdc-e6557f50dac7/members?... 200
POST https://anaconda.example.com/auth/admin/realms/AnacondaPlatform/users/f605d5ca-409f-45a2-8421-5a2640719dda/impersonation 200
GET https://anaconda.example.com/auth/realms/AnacondaPlatform/protocol/openid-connect/auth?... 302
GET https://anaconda.example.com/login?... 302
GET https://anaconda.example.com/?... 200
GET https://anaconda.example.com/api/v2/projects 200
                                                     project
                     resource                        _create  --- s3_ ---    ...
name  owner  editor  _profile  id  created  updated  _status  bucket  path  s...
----  -----  ------  --------  --  -------  -------  -------  ------  ----  ----