public Task <BranchRestriction> AddAsync(string owner, string reposlug, BranchRestriction restriction) { var segments = CreateDefaultSegmentsDictionary(owner, reposlug); var content = restriction.CreatePostData(); var restRequest = new RestComplexDataRequest(Method.POST, segments, null, null, content, RestDataContentType.UrlEncode); var task = MakeAsyncRequest <BranchRestriction>(BRANCH_RESTRICTIONS_RESOURCE, restRequest); return(task); }
public void AddAsync_AddBranchRestriction_BranchIsRetrieved() { var branchRestriction = new BranchRestriction() { Kind = BranchRestrictionType.Delete.Value, Pattern = "pattern", }; var result = _client.AddAsync(_defaultUser, _defaultRepository, branchRestriction).Result; AssertHelper.AtLeastOnePropertyIsNotDefault <BranchRestriction>(result); }
public void GetAsync_GetFirstBranchRestriction_FirstBranchRestrictionRetrieved() { var branchRestriction = new BranchRestriction() { Kind = BranchRestrictionType.Delete.Value, Pattern = "pattern", }; var paginatedRequest = new PaginatedRequest(); var result = _client.AddAsync(_defaultUser, _defaultRepository, branchRestriction).Result; var restrictions = _client.GetAllAsync(_defaultUser, _defaultRepository, paginatedRequest).Result; var restriction = _client.GetAsync(_defaultUser, _defaultRepository, restrictions.Values[0].Id.ToString()).Result; AssertHelper.AtLeastOnePropertyIsNotDefault <BranchRestriction>(restriction); }
public void DeleteAsync_DeleteBranchRestriction_BranchIsRetrieved() { var branchRestriction = new BranchRestriction() { Kind = BranchRestrictionType.Delete.Value, Pattern = "pattern", }; var paginatedRequest = new PaginatedRequest(); var addResult = _client.AddAsync(_defaultUser, _defaultRepository, branchRestriction).Result; var restrictions = _client.GetAllAsync(_defaultUser, _defaultRepository, paginatedRequest).Result; var deleteResult = _client.DeleteAsync(_defaultUser, _defaultRepository, restrictions.Values[0].Id.ToString()).Result; bool condition = (string.IsNullOrWhiteSpace(deleteResult) == true); Assert.IsTrue(condition); }
public void EditAsync_EditBranchRestriction_BranchIsEdited() { var branchRestriction = new BranchRestriction() { Kind = BranchRestrictionType.Delete.Value, Pattern = "pattern", }; var paginatedRequest = new PaginatedRequest(); var result = _client.AddAsync(_defaultUser, _defaultRepository, branchRestriction).Result; var restrictions = _client.GetAllAsync(_defaultUser, _defaultRepository, paginatedRequest).Result; var id = restrictions.Values[0].Id.ToString(); restrictions.Values[0].Pattern = "newPattern"; var newResult = _client.EditAsync(_defaultUser, _defaultRepository, id, restrictions.Values[0]).Result; bool condition = (newResult.Pattern == "newPattern"); Assert.IsTrue(condition); }
internal BranchRestriction PutBranchRestriction(string accountName, string slug, BranchRestriction restriction) { var overrideUrl = GetRepositoryUrl(accountName, slug, $"branch-restrictions/{restriction.id}"); return(_sharpBucketV2.Put(restriction, overrideUrl)); }
/// <summary> /// Updates a specific branch restriction. You cannot change the kind value with this call. /// </summary> /// <param name="restriction">The branch restriction.</param> /// <returns></returns> public BranchRestriction PutBranchRestriction(BranchRestriction restriction) { return(_repositoriesEndPoint.PutBranchRestriction(_accountName, _repository, restriction)); }
internal BranchRestriction PostBranchRestriction(string accountName, string repository, BranchRestriction restriction) { var overrideUrl = GetRepositoryUrl(accountName, repository, "branch-restrictions/"); return(_sharpBucketV2.Post(restriction, overrideUrl)); }
internal async Task <BranchRestriction> PutBranchRestriction(string accountName, string repository, BranchRestriction restriction) { var overrideUrl = GetRepositoryUrl(accountName, repository, "branch-restrictions/" + restriction.id); return(await _bitBucketClientV2.Put(restriction, overrideUrl)); }
/// <summary> /// Updates a specific branch restriction. You cannot change the kind value with this call. /// </summary> /// <param name="restriction">The branch restriction.</param> /// <param name="token">The cancellation token</param> /// <returns></returns> public Task <BranchRestriction> PutBranchRestrictionAsync(BranchRestriction restriction, CancellationToken token = default) { return(_sharpBucketV2.PutAsync(restriction, _baseUrl + $"branch-restrictions/{restriction.id}", token)); }
/// <summary> /// Updates a specific branch restriction. You cannot change the kind value with this call. /// </summary> /// <param name="restriction">The branch restriction.</param> /// <returns></returns> public BranchRestriction PutBranchRestriction(BranchRestriction restriction) { return(_sharpBucketV2.Put(restriction, _baseUrl + $"branch-restrictions/{restriction.id}")); }
/// <summary> /// Creates restrictions for the specified repository. You should specify a Content-Header with this call. /// </summary> /// <param name="restriction">The branch restriction.</param> /// <returns></returns> public BranchRestriction PostBranchRestriction(BranchRestriction restriction) { return(_sharpBucketV2.Post(restriction, _baseUrl + "branch-restrictions")); }
public Task <BranchRestriction> EditAsync(string owner, string reposlug, string id, BranchRestriction restriction) { var segments = CreateDefaultSegmentsDictionary(owner, reposlug); segments.Add(ID_SEGMENT, id); var content = restriction.CreatePostData(); var restRequest = new RestComplexDataRequest(Method.PUT, segments, null, null, content, RestDataContentType.UrlEncode); var task = MakeAsyncRequest <BranchRestriction>(SPECIFIED_RESTRICTION_RESOURCE, restRequest); return(task); }
/// <summary> /// Updates a specific branch restriction. You cannot change the kind value with this call. /// </summary> /// <param name="restriction">The branch restriction.</param> /// <returns></returns> public async Task <BranchRestriction> PutBranchRestriction(BranchRestriction restriction) { return(await _repositoriesEndPoint.PutBranchRestriction(_accountName, _repository, restriction)); }
public async Task <BranchRestriction> UpdateRepositoryBranchRestrictionAsync(string workspaceId, string repositorySlug, string branchRestrictionId, BranchRestriction branchRestriction) { var response = await GetBranchRestrictionsUrl(workspaceId, repositorySlug, branchRestrictionId) .PutJsonAsync(branchRestriction) .ConfigureAwait(false); return(await HandleResponseAsync <BranchRestriction>(response)); }