133 lines
4.7 KiB
Markdown
133 lines
4.7 KiB
Markdown
# Google API communication
|
|
|
|
Sluzba poskytuje obecnou komunikacni vrstvu pro Google API. Neobsahuje secrets ve zdrojovem kodu a pro verejne routovani pouziva `ROOT_PATH`, aby Swagger/OpenAPI fungoval za AppFactory prefixem `/apps/<app-id>`.
|
|
|
|
## Discovery
|
|
|
|
- `GET /google/discovery/apis` vraci seznam Google API dostupnych pres Google Discovery service.
|
|
- `GET /google/discovery/apis/{api}/{version}/rest` vraci REST discovery dokument konkretniho API, napr. `drive/v3`.
|
|
|
|
Discovery endpointy slouzi k dohledani dostupnych resource, metod, schema a OAuth scope pro konkretni Google API.
|
|
|
|
## OAuth
|
|
|
|
- `POST /google/oauth/token` podporuje `authorization_code` a `refresh_token` grant.
|
|
- `POST /google/oauth/service-account-token` podporuje service account JWT bearer flow.
|
|
- `POST /google/oauth/revoke` revokuje token.
|
|
- `GET /google/oauth/tokeninfo` vraci informace o access tokenu nebo ID tokenu.
|
|
|
|
OAuth client a service account hodnoty je vhodne predavat pres environment variables:
|
|
|
|
- `GOOGLE_CLIENT_ID`
|
|
- `GOOGLE_CLIENT_SECRET`
|
|
- `GOOGLE_SERVICE_ACCOUNT_EMAIL`
|
|
- `GOOGLE_PRIVATE_KEY`
|
|
- `GOOGLE_SCOPES`
|
|
|
|
## Obecne REST volani
|
|
|
|
`POST /google/request` je genericka proxy pro Google REST API. Request obsahuje HTTP metodu, cilovou Google URL nebo kombinaci `baseUrl` a `path`, volitelne query parametry, body a autorizaci.
|
|
|
|
Priklad volani Google Drive:
|
|
|
|
```json
|
|
{
|
|
"method": "GET",
|
|
"baseUrl": "https://www.googleapis.com",
|
|
"path": "/drive/v3/files",
|
|
"query": {
|
|
"pageSize": 10
|
|
},
|
|
"accessTokenEnv": "GOOGLE_ACCESS_TOKEN"
|
|
}
|
|
```
|
|
|
|
Z bezpecnostnich duvodu jsou povolene jen HTTPS URL na Google domenach. Requesty na jine hosty sluzba odmita.
|
|
|
|
## Konkretni produktove endpointy
|
|
|
|
Krome obecne proxy jsou dostupne konkretni wrappery nad nejbeznejsimi Google API:
|
|
|
|
### Calendar
|
|
|
|
- `GET /google/calendar/calendars`
|
|
- `POST /google/calendar/calendars`
|
|
- `GET /google/calendar/calendars/{calendarId}`
|
|
- `PATCH /google/calendar/calendars/{calendarId}`
|
|
- `DELETE /google/calendar/calendars/{calendarId}`
|
|
- `GET /google/calendar/calendars/{calendarId}/events`
|
|
- `POST /google/calendar/calendars/{calendarId}/events`
|
|
- `GET /google/calendar/calendars/{calendarId}/events/{eventId}`
|
|
- `PATCH /google/calendar/calendars/{calendarId}/events/{eventId}`
|
|
- `DELETE /google/calendar/calendars/{calendarId}/events/{eventId}`
|
|
- `POST /google/calendar/calendars/{calendarId}/events/{eventId}/move`
|
|
|
|
### Sheets
|
|
|
|
- `POST /google/sheets/spreadsheets`
|
|
- `GET /google/sheets/spreadsheets/{spreadsheetId}`
|
|
- `POST /google/sheets/spreadsheets/{spreadsheetId}/batch-update`
|
|
- `GET /google/sheets/spreadsheets/{spreadsheetId}/values?range=Sheet1!A1:B10`
|
|
- `PUT /google/sheets/spreadsheets/{spreadsheetId}/values?range=Sheet1!A1`
|
|
- `POST /google/sheets/spreadsheets/{spreadsheetId}/values/append?range=Sheet1!A1`
|
|
- `POST /google/sheets/spreadsheets/{spreadsheetId}/values/batch-update`
|
|
- `POST /google/sheets/spreadsheets/{spreadsheetId}/values/batch-clear`
|
|
|
|
### Drive
|
|
|
|
- `GET /google/drive/files`
|
|
- `POST /google/drive/files`
|
|
- `GET /google/drive/files/{fileId}`
|
|
- `PATCH /google/drive/files/{fileId}`
|
|
- `DELETE /google/drive/files/{fileId}`
|
|
- `GET /google/drive/files/{fileId}/export?mimeType=application/pdf`
|
|
- `GET /google/drive/files/{fileId}/permissions`
|
|
- `POST /google/drive/files/{fileId}/permissions`
|
|
- `DELETE /google/drive/files/{fileId}/permissions/{permissionId}`
|
|
|
|
### Gmail
|
|
|
|
- `GET /google/gmail/profile`
|
|
- `GET /google/gmail/messages`
|
|
- `GET /google/gmail/messages/{messageId}`
|
|
- `POST /google/gmail/messages/send`
|
|
- `GET /google/gmail/labels`
|
|
- `POST /google/gmail/labels`
|
|
|
|
### Docs, Slides a Forms
|
|
|
|
- `POST /google/docs/documents`
|
|
- `GET /google/docs/documents/{documentId}`
|
|
- `POST /google/docs/documents/{documentId}/batch-update`
|
|
- `POST /google/slides/presentations`
|
|
- `GET /google/slides/presentations/{presentationId}`
|
|
- `POST /google/slides/presentations/{presentationId}/batch-update`
|
|
- `POST /google/forms/forms`
|
|
- `GET /google/forms/forms/{formId}`
|
|
- `POST /google/forms/forms/{formId}/batch-update`
|
|
- `GET /google/forms/forms/{formId}/responses`
|
|
|
|
### People a Tasks
|
|
|
|
- `GET /google/people/connections`
|
|
- `GET /google/people/{resourceName}`
|
|
- `POST /google/people/contacts`
|
|
- `PATCH /google/people/{resourceName}`
|
|
- `DELETE /google/people/{resourceName}`
|
|
- `GET /google/tasks/lists`
|
|
- `POST /google/tasks/lists`
|
|
- `GET /google/tasks/lists/{tasklistId}/tasks`
|
|
- `POST /google/tasks/lists/{tasklistId}/tasks`
|
|
- `PATCH /google/tasks/lists/{tasklistId}/tasks/{taskId}`
|
|
- `DELETE /google/tasks/lists/{tasklistId}/tasks/{taskId}`
|
|
|
|
## AppFactory overeni
|
|
|
|
Po deploy over:
|
|
|
|
- `GET /apps/google-service/health`
|
|
- `GET /apps/google-service/docs`
|
|
- `GET /apps/google-service/openapi.json`
|
|
|
|
OpenAPI dokument musi obsahovat `servers[0].url` s hodnotou `ROOT_PATH`, napr. `/apps/google-service`, aby Swagger UI volalo endpointy pres verejnou proxy cestu.
|