From ed5c58e10e87e647a919a143fc6abe90199778bc Mon Sep 17 00:00:00 2001 From: Saad Jutt Date: Mon, 28 Feb 2022 23:39:03 +0500 Subject: [PATCH] chore: added restclient sample requests --- restClient/auth.rest | 22 +++++++++++++ restClient/drive.rest | 45 +++++++++++++++++++++++++++ routes.rest => restClient/routes.rest | 37 +++++++++++++++++++++- restClient/sample.sas | 1 + restClient/session.rest | 2 ++ restClient/users.rest | 10 ++++++ 6 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 restClient/auth.rest create mode 100644 restClient/drive.rest rename routes.rest => restClient/routes.rest (62%) create mode 100644 restClient/sample.sas create mode 100644 restClient/session.rest create mode 100644 restClient/users.rest diff --git a/restClient/auth.rest b/restClient/auth.rest new file mode 100644 index 0000000..6eed756 --- /dev/null +++ b/restClient/auth.rest @@ -0,0 +1,22 @@ +### Get Auth Code +POST http://localhost:5000/SASjsApi/auth/authorize +Content-Type: application/json + +{ + "username": "secretuser", + "password": "secretpassword", + "client_id": "clientID1" +} + +### Exchange AuthCode with Access/Refresh Tokens +POST http://localhost:5000/SASjsApi/auth/token +Content-Type: application/json + +{ + "client_id": "clientID1", + "client_secret": "clientID1secret", + "code": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRfaWQiOiJjbGllbnRJRDEiLCJ1c2VybmFtZSI6InVzZXJuYW1lMSIsImlzYWRtaW4iOmZhbHNlLCJpc2FjdGl2ZSI6dHJ1ZSwiaWF0IjoxNjM1ODA0MDYxLCJleHAiOjE2MzU4MDQwOTF9.jV7DpBWG7XAGODs22zAW_kWOqVLZvOxmmYJGpSNQ-KM" +} + +### Perform logout to deactivate access token instantly +DELETE http://localhost:5000/SASjsApi/auth/logout diff --git a/restClient/drive.rest b/restClient/drive.rest new file mode 100644 index 0000000..75315f1 --- /dev/null +++ b/restClient/drive.rest @@ -0,0 +1,45 @@ +### +POST http://localhost:5000/SASjsApi/drive/deploy +Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRfaWQiOiJjbGllbnRJRDEiLCJ1c2VybmFtZSI6InVzZXJuYW1lMSIsImlzYWRtaW4iOmZhbHNlLCJpc2FjdGl2ZSI6dHJ1ZSwiaWF0IjoxNjM1ODA0MDc2LCJleHAiOjE2MzU4OTA0NzZ9.Cx1F54ILgAUtnkit0Wg1K1YVO2RdNjOnTKdPhUtDm5I + +### multipart upload to sas server file +POST http://localhost:5000/SASjsApi/drive/file +Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW + +------WebKitFormBoundary7MA4YWxkTrZu0gW +Content-Disposition: form-data; name="filePath" + +/saad/files/new.sas +------WebKitFormBoundary7MA4YWxkTrZu0gW +Content-Disposition: form-data; name="file"; filename="sample_new.sas" +Content-Type: application/octet-stream + +< ./sample.sas +------WebKitFormBoundary7MA4YWxkTrZu0gW-- + +### multipart upload to sas server file text +POST http://localhost:5000/SASjsApi/drive/file +Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW + +------WebKitFormBoundary7MA4YWxkTrZu0gW \n +Content-Disposition: form-data; name="filePath" + +/saad/files/new2.sas +------WebKitFormBoundary7MA4YWxkTrZu0gW +Content-Disposition: form-data; name="file"; filename="sample_new.sas" +Content-Type: text/plain + +SOME CONTENTS OF SAS FILE IN REQUEST + +------WebKitFormBoundary7MA4YWxkTrZu0gW-- + + +Users + "username": "username1", + "password": "some password", + + "username": "username2", + "password": "some password", +Admins + "username": "secretuser", + "password": "secretpassword", \ No newline at end of file diff --git a/routes.rest b/restClient/routes.rest similarity index 62% rename from routes.rest rename to restClient/routes.rest index 91d8954..bfae700 100644 --- a/routes.rest +++ b/restClient/routes.rest @@ -23,7 +23,7 @@ Content-Type: application/json "client_secret": "newClientSecret" } ### -POST https://sas.analytium.co.uk:5002/SASjsApi/auth/authorize +POST http://localhost:5000/SASjsApi/auth/authorize Content-Type: application/json { @@ -45,6 +45,41 @@ Content-Type: application/json ### DELETE http://localhost:5000/SASjsApi/auth/logout +### +GET http://localhost:5000/SASjsApi/session + + +### multipart upload to sas server file +POST http://localhost:5000/SASjsApi/drive/file +Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW + +------WebKitFormBoundary7MA4YWxkTrZu0gW +Content-Disposition: form-data; name="filePath" + +/saad/files/new.sas +------WebKitFormBoundary7MA4YWxkTrZu0gW +Content-Disposition: form-data; name="file"; filename="sample_new.sas" +Content-Type: application/octet-stream + +< ./sample.sas +------WebKitFormBoundary7MA4YWxkTrZu0gW-- + +### multipart upload to sas server file text +POST http://localhost:5000/SASjsApi/drive/file +Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW + +------WebKitFormBoundary7MA4YWxkTrZu0gW \n +Content-Disposition: form-data; name="filePath" + +/saad/files/new2.sas +------WebKitFormBoundary7MA4YWxkTrZu0gW +Content-Disposition: form-data; name="file"; filename="sample_new.sas" +Content-Type: text/plain + +SOME CONTENTS OF SAS FILE IN REQUEST + +------WebKitFormBoundary7MA4YWxkTrZu0gW-- + Users "username": "username1", diff --git a/restClient/sample.sas b/restClient/sample.sas new file mode 100644 index 0000000..8556487 --- /dev/null +++ b/restClient/sample.sas @@ -0,0 +1 @@ +some code of sas \ No newline at end of file diff --git a/restClient/session.rest b/restClient/session.rest new file mode 100644 index 0000000..31b96fc --- /dev/null +++ b/restClient/session.rest @@ -0,0 +1,2 @@ +### Get current user's info via access token +GET http://localhost:5000/SASjsApi/session diff --git a/restClient/users.rest b/restClient/users.rest new file mode 100644 index 0000000..8e7d51e --- /dev/null +++ b/restClient/users.rest @@ -0,0 +1,10 @@ +### Create User +POST http://localhost:5000/SASjsApi/user +Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRfaWQiOiJjbGllbnRJRDEiLCJ1c2VybmFtZSI6InNlY3JldHVzZXIiLCJpc2FkbWluIjp0cnVlLCJpc2FjdGl2ZSI6dHJ1ZSwiaWF0IjoxNjM1ODAzOTc3LCJleHAiOjE2MzU4OTAzNzd9.f-FLgLwryKvB5XrihdzaGZajO3d5E5OHEEuJI_03GRI +Content-Type: application/json + +{ + "displayname": "User 2", + "username": "username2", + "password": "some password" +}