Package com.simplicite.util.tools
Class GoogleAPITool
- java.lang.Object
-
- com.simplicite.util.tools.GoogleAPITool
-
public class GoogleAPITool extends java.lang.Object
Google API toolbox
This class only provides static variables and methods
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
API_KEY_NAME
Google API key system parameter namestatic java.lang.String
DRIVE_REFERENCE_URL
Drive reference URLstatic java.lang.String
PLUS_LOGIN_SCOPE
Google+ scopestatic java.lang.String
PLUS_ME_SCOPE
Google Me scopestatic java.lang.String
SCOPE_CALENDAR
Calendar scopestatic java.lang.String
SCOPE_CALENDAR_READONLY
Calendar scope read onlystatic java.lang.String
SCOPE_DRIVE
Drive scopestatic java.lang.String
SCOPE_DRIVE_APPDATA
Drive scope appdatastatic java.lang.String
SCOPE_DRIVE_FILE
Drive scope filestatic java.lang.String
SCOPE_DRIVE_METADATA
Drive scopestatic java.lang.String
SCOPE_DRIVE_METADATA_READONLY
Drive scopestatic java.lang.String
SCOPE_DRIVE_READONLY
Drive scopestatic java.lang.String
SCOPE_EMAIL
Email scopestatic java.lang.String
SCOPE_GMAIL_ALL
Gmail scopestatic java.lang.String
SCOPE_GMAIL_COMPOSE
Gmail compose scopestatic java.lang.String
SCOPE_GMAIL_INSERT
Gmail insert scopestatic java.lang.String
SCOPE_GMAIL_LABELS
Gmail labels scopestatic java.lang.String
SCOPE_GMAIL_METADATA
Gmail metadata scopestatic java.lang.String
SCOPE_GMAIL_MODIFY
Gmail modify scopestatic java.lang.String
SCOPE_GMAIL_READONLY
Gmail scope read onlystatic java.lang.String
SCOPE_GMAIL_SEND
Gmail send scopestatic java.lang.String
SCOPE_OPENID
OpenIDConnect scopestatic java.lang.String
SCOPE_PROFILE
Profile scopestatic java.lang.String
SCOPE_SHEETS
Sheets scopestatic java.lang.String
SCOPE_SHEETS_READONLY
Sheets scopestatic java.lang.String
SCOPE_YOUTUBE
Youtube account scopestatic java.lang.String
SCOPE_YOUTUBE_READONLY
Youtube account scopestatic java.lang.String
SCOPE_YOUTUBE_UPLOAD
Youtube videos scopestatic java.lang.String
USERINFO_EMAIL_SCOPE
User info email scopestatic java.lang.String
USERINFO_PROFILE_SCOPE
User info profile scope
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static com.google.api.client.auth.oauth2.Credential
authorize(java.lang.String userId, java.lang.String json, java.util.Collection<java.lang.String> scopes)
EXPERIMENTAL Authorizes application to access user's protected data.static com.google.api.services.drive.model.About
driveAbout(com.google.api.services.drive.Drive drive, java.lang.String fields)
Get drive about for specified fieldsstatic com.google.api.services.drive.model.File
driveCreate(com.google.api.services.drive.Drive drive, java.lang.String name, java.lang.String mime, byte[] data)
Create drive file (override)static com.google.api.services.drive.model.File
driveCreate(com.google.api.services.drive.Drive drive, java.lang.String name, java.lang.String mime, byte[] data, java.lang.String folderId, boolean override)
Create drive filestatic com.google.api.services.drive.model.File
driveCreate(com.google.api.services.drive.Drive drive, java.lang.String name, java.lang.String mime, java.io.InputStream in)
Create drive file (override)static com.google.api.services.drive.model.File
driveCreate(com.google.api.services.drive.Drive drive, java.lang.String name, java.lang.String mime, java.io.InputStream in, java.lang.String folderId, boolean override)
Create drive filestatic com.google.api.services.drive.model.File
driveCreateFolder(com.google.api.services.drive.Drive drive, java.lang.String name, java.lang.String parentId, boolean unique)
Create a drive folderstatic com.google.api.services.drive.model.Permission
driveCreatePermissionAnyone(com.google.api.services.drive.Drive drive, java.lang.String fileId, boolean canWrite)
Add file permission to anyonestatic com.google.api.services.drive.model.Permission
driveCreatePermissionAnyone(com.google.api.services.drive.Drive drive, java.lang.String fileId, boolean canWrite, boolean notif)
Add file permission to anyonestatic com.google.api.services.drive.model.Permission
driveCreatePermissionDomain(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String domain, boolean canWrite)
Add file permission to domainstatic com.google.api.services.drive.model.Permission
driveCreatePermissionDomain(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String domain, boolean canWrite, boolean notif)
Add file permission to domainstatic com.google.api.services.drive.model.Permission
driveCreatePermissionGroup(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String email, boolean canWrite)
Add file permission to group (same as user)static com.google.api.services.drive.model.Permission
driveCreatePermissionGroup(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String email, boolean canWrite, boolean notif)
Add file permission to group (same as user)static com.google.api.services.drive.model.Permission
driveCreatePermissionUser(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String email, boolean canWrite)
Add file permission to userstatic com.google.api.services.drive.model.Permission
driveCreatePermissionUser(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String email, boolean canWrite, boolean notif)
Add file permission to userstatic void
driveDelete(com.google.api.services.drive.Drive drive, java.lang.String fileId)
Delete drive filestatic void
driveDeletePermission(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String permissionId)
Remove file permissionstatic com.google.api.services.drive.model.File
driveGet(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String fields)
Get drive filestatic java.util.List<com.google.api.services.drive.model.File>
driveList(com.google.api.services.drive.Drive drive, java.lang.String query)
List drive files from querystatic java.util.List<com.google.api.services.drive.model.File>
driveList(com.google.api.services.drive.Drive drive, java.lang.String query, java.lang.String fields)
List drive files from querystatic java.util.List<com.google.api.services.drive.model.File>
driveListFolder(com.google.api.services.drive.Drive drive, java.lang.String query, java.lang.String folderId)
List drive files in a folderstatic java.util.List<com.google.api.services.drive.model.File>
driveListFolder(com.google.api.services.drive.Drive drive, java.lang.String query, java.lang.String folderId, java.lang.String fields, boolean trashed)
List drive files in a folderstatic java.util.List<com.google.api.services.drive.model.Permission>
driveListPermissions(com.google.api.services.drive.Drive drive, java.lang.String fileId)
List all permissions on filestatic com.google.api.services.drive.model.File
driveMove(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String folderId)
Move a file to folderstatic java.lang.String
driveQueryString(java.lang.String value)
Prepare a string for a drive query.static com.google.api.services.drive.model.About.StorageQuota
driveStorageQuota(com.google.api.services.drive.Drive drive)
Get drive storage quotastatic com.google.api.services.drive.model.File
driveUpdate(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String name, java.lang.String mime, byte[] data)
Update a file in drivestatic com.google.api.services.drive.model.File
driveUpdate(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String name, java.lang.String mime, java.io.InputStream in)
Update a file in drivestatic java.lang.String
getAPIKey(Grant g)
Get API keystatic com.google.api.services.calendar.Calendar
getCalendarService(com.google.api.client.auth.oauth2.Credential credential)
Get Calendar servicestatic com.google.api.services.calendar.Calendar
getCalendarService(Grant g)
Get Calendar servicestatic com.google.api.services.calendar.Calendar
getCalendarService(java.lang.String json)
Get Calendar servicestatic com.google.api.client.auth.oauth2.Credential
getCredential(Grant g)
Get Google credential object from access tokenstatic com.google.api.client.auth.oauth2.Credential
getCredential(java.lang.String accessToken)
Get Google credential object from access tokenstatic com.google.api.client.auth.oauth2.Credential
getCredentialAccount(java.lang.String key)
Get Google credential from service accountstatic java.lang.String
getDriveFileURL(java.lang.String fileId)
URL to open file in drivestatic java.lang.String
getDriveFolderURL(java.lang.String folderId)
URL to open folder in drivestatic com.google.api.services.drive.Drive
getDriveService(com.google.api.client.auth.oauth2.Credential credential)
Get Drive service for the platform namestatic com.google.api.services.drive.Drive
getDriveService(com.google.api.client.auth.oauth2.Credential credential, java.lang.String appName)
Get Drive servicestatic com.google.api.services.drive.Drive
getDriveService(Grant g)
Get Drive servicestatic com.google.api.services.drive.Drive
getDriveService(java.lang.String json)
Get Drive servicestatic java.lang.String
getFontCSS(java.lang.String font)
Deprecated, for removal: This API element is subject to removal in a future version.Use HTMLTool.getGoogleFontCSSstatic java.lang.String
getFontName(Grant g)
Deprecated, for removal: This API element is subject to removal in a future version.Use HTMLTool.getGoogleFontNamestatic java.lang.String
getFontURL(java.lang.String font)
Deprecated, for removal: This API element is subject to removal in a future version.Use HTMLTool.getGoogleFontURLstatic com.google.api.services.gmail.Gmail
getGmailService(com.google.api.client.auth.oauth2.Credential credential)
Get Gmail servicestatic com.google.api.services.gmail.Gmail
getGmailService(Grant g)
Get Gmail servicestatic com.google.api.services.gmail.Gmail
getGmailService(java.lang.String json)
Get Gmail servicestatic java.lang.String
getLoginURL(java.lang.String client_id, java.lang.String redirect_uri, java.lang.String login_hint, java.lang.String scopes, java.lang.String state)
Get the URL of Google OAuth2 login pagestatic com.google.api.services.plus.Plus
getPlusService(com.google.api.client.auth.oauth2.Credential credential)
Deprecated, for removal: This API element is subject to removal in a future version.static com.google.api.services.plus.Plus
getPlusService(Grant g)
Deprecated, for removal: This API element is subject to removal in a future version.static com.google.api.services.plus.Plus
getPlusService(java.lang.String json)
Deprecated, for removal: This API element is subject to removal in a future version.static com.google.api.services.sheets.v4.Sheets
getSheetsService(com.google.api.client.auth.oauth2.Credential credential)
Get Sheets servicestatic com.google.api.services.sheets.v4.Sheets
getSheetsService(Grant g)
Get Sheets servicestatic com.google.api.services.sheets.v4.Sheets
getSheetsService(java.lang.String json)
Get Sheets servicestatic java.lang.String
getToken(Grant g)
Get token (and refresh it if needed)static org.json.JSONObject
getToken(java.lang.String client_id, java.lang.String client_secret, java.lang.String redirect_uri, java.lang.String code)
Get tokenstatic com.google.api.services.translate.Translate
getTranslateService(Grant g)
Get Translate servicestatic com.google.api.services.translate.Translate
getTranslateService(java.lang.String apiKey)
Get Translate servicestatic org.json.JSONObject
getUserData(java.lang.String token)
Get user datastatic com.google.api.services.youtube.YouTube
getYouTubeService(com.google.api.client.auth.oauth2.Credential credential)
Get YouTube servicestatic com.google.api.services.youtube.YouTube
getYouTubeService(Grant g)
Get YouTube servicestatic com.google.api.services.youtube.YouTube
getYouTubeService(java.lang.String json)
Get YouTube servicestatic com.google.api.services.plus.model.Activity
plusGetActivity(com.google.api.services.plus.Plus plus, java.lang.String activityId)
Deprecated, for removal: This API element is subject to removal in a future version.static com.google.api.services.plus.model.Person
plusGetMe(com.google.api.services.plus.Plus plus)
Deprecated, for removal: This API element is subject to removal in a future version.static com.google.api.services.plus.model.Person
plusGetPerson(com.google.api.services.plus.Plus plus, java.lang.String userId)
Deprecated, for removal: This API element is subject to removal in a future version.static java.util.List<com.google.api.services.plus.model.Activity>
plusGetPublicActivities(com.google.api.services.plus.Plus plus, java.lang.String userId)
Deprecated, for removal: This API element is subject to removal in a future version.static java.util.List<com.google.api.services.plus.model.Activity>
plusSearchActivities(com.google.api.services.plus.Plus plus, java.lang.String query, long maxResults)
Deprecated, for removal: This API element is subject to removal in a future version.static java.util.List<com.google.api.services.plus.model.Person>
plusSearchPersons(com.google.api.services.plus.Plus plus, java.lang.String query, long maxResults)
Deprecated, for removal: This API element is subject to removal in a future version.static org.json.JSONObject
refreshToken(java.lang.String clientId, java.lang.String clientSecret, java.lang.String refreshToken)
Refresh tokenstatic boolean
revokeToken(java.lang.String token)
Revoke a Google OAuth2 tokenstatic java.lang.String
translate(com.google.api.services.translate.Translate service, java.lang.String text, java.lang.String source, java.lang.String target)
Traslatestatic java.lang.String[]
translate(Grant g, java.lang.String text, java.lang.String source, java.lang.String target)
Translate text to specified language
-
-
-
Field Detail
-
API_KEY_NAME
public static final java.lang.String API_KEY_NAME
Google API key system parameter name- See Also:
- Constant Field Values
-
SCOPE_PROFILE
public static final java.lang.String SCOPE_PROFILE
Profile scope- See Also:
- Constant Field Values
-
SCOPE_EMAIL
public static final java.lang.String SCOPE_EMAIL
Email scope- See Also:
- Constant Field Values
-
SCOPE_OPENID
public static final java.lang.String SCOPE_OPENID
OpenIDConnect scope- See Also:
- Constant Field Values
-
USERINFO_PROFILE_SCOPE
public static final java.lang.String USERINFO_PROFILE_SCOPE
User info profile scope- See Also:
- Constant Field Values
-
USERINFO_EMAIL_SCOPE
public static final java.lang.String USERINFO_EMAIL_SCOPE
User info email scope- See Also:
- Constant Field Values
-
PLUS_LOGIN_SCOPE
public static final java.lang.String PLUS_LOGIN_SCOPE
Google+ scope- See Also:
- Constant Field Values
-
PLUS_ME_SCOPE
public static final java.lang.String PLUS_ME_SCOPE
Google Me scope- See Also:
- Constant Field Values
-
SCOPE_GMAIL_ALL
public static final java.lang.String SCOPE_GMAIL_ALL
Gmail scope- See Also:
- Constant Field Values
-
SCOPE_GMAIL_READONLY
public static final java.lang.String SCOPE_GMAIL_READONLY
Gmail scope read only- See Also:
- Constant Field Values
-
SCOPE_GMAIL_COMPOSE
public static final java.lang.String SCOPE_GMAIL_COMPOSE
Gmail compose scope- See Also:
- Constant Field Values
-
SCOPE_GMAIL_INSERT
public static final java.lang.String SCOPE_GMAIL_INSERT
Gmail insert scope- See Also:
- Constant Field Values
-
SCOPE_GMAIL_LABELS
public static final java.lang.String SCOPE_GMAIL_LABELS
Gmail labels scope- See Also:
- Constant Field Values
-
SCOPE_GMAIL_METADATA
public static final java.lang.String SCOPE_GMAIL_METADATA
Gmail metadata scope- See Also:
- Constant Field Values
-
SCOPE_GMAIL_MODIFY
public static final java.lang.String SCOPE_GMAIL_MODIFY
Gmail modify scope- See Also:
- Constant Field Values
-
SCOPE_GMAIL_SEND
public static final java.lang.String SCOPE_GMAIL_SEND
Gmail send scope- See Also:
- Constant Field Values
-
SCOPE_CALENDAR
public static final java.lang.String SCOPE_CALENDAR
Calendar scope- See Also:
- Constant Field Values
-
SCOPE_CALENDAR_READONLY
public static final java.lang.String SCOPE_CALENDAR_READONLY
Calendar scope read only- See Also:
- Constant Field Values
-
SCOPE_DRIVE
public static final java.lang.String SCOPE_DRIVE
Drive scope- See Also:
- Constant Field Values
-
SCOPE_DRIVE_FILE
public static final java.lang.String SCOPE_DRIVE_FILE
Drive scope file- See Also:
- Constant Field Values
-
SCOPE_DRIVE_APPDATA
public static final java.lang.String SCOPE_DRIVE_APPDATA
Drive scope appdata- See Also:
- Constant Field Values
-
SCOPE_DRIVE_READONLY
public static final java.lang.String SCOPE_DRIVE_READONLY
Drive scope- See Also:
- Constant Field Values
-
SCOPE_DRIVE_METADATA
public static final java.lang.String SCOPE_DRIVE_METADATA
Drive scope- See Also:
- Constant Field Values
-
SCOPE_DRIVE_METADATA_READONLY
public static final java.lang.String SCOPE_DRIVE_METADATA_READONLY
Drive scope- See Also:
- Constant Field Values
-
SCOPE_SHEETS
public static final java.lang.String SCOPE_SHEETS
Sheets scope- See Also:
- Constant Field Values
-
SCOPE_SHEETS_READONLY
public static final java.lang.String SCOPE_SHEETS_READONLY
Sheets scope- See Also:
- Constant Field Values
-
SCOPE_YOUTUBE
public static final java.lang.String SCOPE_YOUTUBE
Youtube account scope- See Also:
- Constant Field Values
-
SCOPE_YOUTUBE_READONLY
public static final java.lang.String SCOPE_YOUTUBE_READONLY
Youtube account scope- See Also:
- Constant Field Values
-
SCOPE_YOUTUBE_UPLOAD
public static final java.lang.String SCOPE_YOUTUBE_UPLOAD
Youtube videos scope- See Also:
- Constant Field Values
-
DRIVE_REFERENCE_URL
public static final java.lang.String DRIVE_REFERENCE_URL
Drive reference URL- See Also:
- Constant Field Values
-
-
Method Detail
-
getAPIKey
public static java.lang.String getAPIKey(Grant g)
Get API key- Parameters:
g
- Grant
-
getLoginURL
public static java.lang.String getLoginURL(java.lang.String client_id, java.lang.String redirect_uri, java.lang.String login_hint, java.lang.String scopes, java.lang.String state)
Get the URL of Google OAuth2 login page- Parameters:
client_id
- Client IDredirect_uri
- Redirect URIlogin_hint
- Optional login hintscopes
- Optional scopes, see SCOPE_* constants with space as separator (SCOPE_PROFILE, SCOPE_EMAIL and SCOPE_OPENID scopes are set by default)state
- Unique state
-
getToken
public static org.json.JSONObject getToken(java.lang.String client_id, java.lang.String client_secret, java.lang.String redirect_uri, java.lang.String code)
Get token- Parameters:
client_id
- Client IDclient_secret
- Client secretredirect_uri
- Redirect URIcode
- Authorization code
-
getUserData
public static org.json.JSONObject getUserData(java.lang.String token)
Get user data- Parameters:
token
- Access token
-
refreshToken
public static org.json.JSONObject refreshToken(java.lang.String clientId, java.lang.String clientSecret, java.lang.String refreshToken)
Refresh token- Parameters:
clientId
- Client IDclientSecret
- Client secretrefreshToken
- Refresh token
-
revokeToken
public static boolean revokeToken(java.lang.String token)
Revoke a Google OAuth2 token- Parameters:
token
- Access token
-
authorize
public static com.google.api.client.auth.oauth2.Credential authorize(java.lang.String userId, java.lang.String json, java.util.Collection<java.lang.String> scopes) throws java.io.IOException
EXPERIMENTAL Authorizes application to access user's protected data.- Parameters:
json
- Client secret properties (https://developers.google.com/api-client-library/python/guide/aaa_client_secrets)- Throws:
java.io.IOException
-
getFontName
@Deprecated(forRemoval=true, since="4.0") public static java.lang.String getFontName(Grant g)
Deprecated, for removal: This API element is subject to removal in a future version.Use HTMLTool.getGoogleFontName
-
getFontURL
@Deprecated(forRemoval=true, since="4.0") public static java.lang.String getFontURL(java.lang.String font)
Deprecated, for removal: This API element is subject to removal in a future version.Use HTMLTool.getGoogleFontURL
-
getFontCSS
@Deprecated(forRemoval=true, since="4.0") public static java.lang.String getFontCSS(java.lang.String font)
Deprecated, for removal: This API element is subject to removal in a future version.Use HTMLTool.getGoogleFontCSS
-
translate
public static java.lang.String[] translate(Grant g, java.lang.String text, java.lang.String source, java.lang.String target) throws java.lang.Exception
Translate text to specified language- Parameters:
g
- Granttext
- Text to translatesource
- Source languagetarget
- Target language- Returns:
- Translated text
- Throws:
java.lang.Exception
-
getToken
public static java.lang.String getToken(Grant g) throws java.io.IOException
Get token (and refresh it if needed)- Parameters:
g
- Grant- Throws:
java.io.IOException
-
getCredential
public static com.google.api.client.auth.oauth2.Credential getCredential(Grant g) throws java.io.IOException
Get Google credential object from access token- Parameters:
g
- Grant- Throws:
java.io.IOException
-
getCredential
public static com.google.api.client.auth.oauth2.Credential getCredential(java.lang.String accessToken)
Get Google credential object from access token- Parameters:
accessToken
- Access token
-
getCredentialAccount
public static com.google.api.client.auth.oauth2.Credential getCredentialAccount(java.lang.String key)
Get Google credential from service account- Parameters:
key
- JSON key
-
getPlusService
@Deprecated(forRemoval=true, since="5") public static com.google.api.services.plus.Plus getPlusService(com.google.api.client.auth.oauth2.Credential credential)
Deprecated, for removal: This API element is subject to removal in a future version.Get Google+ service- Parameters:
credential
- Credential
-
getPlusService
@Deprecated(forRemoval=true, since="5") public static com.google.api.services.plus.Plus getPlusService(Grant g) throws java.io.IOException
Deprecated, for removal: This API element is subject to removal in a future version.Get Google+ service- Parameters:
g
- Grant- Throws:
java.io.IOException
-
getPlusService
@Deprecated(forRemoval=true, since="5") public static com.google.api.services.plus.Plus getPlusService(java.lang.String json) throws java.io.IOException
Deprecated, for removal: This API element is subject to removal in a future version.Get Google+ service- Parameters:
json
- account JSON key- Throws:
java.io.IOException
-
plusGetPerson
@Deprecated(forRemoval=true, since="5") public static com.google.api.services.plus.model.Person plusGetPerson(com.google.api.services.plus.Plus plus, java.lang.String userId) throws java.io.IOException
Deprecated, for removal: This API element is subject to removal in a future version.Get Google+ person- Parameters:
plus
- Google+ serviceuserId
- User ID- Throws:
java.io.IOException
-
plusGetMe
@Deprecated(forRemoval=true, since="5") public static com.google.api.services.plus.model.Person plusGetMe(com.google.api.services.plus.Plus plus) throws java.io.IOException
Deprecated, for removal: This API element is subject to removal in a future version.Get Google+ "me" person- Parameters:
plus
- Google+ service- Throws:
java.io.IOException
-
plusSearchPersons
@Deprecated(forRemoval=true, since="5") public static java.util.List<com.google.api.services.plus.model.Person> plusSearchPersons(com.google.api.services.plus.Plus plus, java.lang.String query, long maxResults) throws java.io.IOException
Deprecated, for removal: This API element is subject to removal in a future version.Search Google+ persons- Parameters:
plus
- Google+ servicequery
- Full text querymaxResults
- Max results- Throws:
java.io.IOException
-
plusGetActivity
@Deprecated(forRemoval=true, since="5") public static com.google.api.services.plus.model.Activity plusGetActivity(com.google.api.services.plus.Plus plus, java.lang.String activityId) throws java.io.IOException
Deprecated, for removal: This API element is subject to removal in a future version.Get Google+ activity- Parameters:
plus
- Google+ serviceactivityId
- Activity ID- Throws:
java.io.IOException
-
plusGetPublicActivities
@Deprecated(forRemoval=true, since="5") public static java.util.List<com.google.api.services.plus.model.Activity> plusGetPublicActivities(com.google.api.services.plus.Plus plus, java.lang.String userId) throws java.io.IOException
Deprecated, for removal: This API element is subject to removal in a future version.Get Google+ public activities- Parameters:
plus
- Google+ serviceuserId
- User ID- Throws:
java.io.IOException
-
plusSearchActivities
@Deprecated(forRemoval=true, since="5") public static java.util.List<com.google.api.services.plus.model.Activity> plusSearchActivities(com.google.api.services.plus.Plus plus, java.lang.String query, long maxResults) throws java.io.IOException
Deprecated, for removal: This API element is subject to removal in a future version.Search Google+ activities- Parameters:
plus
- Google+ servicequery
- Full text querymaxResults
- Max results- Throws:
java.io.IOException
-
getTranslateService
public static com.google.api.services.translate.Translate getTranslateService(java.lang.String apiKey)
Get Translate service- Parameters:
apiKey
- API key (null means use configured GOOGLE_API_KEY system parameter value)
-
getTranslateService
public static com.google.api.services.translate.Translate getTranslateService(Grant g)
Get Translate service- Parameters:
g
- Grant
-
translate
public static java.lang.String translate(com.google.api.services.translate.Translate service, java.lang.String text, java.lang.String source, java.lang.String target) throws java.io.IOException
Traslate- Parameters:
service
- Translate servicetext
- Text to translatesource
- Source languagetarget
- Target language- Returns:
- Translated text
- Throws:
java.io.IOException
- If translate service is unavailable
-
getCalendarService
public static com.google.api.services.calendar.Calendar getCalendarService(com.google.api.client.auth.oauth2.Credential credential)
Get Calendar service- Parameters:
credential
- Credential
-
getCalendarService
public static com.google.api.services.calendar.Calendar getCalendarService(Grant g) throws java.io.IOException
Get Calendar service- Parameters:
g
- Grant- Throws:
java.io.IOException
-
getCalendarService
public static com.google.api.services.calendar.Calendar getCalendarService(java.lang.String json) throws java.io.IOException
Get Calendar service- Parameters:
json
- acocunt JSON key- Throws:
java.io.IOException
-
getGmailService
public static com.google.api.services.gmail.Gmail getGmailService(com.google.api.client.auth.oauth2.Credential credential)
Get Gmail service- Parameters:
credential
- Credential
-
getGmailService
public static com.google.api.services.gmail.Gmail getGmailService(Grant g) throws java.lang.Exception
Get Gmail service- Parameters:
g
- Grant- Throws:
java.lang.Exception
-
getGmailService
public static com.google.api.services.gmail.Gmail getGmailService(java.lang.String json) throws java.lang.Exception
Get Gmail service- Parameters:
json
- account JSON key- Throws:
java.lang.Exception
-
getDriveService
public static com.google.api.services.drive.Drive getDriveService(com.google.api.client.auth.oauth2.Credential credential)
Get Drive service for the platform name- Parameters:
credential
- Credential
-
getDriveService
public static com.google.api.services.drive.Drive getDriveService(com.google.api.client.auth.oauth2.Credential credential, java.lang.String appName)
Get Drive service- Parameters:
credential
- CredentialappName
- Optional Google application name (default is the platform name)
-
getDriveService
public static com.google.api.services.drive.Drive getDriveService(Grant g) throws java.io.IOException
Get Drive service- Parameters:
g
- Grant- Throws:
java.io.IOException
-
getDriveService
public static com.google.api.services.drive.Drive getDriveService(java.lang.String json) throws java.io.IOException
Get Drive service- Parameters:
json
- account JSON key- Throws:
java.io.IOException
-
getDriveFileURL
public static java.lang.String getDriveFileURL(java.lang.String fileId)
URL to open file in drive
-
getDriveFolderURL
public static java.lang.String getDriveFolderURL(java.lang.String folderId)
URL to open folder in drive
-
driveQueryString
public static java.lang.String driveQueryString(java.lang.String value)
Prepare a string for a drive query. Surround the value with single quotes ' and escape single quotes in queries with \', e.g. 'Valentine\'s Day'.- Parameters:
value
- Value
-
driveAbout
public static com.google.api.services.drive.model.About driveAbout(com.google.api.services.drive.Drive drive, java.lang.String fields) throws java.io.IOException
Get drive about for specified fields- Parameters:
drive
- Drive servicefields
- Fields (e.g. "user, storageQuota", if null defaults to "storageQuota")- Throws:
java.io.IOException
-
driveStorageQuota
public static com.google.api.services.drive.model.About.StorageQuota driveStorageQuota(com.google.api.services.drive.Drive drive) throws java.io.IOException
Get drive storage quota- Parameters:
drive
- Drive service- Throws:
java.io.IOException
-
driveList
public static java.util.List<com.google.api.services.drive.model.File> driveList(com.google.api.services.drive.Drive drive, java.lang.String query) throws java.io.IOException
List drive files from query- Parameters:
drive
- Drive servicequery
- Query string (see https://developers.google.com/drive/api/v3/search-parameters)- Throws:
java.io.IOException
-
driveList
public static java.util.List<com.google.api.services.drive.model.File> driveList(com.google.api.services.drive.Drive drive, java.lang.String query, java.lang.String fields) throws java.io.IOException
List drive files from query- Parameters:
drive
- Drive servicequery
- Query string (see https://developers.google.com/drive/api/v3/search-parameters)fields
- Fields (e.g. "files/id, files/name", if null all fields)- Throws:
java.io.IOException
-
driveListFolder
public static java.util.List<com.google.api.services.drive.model.File> driveListFolder(com.google.api.services.drive.Drive drive, java.lang.String query, java.lang.String folderId) throws java.io.IOException
List drive files in a folder- Parameters:
drive
- Drive servicequery
- Query string (see https://developers.google.com/drive/api/v3/search-parameters)folderId
- Optional parent folder Id (or 'root' or null=anywhere)- Throws:
java.io.IOException
-
driveListFolder
public static java.util.List<com.google.api.services.drive.model.File> driveListFolder(com.google.api.services.drive.Drive drive, java.lang.String query, java.lang.String folderId, java.lang.String fields, boolean trashed) throws java.io.IOException
List drive files in a folder- Parameters:
drive
- Drive servicequery
- Query string (see https://developers.google.com/drive/api/v3/search-parameters)folderId
- Optional parent folder Id (or 'root' or null=anywhere)fields
- Fields (e.g. "files/id, files/name", if null all fields)trashed
- true to search in trash- Throws:
java.io.IOException
-
driveGet
public static com.google.api.services.drive.model.File driveGet(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String fields) throws java.io.IOException
Get drive file- Parameters:
drive
- Drive servicefileId
- File IDfields
- Fields (e.g. "files/id, files/name", if null all fields)- Throws:
java.io.IOException
-
driveCreate
public static com.google.api.services.drive.model.File driveCreate(com.google.api.services.drive.Drive drive, java.lang.String name, java.lang.String mime, java.io.InputStream in) throws java.io.IOException
Create drive file (override)- Parameters:
drive
- Drive servicename
- File namemime
- File MIME typein
- Data input stream- Throws:
java.io.IOException
-
driveCreate
public static com.google.api.services.drive.model.File driveCreate(com.google.api.services.drive.Drive drive, java.lang.String name, java.lang.String mime, byte[] data) throws java.io.IOException
Create drive file (override)- Parameters:
drive
- Drive servicename
- File namemime
- File MIME typedata
- Data- Throws:
java.io.IOException
-
driveCreate
public static com.google.api.services.drive.model.File driveCreate(com.google.api.services.drive.Drive drive, java.lang.String name, java.lang.String mime, byte[] data, java.lang.String folderId, boolean override) throws java.io.IOException
Create drive file- Parameters:
drive
- Drive servicename
- File namemime
- File MIME typedata
- DatafolderId
- Optional parent folder Idoverride
- true to replace existing file (false will create a second file with the same name and new Id)- Throws:
java.io.IOException
-
driveCreate
public static com.google.api.services.drive.model.File driveCreate(com.google.api.services.drive.Drive drive, java.lang.String name, java.lang.String mime, java.io.InputStream in, java.lang.String folderId, boolean override) throws java.io.IOException
Create drive file- Parameters:
drive
- Drive servicename
- File namemime
- File MIME typein
- Data input streamfolderId
- Optional parent folder Idoverride
- true to replace existing file- Throws:
java.io.IOException
-
driveUpdate
public static com.google.api.services.drive.model.File driveUpdate(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String name, java.lang.String mime, byte[] data) throws java.io.IOException
Update a file in drive- Parameters:
drive
- Drive servicefileId
- File Id to updatename
- New namemime
- Optional mime typedata
- File data- Throws:
java.io.IOException
-
driveUpdate
public static com.google.api.services.drive.model.File driveUpdate(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String name, java.lang.String mime, java.io.InputStream in) throws java.io.IOException
Update a file in drive- Parameters:
drive
- Drive servicefileId
- File Id to updatename
- New namemime
- Optional mime typein
- Data inpout stream- Throws:
java.io.IOException
-
driveDelete
public static void driveDelete(com.google.api.services.drive.Drive drive, java.lang.String fileId) throws java.io.IOException
Delete drive file- Parameters:
drive
- Drive servicefileId
- File ID- Throws:
java.io.IOException
-
driveMove
public static com.google.api.services.drive.model.File driveMove(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String folderId) throws java.io.IOException
Move a file to folder- Parameters:
drive
- Drive servicefileId
- File IDfolderId
- Folder Id- Throws:
java.io.IOException
-
driveCreateFolder
public static com.google.api.services.drive.model.File driveCreateFolder(com.google.api.services.drive.Drive drive, java.lang.String name, java.lang.String parentId, boolean unique) throws java.io.IOException
Create a drive folder- Parameters:
drive
- Drive servicename
- Folder nameparentId
- Optional parent folder Id (default = root)unique
- True do get the same folder if already exists- Throws:
java.io.IOException
-
driveListPermissions
public static java.util.List<com.google.api.services.drive.model.Permission> driveListPermissions(com.google.api.services.drive.Drive drive, java.lang.String fileId) throws java.io.IOException
List all permissions on file- Parameters:
drive
- Drive servicefileId
- File or folder Id- Returns:
- Permissions list
- Throws:
java.io.IOException
-
driveCreatePermissionUser
public static com.google.api.services.drive.model.Permission driveCreatePermissionUser(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String email, boolean canWrite) throws java.io.IOException
Add file permission to user- Parameters:
drive
- Drive servicefileId
- File or folder Idemail
- user emailcanWrite
- false for read only- Throws:
java.io.IOException
-
driveCreatePermissionUser
public static com.google.api.services.drive.model.Permission driveCreatePermissionUser(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String email, boolean canWrite, boolean notif) throws java.io.IOException
Add file permission to user- Parameters:
drive
- Drive servicefileId
- File or folder Idemail
- user emailcanWrite
- false for read onlynotif
- Send email notifications?- Throws:
java.io.IOException
-
driveCreatePermissionGroup
public static com.google.api.services.drive.model.Permission driveCreatePermissionGroup(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String email, boolean canWrite) throws java.io.IOException
Add file permission to group (same as user)- Parameters:
drive
- Drive servicefileId
- File or folder Idemail
- group emailcanWrite
- false for read only- Throws:
java.io.IOException
-
driveCreatePermissionGroup
public static com.google.api.services.drive.model.Permission driveCreatePermissionGroup(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String email, boolean canWrite, boolean notif) throws java.io.IOException
Add file permission to group (same as user)- Parameters:
drive
- Drive servicefileId
- File or folder Idemail
- group emailcanWrite
- false for read onlynotif
- Send email notifications?- Throws:
java.io.IOException
-
driveCreatePermissionDomain
public static com.google.api.services.drive.model.Permission driveCreatePermissionDomain(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String domain, boolean canWrite) throws java.io.IOException
Add file permission to domain- Parameters:
drive
- Drive servicefileId
- File or folder Iddomain
- Domain to grant ex mydomain.comcanWrite
- false for read only- Throws:
java.io.IOException
-
driveCreatePermissionDomain
public static com.google.api.services.drive.model.Permission driveCreatePermissionDomain(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String domain, boolean canWrite, boolean notif) throws java.io.IOException
Add file permission to domain- Parameters:
drive
- Drive servicefileId
- File or folder Iddomain
- Domain to grant ex mydomain.comcanWrite
- false for read onlynotif
- Send email notifications?- Throws:
java.io.IOException
-
driveCreatePermissionAnyone
public static com.google.api.services.drive.model.Permission driveCreatePermissionAnyone(com.google.api.services.drive.Drive drive, java.lang.String fileId, boolean canWrite) throws java.io.IOException
Add file permission to anyone- Parameters:
drive
- Drive servicefileId
- File or folder IdcanWrite
- false for read only- Throws:
java.io.IOException
-
driveCreatePermissionAnyone
public static com.google.api.services.drive.model.Permission driveCreatePermissionAnyone(com.google.api.services.drive.Drive drive, java.lang.String fileId, boolean canWrite, boolean notif) throws java.io.IOException
Add file permission to anyone- Parameters:
drive
- Drive servicefileId
- File or folder IdcanWrite
- false for read onlynotif
- Send email notifications?- Throws:
java.io.IOException
-
driveDeletePermission
public static void driveDeletePermission(com.google.api.services.drive.Drive drive, java.lang.String fileId, java.lang.String permissionId) throws java.io.IOException
Remove file permission- Parameters:
drive
- Drive servicefileId
- File or folder IdpermissionId
- Permission Id- Throws:
java.io.IOException
-
getSheetsService
public static com.google.api.services.sheets.v4.Sheets getSheetsService(com.google.api.client.auth.oauth2.Credential credential)
Get Sheets service- Parameters:
credential
- Credential
-
getSheetsService
public static com.google.api.services.sheets.v4.Sheets getSheetsService(Grant g) throws java.lang.Exception
Get Sheets service- Parameters:
g
- Grant- Throws:
java.lang.Exception
-
getSheetsService
public static com.google.api.services.sheets.v4.Sheets getSheetsService(java.lang.String json) throws java.lang.Exception
Get Sheets service- Parameters:
json
- account JSON key- Throws:
java.lang.Exception
-
getYouTubeService
public static com.google.api.services.youtube.YouTube getYouTubeService(com.google.api.client.auth.oauth2.Credential credential)
Get YouTube service- Parameters:
credential
- Credential
-
getYouTubeService
public static com.google.api.services.youtube.YouTube getYouTubeService(Grant g) throws java.io.IOException
Get YouTube service- Parameters:
g
- Grant- Throws:
java.io.IOException
-
getYouTubeService
public static com.google.api.services.youtube.YouTube getYouTubeService(java.lang.String json) throws java.io.IOException
Get YouTube service- Parameters:
json
- account JSON key- Throws:
java.io.IOException
-
-