Spaces:
Running
on
Zero
Running
on
Zero
File size: 1,395 Bytes
3d979b2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
class PlantUML {
generateFlowDiagram() {
var flowDiagram = '@startuml\n';
flowDiagram += 'participant Line as "Line"\n';
flowDiagram += 'participant Script as "Google Apps Script"\n';
flowDiagram += 'participant Drive as "Google Drive"\n';
flowDiagram += 'participant S3 as "Amazon S3"\n';
flowDiagram += 'Line->>Script: doPost\n';
flowDiagram += 'Script->>Drive: save image\n';
flowDiagram += 'Script->>S3: upload image\n';
flowDiagram += '@enduml';
var plantUMLService = getPlantUMLService();
var diagramUrl = plantUMLService.getDiagramUrl(flowDiagram);
var diagramImage = UrlFetchApp.fetch(diagramUrl).getBlob();
var driveFile = DriveApp.createFile(diagramImage);
}
getPlantUMLService() {
var service = OAuth2.createService('plantuml')
.setAuthorizationBaseUrl('https://plantuml.com/')
.setTokenUrl('https://plantuml.com/')
.setClientId('your_client_id')
.setClientSecret('your_client_secret')
.setCallbackFunction('authCallback')
.setPropertyStore(PropertiesService.getUserProperties());
return service;
}
authCallback(request) {
var service = getService();
var authorized = service.handleCallback(request);
if (authorized) {
return HtmlService.createHtmlOutput('Authorized');
} else {
return HtmlService.createHtmlOutput('Access denied');
}
}
} |