Skip to content

Commit

Permalink
Merge pull request #475 from vimeo/MPS-1889-Manage-Teams
Browse files Browse the repository at this point in the history
MPS-1889: Manage Teams support
  • Loading branch information
WhosNickDoglio authored Mar 15, 2021
2 parents 9c62bdc + 24a3072 commit 8a5d025
Show file tree
Hide file tree
Showing 10 changed files with 469 additions and 77 deletions.
3 changes: 3 additions & 0 deletions api-core/src/main/java/com/vimeo/networking2/ApiConstants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ object ApiConstants {
const val PARAMETER_ACTIVE = "active"
const val PARAMETER_FOLDER_NAME = NAME
const val PARAMETER_FOLDER_PRIVACY = PRIVACY
const val PARAMETER_PERMISSION_LEVEL = "permission_level"
const val PARAMETER_FOLDER_URI = "folder_uri"
const val PARAMETER_ROLE = "role"

// Generic parameters
const val PARAMETER_GET_PAGE_SIZE = "per_page"
Expand Down
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
mavenCentral()
jcenter()
}
dependencies {
Expand All @@ -13,7 +14,7 @@ buildscript {

plugins {
id "io.gitlab.arturbosch.detekt" version "1.14.2"
id "com.github.ben-manes.versions" version "0.36.0"
id "com.github.ben-manes.versions" version "0.38.0"
}

ext {
Expand All @@ -39,6 +40,7 @@ subprojects {
allprojects {
repositories {
google()
mavenCentral()
jcenter()
}
apply plugin: "com.jfrog.bintray"
Expand Down
4 changes: 4 additions & 0 deletions models/detekt_baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<SmellBaseline>
<ManuallySuppressedIssues></ManuallySuppressedIssues>
<CurrentIssues>
<ID>UndocumentedPublicProperty:AddUserToTeam.kt$AddUserToTeam$/** * If the user is being added as a [TeamRoleType.CONTRIBUTOR] or [TeamRoleType.VIEWER] a URI for the Folder * they can contribute or view also needs to be added. */ @Json(name = "folder_uri") val folderUri: String? = null</ID>
<ID>UndocumentedPublicProperty:AddUserToTeam.kt$AddUserToTeam$/** * The email address for the user being added. */ @Json(name = "email") val email: String</ID>
<ID>UndocumentedPublicProperty:AddUserToTeam.kt$AddUserToTeam$/** * The intended [TeamRoleType] for the user being added. */ @Json(name = "permission_level") val permissionLevel: TeamRoleType</ID>
<ID>UndocumentedPublicProperty:AddVideoToAlbum.kt$AddVideoToAlbum$/** * The URI of the video. */ @Json(name = "uri") val uri: String</ID>
<ID>UndocumentedPublicProperty:AddVideoToAlbum.kt$AddVideoToAlbum$/** * The position of the video. */ @Json(name = "position") val position: Int?</ID>
<ID>UndocumentedPublicProperty:AddVideoToAlbumContainer.kt$AddVideoToAlbumContainer$/** * The video that should be added. */ @Json(name = "video") val video: AddVideoToAlbum</ID>
Expand Down Expand Up @@ -177,6 +180,7 @@
<ID>UndocumentedPublicProperty:Gcs.kt$Gcs$/** * Expected ending byte range for the current upload_link. */ @Internal @Json(name = "end_byte") val endByte: Long? = null</ID>
<ID>UndocumentedPublicProperty:Gcs.kt$Gcs$/** * Expected starting byte size for the current upload_link. */ @Internal @Json(name = "start_byte") val startByte: Long? = null</ID>
<ID>UndocumentedPublicProperty:Gcs.kt$Gcs$/** * Link for uploading file chunk to. */ @Internal @Json(name = "upload_link") val uploadLink: String? = null</ID>
<ID>UndocumentedPublicProperty:GrantFolderPermissionForUser.kt$GrantFolderPermissionForUser$/** * The user URI that will be added to the given Folder. */ @Json(name = "uri") val uri: String</ID>
<ID>UndocumentedPublicProperty:Group.kt$Group$/** * The active picture for this group. */ @Json(name = "pictures") val pictures: PictureCollection? = null</ID>
<ID>UndocumentedPublicProperty:Group.kt$Group$/** * The canonical relative URI of this group. */ @Json(name = "uri") val uri: String? = null</ID>
<ID>UndocumentedPublicProperty:Group.kt$Group$/** * The group's description. */ @Json(name = "description") val description: String? = null</ID>
Expand Down
24 changes: 24 additions & 0 deletions models/src/main/java/com/vimeo/networking2/TeamMembershipList.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.vimeo.networking2

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.vimeo.networking2.common.Pageable

/**
* List of [TeamMemberships][TeamMembership] that can be paged.
*/
@JsonClass(generateAdapter = true)
data class TeamMembershipList(
@Json(name = "total")
override val total: Int? = null,
@Json(name = "page")
override val page: Int? = null,
@Json(name = "per_page")
override val perPage: Int? = null,
@Json(name = "paging")
override val paging: Paging? = null,
@Json(name = "data")
override val data: List<TeamMembership>? = null,
@Json(name = "filtered_total")
override val filteredTotal: Int? = null
) : Pageable<TeamMembership>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.vimeo.networking2.params

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

/**
* Represents a User URI being used to grant permission for a particular folder.
*/
@JsonClass(generateAdapter = true)
data class GrantFolderPermissionForUser(
/**
* The user URI that will be added to the given Folder.
*/
@Json(name = "uri")
val uri: String
)
1 change: 1 addition & 0 deletions models/src/test/java/com/vimeo/networking2/ModelsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class ModelsTest {
TeamBranding::class,
TeamList::class,
TeamMembership::class,
TeamMembershipList::class,
TeamMembershipConnections::class,
TeamOwnerConnection::class,
TextTrack::class,
Expand Down
188 changes: 170 additions & 18 deletions request/src/main/java/com/vimeo/networking2/VimeoApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,11 @@ package com.vimeo.networking2
import com.vimeo.networking2.common.Followable
import com.vimeo.networking2.config.VimeoApiConfiguration
import com.vimeo.networking2.config.RetrofitSetupModule
import com.vimeo.networking2.enums.CommentPrivacyType
import com.vimeo.networking2.enums.ConnectedAppType
import com.vimeo.networking2.enums.EmbedPrivacyType
import com.vimeo.networking2.enums.FolderViewPrivacyType
import com.vimeo.networking2.enums.NotificationType
import com.vimeo.networking2.enums.SlackLanguagePreferenceType
import com.vimeo.networking2.enums.SlackUserPreferenceType
import com.vimeo.networking2.enums.ViewPrivacyType
import com.vimeo.networking2.enums.*
import com.vimeo.networking2.internal.LocalVimeoCallAdapter
import com.vimeo.networking2.internal.MutableVimeoApiClientDelegate
import com.vimeo.networking2.internal.VimeoApiClientImpl
import com.vimeo.networking2.params.BatchPublishToSocialMedia
import com.vimeo.networking2.params.ModifyVideoInAlbumsSpecs
import com.vimeo.networking2.params.ModifyVideosInAlbumSpecs
import com.vimeo.networking2.params.SearchDateType
import com.vimeo.networking2.params.SearchDurationType
import com.vimeo.networking2.params.SearchFacetType
import com.vimeo.networking2.params.SearchFilterType
import com.vimeo.networking2.params.SearchSortDirectionType
import com.vimeo.networking2.params.SearchSortType
import com.vimeo.networking2.params.*
import okhttp3.CacheControl
import okhttp3.Credentials
import java.util.concurrent.Executor
Expand All @@ -70,7 +55,7 @@ import java.util.concurrent.Executor
* val clientInstance = VimeoApiClient.instance()
* ```
*/
@Suppress("ComplexInterface", "LongParameterList")
@Suppress("ComplexInterface", "LongParameterList", "LargeClass")
interface VimeoApiClient {

/**
Expand Down Expand Up @@ -1551,6 +1536,173 @@ interface VimeoApiClient {
callback: VimeoCallback<VideoStatus>
): VimeoRequest

/**
* Fetch a [TeamMembershipList] from the provided endpoint.
*
* @param uri the URI from which content will be requested.
* @param fieldFilter The fields that should be returned by the server in the response, null indicates all should be
* returned.
* @param queryParams Optional map used to refine the response from the API.
* @param cacheControl The optional cache behavior for the request, null indicates that the default cache behavior
* should be used.
* @param callback The callback which will be notified of the request completion.
*
* @return A [VimeoRequest] object to cancel API requests.
*/
fun fetchTeamMembersList(
uri: String,
fieldFilter: String?,
queryParams: Map<String, String>?,
cacheControl: CacheControl?,
callback: VimeoCallback<TeamMembershipList>
): VimeoRequest

/**
* Adds a given user to the current Team.
*
* @param uri the URI from which content will be sent to.
* @param email The email address for the user being added.
* @param permissionLevel The intended [TeamRoleType] for the user being added.
* @param folderUri If the user is being added as a [TeamRoleType.CONTRIBUTOR] or [TeamRoleType.VIEWER] a URI for
* the Folder they can contribute or view also needs to be added.
* @param queryParams Optional map used to refine the response from the API.
* @param callback The callback which will be notified of the request completion.
*
* @return A [VimeoRequest] object to cancel API requests.
*/
fun addUserToTeam(
uri: String,
email: String,
permissionLevel: TeamRoleType,
folderUri: String?,
queryParams: Map<String, String>?,
callback: VimeoCallback<TeamMembership>
): VimeoRequest

/**
* Adds a given user to the current Team.
*
* @param team The [Team] the user is being added to.
* @param email The email address for the user being added.
* @param permissionLevel The intended [TeamRoleType] for the user being added.
* @param folder If the user is being added as a [TeamRoleType.CONTRIBUTOR] or [TeamRoleType.VIEWER] the
* [Folder] they can contribute or view also needs to be added.
* @param queryParams Optional map used to refine the response from the API.
* @param callback The callback which will be notified of the request completion.
*
* @return A [VimeoRequest] object to cancel API requests.
*/
fun addUserToTeam(
team: Team,
email: String,
permissionLevel: TeamRoleType,
folder: Folder?,
queryParams: Map<String, String>?,
callback: VimeoCallback<TeamMembership>
): VimeoRequest

/**
* Removes the provided User from the team.
*
* @param uri the URI from which content will be sent to.
* @param queryParams Optional map used to refine the response from the API.
* @param callback The callback which will be notified of the request completion.
*
* @return A [VimeoRequest] object to cancel API requests.
*/
fun removeUserFromTeam(
uri: String,
queryParams: Map<String, String>?,
callback: VimeoCallback<Unit>
): VimeoRequest

/**
* Removes the provided User from the team.
*
* @param membership The [Membership] of the User to be removed.
* @param queryParams Optional map used to refine the response from the API.
* @param callback The callback which will be notified of the request completion.
*
* @return A [VimeoRequest] object to cancel API requests.
*/
fun removeUserFromTeam(
membership: TeamMembership,
queryParams: Map<String, String>?,
callback: VimeoCallback<Unit>
): VimeoRequest

/**
* Changes the user role based on the given [role].
*
* @param uri the URI from which content will be sent to.
* @param role The [TeamRoleType] that given user will be changed to.
* @param queryParams Optional map used to refine the response from the API.
* @param callback The callback which will be notified of the request completion.
*
* @return A [VimeoRequest] object to cancel API requests.
*/
fun changeUserRole(
uri: String,
role: TeamRoleType,
queryParams: Map<String, String>?,
callback: VimeoCallback<TeamMembership>
): VimeoRequest

/**
* Changes the user role based on the given [role].
*
* @param membership The [TeamMembership] of the User that will have their [TeamRoleType] changed.
* @param role The [TeamRoleType] that given user will be changed to.
* @param queryParams Optional map used to refine the response from the API.
* @param callback The callback which will be notified of the request completion.
*
* @return A [VimeoRequest] object to cancel API requests.
*/
fun changeUserRole(
membership: TeamMembership,
role: TeamRoleType,
queryParams: Map<String, String>?,
callback: VimeoCallback<TeamMembership>
): VimeoRequest

/**
* Grants permission for the given users to access the given folder.
*
* @param uri the URI from which content will be sent to.
* @param usersIds A list of URIs for the users who will be granted access.
* to the given folder, if a user who currently has access to this folder is not present in this list they will have
* their folder permission revoked.
* @param queryParams Optional map used to refine the response from the API.
* @param callback The callback which will be notified of the request completion.
*
* @return A [VimeoRequest] object to cancel API requests.
*/
fun grantUsersAccessToFolder(
uri: String,
usersIds: List<String>,
queryParams: Map<String, String>?,
callback: VimeoCallback<Unit>
): VimeoRequest

/**
* Grants permission for the given users to access the given folder.
*
* @param folder The [Folder] that [users] will be granted access to.
* @param users A list of [Users][User] who will be granted access.
* to the given folder, if a user who currently has access to this folder is not present in this list they will have
* their folder permission revoked.
* @param queryParams Optional map used to refine the response from the API.
* @param callback The callback which will be notified of the request completion.
*
* @return A [VimeoRequest] object to cancel API requests.
*/
fun grantUsersAccessToFolder(
folder: Folder,
users: List<User>,
queryParams: Map<String, String>?,
callback: VimeoCallback<Unit>
): VimeoRequest

/**
* Fetch an empty response from the provided endpoint.
*
Expand Down
Loading

0 comments on commit 8a5d025

Please sign in to comment.