/// <summary> /// Add a repository to the team /// </summary> /// <param name="id">The team identifier.</param> /// <param name="organization">Org to associate the repo with.</param> /// <param name="repoName">Name of the repo.</param> /// <param name="permission">The permission to grant the team on this repository.</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns></returns> public async Task <bool> AddRepository(int id, string organization, string repoName, RepositoryPermissionRequest permission) { Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); Ensure.ArgumentNotNullOrEmptyString(repoName, "repoName"); var endpoint = ApiUrls.TeamRepository(id, organization, repoName); try { var httpStatusCode = await ApiConnection.Connection.Put <HttpStatusCode>(endpoint, permission, "", AcceptHeaders.OrganizationPermissionsPreview).ConfigureAwait(false); return(httpStatusCode.HttpResponse.StatusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }
public async Task <bool> AddRepository(int id, string organization, string repoName, RepositoryPermissionRequest permission) { Ensure.ArgumentNotNullOrEmptyString(organization, nameof(organization)); Ensure.ArgumentNotNullOrEmptyString(repoName, nameof(repoName)); // TODO: I am very suspicious of this due to the documentation // https://developer.github.com/v3/teams/#add-or-update-team-repository // // Recommended: // PUT /orgs/:org/teams/:team_slug/repos/:owner/:repo // // or // // PUT /organizations/:org_id/team/:team_id/repos/:owner/:repo // // Likely will require a breaking change var endpoint = ApiUrls.TeamRepository(id, organization, repoName); try { var httpStatusCode = await ApiConnection.Connection.Put <HttpStatusCode>(endpoint, permission).ConfigureAwait(false); return(httpStatusCode.HttpResponse.StatusCode == HttpStatusCode.NoContent); } catch (NotFoundException) { return(false); } }
/// <summary> /// Add a repository to the team /// </summary> /// <param name="id">The team identifier.</param> /// <param name="organization">Org to associate the repo with.</param> /// <param name="repoName">Name of the repo.</param> /// <param name="permission">The permission to grant the team on this repository.</param> /// <exception cref="ApiException">Thrown when a general API error occurs.</exception> /// <returns></returns> public async Task<bool> AddRepository(int id, string organization, string repoName, RepositoryPermissionRequest permission) { Ensure.ArgumentNotNullOrEmptyString(organization, "organization"); Ensure.ArgumentNotNullOrEmptyString(repoName, "repoName"); var endpoint = ApiUrls.TeamRepository(id, organization, repoName); try { var httpStatusCode = await ApiConnection.Connection.Put<HttpStatusCode>(endpoint, permission, "", AcceptHeaders.OrganizationPermissionsPreview).ConfigureAwait(false); return httpStatusCode.HttpResponse.StatusCode == HttpStatusCode.NoContent; } catch (NotFoundException) { return false; } }