Création d'un service en Go pour pouvoir m'y connecter via mon portfolio-apple et interagire avec le système de fichier via l'IHM.
wget https://github.com/nicolachoquet06250/file-system-service/releases/download/$(curl https://api.github.com/repos/nicolachoquet06250/file-system-service/releases | jq .[0].name | sed 's/.\(.*\)/\1/' | sed 's/\(.*\)./\1/')/swagger/swagger.yaml
last_version="$(curl https://api.github.com/repos/nicolachoquet06250/file-system-service/releases | jq .[0].name | sed 's/.\(.*\)/\1/' | sed 's/\(.*\)./\1/')" && \
wget -c https://github.com/nicolachoquet06250/file-system-service/releases/download/${last_version}/file-system-service-linux-${last_version}-linux-amd64.tar.gz && \
tar -xf file-system-service-linux-${last_version}-linux-amd64.tar.gz && \
rm file-system-service-linux-${last_version}-linux-amd64.tar.gz
last_version="$(curl https://api.github.com/repos/nicolachoquet06250/file-system-service/releases | jq .[0].name | sed 's/.\(.*\)/\1/' | sed 's/\(.*\)./\1/')" && \
wget -c https://github.com/nicolachoquet06250/file-system-service/releases/download/${last_version}/file-system-service-darwin-${last_version}-darwin-amd64.tar.gz && \
tar -xf file-system-service-darwin-${last_version}-darwin-amd64.tar.gz && \
rm file-system-service-darwin-${last_version}-darwin-amd64.tar.gz
last_version="$(curl https://api.github.com/repos/nicolachoquet06250/file-system-service/releases | jq .[0].name | sed 's/.\(.*\)/\1/' | sed 's/\(.*\)./\1/')" && \
wget -c https://github.com/nicolachoquet06250/file-system-service/releases/download/${last_version}/file-system-service-darwin-${last_version}-darwin-arm64.tar.gz && \
tar -xf file-system-service-darwin-${last_version}-darwin-arm64.tar.gz && \
rm file-system-service-darwin-${last_version}-darwin-arm64.tar.gz
https://github.com/nicolachoquet06250/file-system-service/releases/latest
Click on file-system-service.swagger.yml
Click on file-system-service-windows-{version}-windows-amd64.zip
Generate credentials
sudo file-system-service --generate-credentials [--role <role=readonly>]
flag | type | default value | optional |
---|---|---|---|
generate-credential | boolean |
false |
❌ |
role | enum (readwrite , readonly ) |
readonly |
✔️ |
Update credentials
sudo file-system-service --update-credentials --client_id <client_id> [--role <role=readonly>]
flag | type | default value | optional |
---|---|---|---|
update-credential | boolean |
false |
❌ |
client_id | string |
null |
❌ |
role | enum (readwrite , readonly ) |
readonly |
✔️ |
Show all available roles
sudo file-system-service --show-roles
flag | type | default value | optional |
---|---|---|---|
show-roles | boolean |
false |
❌ |
Show user current role
sudo file-system-service --show-user-role --client_id <client_id>
flag | type | default value | optional |
---|---|---|---|
show-user-role | boolean |
false |
❌ |
client_id | string |
null |
❌ |
Start server
sudo file-system-service [--host <host='127.0.0.1'>] [--port <port=3000>]
flag | type | default value | optional |
---|---|---|---|
host | string |
127.0.0.1 |
✔️ |
post | integer |
3000 |
✔️ |
GET /check-validity
{
"isValid": true
}
POST /auth/get-token
Accept: application/json
Content-Type: application/json
Authorization: Basic {base64(<client_id>:<client_secret>)}
or
POST /auth/get-token?client_id=<client_id>&client_secret=<client_secret>
Accept: application/json
Content-Type: application/json
{
"access_token": "string",
"refresh_token": "string",
"expires_in": "int",
"created_at": "int"
}
{
"code": 400,
"message": "string"
}
{
"code": 500,
"message": "string"
}
PUT /auth/get-token
Accept: application/json
Content-Type: application/json
Refresh-Token: {getted-refresh-token}
{
"access_token": "string",
"refresh_token": "string",
"expires_in": "int",
"created_at": "int"
}
{
"code": 400,
"message": "string"
}
{
"code": 500,
"message": "string"
}
GET /file-system/${path...}
Parameter | Type | Description | Default value |
---|---|---|---|
path |
string |
Optional. The path of the directory you would like open | / |
[
{
"type": "directory",
"path": "/home",
"name": "nchoquet"
},
{
"type": "file",
"path": "/home",
"name": ".bashrc"
},
"..."
]
{
"code": 400,
"message": "an error message"
}
{
"code": 404,
"message": "an error message"
}
{
"code": 403,
"message": "an error message"
}
POST /directory
Accept: application/json
Content-Type: application/json
{
"type": "directory",
"path": "string",
"name": "string"
}
{
"path": "string",
"name": "string"
}
{
"code": 400,
"message": "an error message"
}
{
"code": 404,
"message": "an error message"
}
{
"code": 403,
"message": "an error message"
}
PATCH /directory/{path...}
Accept: application/json
Content-Type: application/json
{
"type": "directory",
"path": "string",
"name": "string"
}
Parameter | Type | Description | Default value |
---|---|---|---|
path |
string |
Optional. The path of the directory you would like open | / |
{
"path": "string",
"name": "string"
}
{
"code": 400,
"message": "an error message"
}
{
"code": 404,
"message": "an error message"
}
{
"code": 403,
"message": "an error message"
}
DELETE /directory/{path...}
Accept: application/json
Parameter | Type | Description | Default value |
---|---|---|---|
path |
string |
Optional. The path of the directory you would like open | / |
{
"status": "success"
}
{
"code": 400,
"message": "an error message"
}
{
"code": 404,
"message": "an error message"
}
{
"code": 403,
"message": "an error message"
}
POST http://localhost:3000/file
Accept: application/json
Content-Type: multipart/form-data; boundary=boundary
--boundary
Content-Disposition: form-data; name="file"
Content-Type: application/json
{
"type": "file"
"path": "/path/to/create",
"name": "file-to-create",
"extension": "your-extension"
}
--boundary
Content-Disposition: form-data; name="content"
Content-Type: text/plain
Ceci est un test
--boundary--
{
"path": "/path/to/create",
"name": "file-to-create",
"extension": "your-extension"
}
{
"code": 400,
"message": "an error message"
}
Parameter | Type | Description | Default value |
---|---|---|---|
path |
string |
Optional. The path of the directory you would like open | / |
{
"code": 403,
"message": "an error message"
}
POST http://localhost:3000/file
Accept: application/json
Content-Type: application/json
{
"type": "file"
"path": "/path/to/create",
"name": "file-to-create",
"extension": "your-extension"
}
{
"path": "/path/to/create",
"name": "file-to-create",
"extension": "your-extension"
}
{
"code": 400,
"message": "an error message"
}
Parameter | Type | Description | Default value |
---|---|---|---|
path |
string |
Optional. The path of the directory you would like open | / |
{
"code": 403,
"message": "an error message"
}
GET /file/${path...}
Accept: application/json
Parameter | Type | Description | Default value |
---|---|---|---|
path |
string |
Optional. The path of the directory you would like open | / |
{
"code": 400,
"message": "an error message"
}
{
"code": 404,
"message": "an error message"
}
{
"code": 403,
"message": "an error message"
}
PATCH /file/{path...}
Accept: application/json
Content-Type: application/json
{
"type": "file",
"path": "/path/to/create",
"name": "file-to-create",
"extension": "your-extension"
}
Parameter | Type | Description | Default value |
---|---|---|---|
path |
string |
Optional. The path of the directory you would like open | / |
{
"path": "/path/to/create",
"name": "file-to-create",
"extension": "your-extension"
}
{
"code": 400,
"message": "an error message"
}
{
"code": 404,
"message": "an error message"
}
{
"code": 403,
"message": "an error message"
}
PUT /file/{path...}
Accept: application/json
Content-Type: text/plain
This is a text for update
the fichier
{
"status": "success"
}
{
"code": 400,
"message": "an error message"
}
{
"code": 404,
"message": "an error message"
}
{
"code": 403,
"message": "an error message"
}
DELETE /file/{path...}
Accept: application/json
{
"status": "success"
}
{
"code": 400,
"message": "an error message"
}
{
"code": 404,
"message": "an error message"
}
{
"code": 403,
"message": "an error message"
}