/** * Returns a {@link DbxClientV2} that performs requests against Dropbox API * user endpoints as the given team member. * * <p> This method performs no validation of the team member ID. </p> * * @param memberId Team member ID of member in this client's team, never * {@code null}. * * @return Dropbox client that issues requests to user endpoints as the * given team member * * @throws IllegalArgumentException If {@code memberId} is {@code null} */ public DbxClientV2 asMember(String memberId) { if (memberId == null) { throw new IllegalArgumentException("'memberId' should not be null"); } DbxRawClientV2 asMemberClient = new DbxTeamRawClientV2( _client.getRequestConfig(), _client.getHost(), accessToken, _client.getUserId(), memberId, null, null ); return new DbxClientV2(asMemberClient); }
/** * */ GetTemplateResult propertiesTemplateGet(GetTemplateArg arg) throws TemplateErrorException, DbxException { try { return this.client.rpcStyle(this.client.getHost().getApi(), "2/files/properties/template/get", arg, false, GetTemplateArg.Serializer.INSTANCE, GetTemplateResult.Serializer.INSTANCE, TemplateError.Serializer.INSTANCE); } catch (DbxWrappedException ex) { throw new TemplateErrorException("2/files/properties/template/get", ex.getRequestId(), ex.getUserMessage(), (TemplateError) ex.getErrorValue()); } }
/** * Updates an existing Paper doc with the provided content. * * * @return Uploader used to upload the request body and finish request. */ DocsUpdateUploader docsUpdate(PaperDocUpdateArgs arg) throws DbxException { HttpRequestor.Uploader _uploader = this.client.uploadStyle(this.client.getHost().getApi(), "2/paper/docs/update", arg, false, PaperDocUpdateArgs.Serializer.INSTANCE); return new DocsUpdateUploader(_uploader, this.client.getUserId()); }
/** * Exports and downloads Paper doc either as HTML or markdown. * * @param _headers Extra headers to send with request. * * @return Downloader used to download the response body and view the server * response. */ DbxDownloader<PaperDocExportResult> docsDownload(PaperDocExport arg, List<HttpRequestor.Header> _headers) throws DocLookupErrorException, DbxException { try { return this.client.downloadStyle(this.client.getHost().getApi(), "2/paper/docs/download", arg, false, _headers, PaperDocExport.Serializer.INSTANCE, PaperDocExportResult.Serializer.INSTANCE, DocLookupError.Serializer.INSTANCE); } catch (DbxWrappedException ex) { throw new DocLookupErrorException("2/paper/docs/download", ex.getRequestId(), ex.getUserMessage(), (DocLookupError) ex.getErrorValue()); } }
throws DbxWrappedException, DbxException { final byte [] body = writeAsBytes(argSerializer, arg); final List<HttpRequestor.Header> headers = new ArrayList<HttpRequestor.Header>(); if (!noAuth) { addAuthHeaders(headers); return executeRetriable(requestConfig.getMaxRetries(), new RetriableExecution<ResT> () { private String userIdAnon;
addAuthHeaders(headers); headers.add(new HttpRequestor.Header("Dropbox-API-Arg", headerSafeJson(argSerializer, arg))); headers.add(new HttpRequestor.Header("Content-Type", "")); return executeRetriable(requestConfig.getMaxRetries(), new RetriableExecution<DbxDownloader<ResT>>() { private String userIdAnon;
@Override protected void logout() throws BackgroundException { try { ((DropboxCommonsHttpRequestExecutor) client.getRequestConfig().getHttpRequestor()).close(); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } }
public <ArgT> HttpRequestor.Uploader uploadStyle(String host, String path, ArgT arg, boolean noAuth, StoneSerializer<ArgT> argSerializer) throws DbxException { String uri = DbxRequestUtil.buildUri(host, path); List<HttpRequestor.Header> headers = new ArrayList<HttpRequestor.Header>(); if (!noAuth) { addAuthHeaders(headers); } addUserLocaleHeader(headers, requestConfig); addPathRootHeader(headers, this.pathRoot); headers.add(new HttpRequestor.Header("Content-Type", "application/octet-stream")); headers = DbxRequestUtil.addUserAgentHeader(headers, requestConfig, USER_AGENT_ID); headers.add(new HttpRequestor.Header("Dropbox-API-Arg", headerSafeJson(argSerializer, arg))); try { return requestConfig.getHttpRequestor().startPost(uri, headers); } catch (IOException ex) { throw new NetworkIOException(ex); } }
/** * Retries the execution at most a maximum number of times. * * <p> This method is an alternative implementation to {@code DbxRequestUtil.runAndRetry(..)} * that does <b>not</b> retry 500 errors ({@link com.dropbox.core.ServerException}). To maintain * behavior backwards compatibility in v1, we leave the old implementation in {@code * DbxRequestUtil} unchanged. */ private static <T> T executeRetriable(int maxRetries, RetriableExecution<T> execution) throws DbxWrappedException, DbxException { if (maxRetries == 0) { return execution.execute(); } int retries = 0; while (true) { try { return execution.execute(); } catch (RetryException ex) { if (retries < maxRetries) { ++retries; sleepQuietlyWithJitter(ex.getBackoffMillis()); } else { throw ex; } } } }
/** * Download a file from a user's Dropbox. * * @param _headers Extra headers to send with request. * * @return Downloader used to download the response body and view the server * response. */ DbxDownloader<FileMetadata> download(DownloadArg arg, List<HttpRequestor.Header> _headers) throws DownloadErrorException, DbxException { try { return this.client.downloadStyle(this.client.getHost().getContent(), "2/files/download", arg, false, _headers, DownloadArg.Serializer.INSTANCE, FileMetadata.Serializer.INSTANCE, DownloadError.Serializer.INSTANCE); } catch (DbxWrappedException ex) { throw new DownloadErrorException("2/files/download", ex.getRequestId(), ex.getUserMessage(), (DownloadError) ex.getErrorValue()); } }
/** * List all device sessions of a team. Permission : Team member file access. * */ ListMembersDevicesResult devicesListMembersDevices(ListMembersDevicesArg arg) throws ListMembersDevicesErrorException, DbxException { try { return this.client.rpcStyle(this.client.getHost().getApi(), "2/team/devices/list_members_devices", arg, false, ListMembersDevicesArg.Serializer.INSTANCE, ListMembersDevicesResult.Serializer.INSTANCE, ListMembersDevicesError.Serializer.INSTANCE); } catch (DbxWrappedException ex) { throw new ListMembersDevicesErrorException("2/team/devices/list_members_devices", ex.getRequestId(), ex.getUserMessage(), (ListMembersDevicesError) ex.getErrorValue()); } }
/** * Creates a new Paper doc with the provided content. * * * @return Uploader used to upload the request body and finish request. */ DocsCreateUploader docsCreate(PaperDocCreateArgs arg) throws DbxException { HttpRequestor.Uploader _uploader = this.client.uploadStyle(this.client.getHost().getApi(), "2/paper/docs/create", arg, false, PaperDocCreateArgs.Serializer.INSTANCE); return new DocsCreateUploader(_uploader, this.client.getUserId()); }
/** * Returns a {@link DbxClientV2} that performs requests against Dropbox API * user endpoints as the given team admin. * * <p> This method performs no validation of the team admin ID. </p> * * @param adminId Team member ID of the admin in client's team, never * {@code null}. * * @return Dropbox client that issues requests to user endpoints as the * given team Admin. * * @throws IllegalArgumentException If {@code adminId} is {@code null} */ public DbxClientV2 asAdmin(String adminId) { if (adminId == null) { throw new IllegalArgumentException("'adminId' should not be null"); } DbxRawClientV2 asAdminClient = new DbxTeamRawClientV2( _client.getRequestConfig(), _client.getHost(), accessToken, _client.getUserId(), null, adminId, null ); return new DbxClientV2(asAdminClient); }
/** * Download the shared link's file from a user's Dropbox. * * @param _headers Extra headers to send with request. * * @return Downloader used to download the response body and view the server * response. */ DbxDownloader<SharedLinkMetadata> getSharedLinkFile(GetSharedLinkMetadataArg arg, List<HttpRequestor.Header> _headers) throws GetSharedLinkFileErrorException, DbxException { try { return this.client.downloadStyle(this.client.getHost().getContent(), "2/sharing/get_shared_link_file", arg, false, _headers, GetSharedLinkMetadataArg.Serializer.INSTANCE, SharedLinkMetadata.Serializer.INSTANCE, GetSharedLinkFileError.Serializer.INSTANCE); } catch (DbxWrappedException ex) { throw new GetSharedLinkFileErrorException("2/sharing/get_shared_link_file", ex.getRequestId(), ex.getUserMessage(), (GetSharedLinkFileError) ex.getErrorValue()); } }
/** * Revoke a list of linked applications of the team members. * */ RevokeLinkedAppBatchResult linkedAppsRevokeLinkedAppBatch(RevokeLinkedApiAppBatchArg arg) throws RevokeLinkedAppBatchErrorException, DbxException { try { return this.client.rpcStyle(this.client.getHost().getApi(), "2/team/linked_apps/revoke_linked_app_batch", arg, false, RevokeLinkedApiAppBatchArg.Serializer.INSTANCE, RevokeLinkedAppBatchResult.Serializer.INSTANCE, RevokeLinkedAppBatchError.Serializer.INSTANCE); } catch (DbxWrappedException ex) { throw new RevokeLinkedAppBatchErrorException("2/team/linked_apps/revoke_linked_app_batch", ex.getRequestId(), ex.getUserMessage(), (RevokeLinkedAppBatchError) ex.getErrorValue()); } }
/** * Create a new file with the contents provided in the request. Note that * this endpoint is part of the properties API alpha and is slightly * different from {@link DbxUserFilesRequests#upload(String)}. Do not use * this to upload a file larger than 150 MB. Instead, create an upload * session with {@link DbxUserFilesRequests#uploadSessionStart(boolean)}. * * * @return Uploader used to upload the request body and finish request. */ AlphaUploadUploader alphaUpload(CommitInfoWithProperties arg) throws DbxException { HttpRequestor.Uploader _uploader = this.client.uploadStyle(this.client.getHost().getContent(), "2/files/alpha/upload", arg, false, CommitInfoWithProperties.Serializer.INSTANCE); return new AlphaUploadUploader(_uploader, this.client.getUserId()); }
/** * Download a folder from the user's Dropbox, as a zip file. The folder must * be less than 20 GB in size and have fewer than 10,000 total files. The * input cannot be a single file. Any single file must be less than 4GB in * size. * * @param _headers Extra headers to send with request. * * @return Downloader used to download the response body and view the server * response. */ DbxDownloader<DownloadZipResult> downloadZip(DownloadZipArg arg, List<HttpRequestor.Header> _headers) throws DownloadZipErrorException, DbxException { try { return this.client.downloadStyle(this.client.getHost().getContent(), "2/files/download_zip", arg, false, _headers, DownloadZipArg.Serializer.INSTANCE, DownloadZipResult.Serializer.INSTANCE, DownloadZipError.Serializer.INSTANCE); } catch (DbxWrappedException ex) { throw new DownloadZipErrorException("2/files/download_zip", ex.getRequestId(), ex.getUserMessage(), (DownloadZipError) ex.getErrorValue()); } }
/** * Lists members of a group. Permission : Team Information. * */ GroupsMembersListResult groupsMembersList(GroupsMembersListArg arg) throws GroupSelectorErrorException, DbxException { try { return this.client.rpcStyle(this.client.getHost().getApi(), "2/team/groups/members/list", arg, false, GroupsMembersListArg.Serializer.INSTANCE, GroupsMembersListResult.Serializer.INSTANCE, GroupSelectorError.Serializer.INSTANCE); } catch (DbxWrappedException ex) { throw new GroupSelectorErrorException("2/team/groups/members/list", ex.getRequestId(), ex.getUserMessage(), (GroupSelectorError) ex.getErrorValue()); } }
/** * Append more data to an upload session. A single request should not upload * more than 150 MB. The maximum size of a file one can upload to an upload * session is 350 GB. Calls to this endpoint will count as data transport * calls for any Dropbox Business teams with a limit on the number of data * transport calls allowed per month. For more information, see the <a * href="https://www.dropbox.com/developers/reference/data-transport-limit">Data * transport limit page</a>. * * * @return Uploader used to upload the request body and finish request. */ UploadSessionAppendUploader uploadSessionAppend(UploadSessionCursor arg) throws DbxException { HttpRequestor.Uploader _uploader = this.client.uploadStyle(this.client.getHost().getContent(), "2/files/upload_session/append", arg, false, UploadSessionCursor.Serializer.INSTANCE); return new UploadSessionAppendUploader(_uploader, this.client.getUserId()); }
/** * Get a thumbnail for an image. This method currently supports files with * the following file extensions: jpg, jpeg, png, tiff, tif, gif and bmp. * Photos that are larger than 20MB in size won't be converted to a * thumbnail. * * @param _headers Extra headers to send with request. * * @return Downloader used to download the response body and view the server * response. */ DbxDownloader<FileMetadata> getThumbnail(ThumbnailArg arg, List<HttpRequestor.Header> _headers) throws ThumbnailErrorException, DbxException { try { return this.client.downloadStyle(this.client.getHost().getContent(), "2/files/get_thumbnail", arg, false, _headers, ThumbnailArg.Serializer.INSTANCE, FileMetadata.Serializer.INSTANCE, ThumbnailError.Serializer.INSTANCE); } catch (DbxWrappedException ex) { throw new ThumbnailErrorException("2/files/get_thumbnail", ex.getRequestId(), ex.getUserMessage(), (ThumbnailError) ex.getErrorValue()); } }