-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support repositories/deployments_config
- Loading branch information
1 parent
61ac6b1
commit be23086
Showing
4 changed files
with
63 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/Bitbucket.Cloud.Net/v2/Repositories/DeploymentsConfig/BitbucketCloudClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Bitbucket.Cloud.Net.Common.Models; | ||
using Bitbucket.Cloud.Net.Models; | ||
using Flurl.Http; | ||
|
||
// ReSharper disable once CheckNamespace | ||
namespace Bitbucket.Cloud.Net | ||
{ | ||
public partial class BitbucketCloudClient | ||
{ | ||
private IFlurlRequest GetDeploymentsConfigUrl(string workspaceId, string repositorySlug) => GetBaseUrl($"2.0/repositories/{workspaceId}/{repositorySlug}/deployments_config"); | ||
|
||
private IFlurlRequest GetDeploymentsConfigUrl(string workspaceId, string repositorySlug, string path) => GetDeploymentsConfigUrl(workspaceId, repositorySlug) | ||
.AppendPathSegment(path); | ||
|
||
public async Task<Variable> CreateRepositoryDeploymentsConfigVariableAsync(string workspaceId, string repositorySlug, Guid environmentUuid, Variable variable) | ||
{ | ||
var response = await GetDeploymentsConfigUrl(workspaceId, repositorySlug, $"/environments/{environmentUuid:B}/variables") | ||
.PostJsonAsync(variable) | ||
.ConfigureAwait(false); | ||
|
||
return await HandleResponseAsync<Variable>(response).ConfigureAwait(false); | ||
} | ||
|
||
public async Task<IEnumerable<Variable>> GetRepositoryDeploymentsConfigVariablesAsync(string workspaceId, string repositorySlug, Guid environmentUuid, int? maxPages = null) | ||
{ | ||
var queryParamValues = new Dictionary<string, object>(); | ||
|
||
return await GetPagedResultsAsync(maxPages, queryParamValues, async qpv => | ||
await GetDeploymentsConfigUrl(workspaceId, repositorySlug, $"/environments/{environmentUuid:B}/variables") | ||
.SetQueryParams(qpv) | ||
.GetJsonAsync<PagedResults<Variable>>() | ||
.ConfigureAwait(false)) | ||
.ConfigureAwait(false); | ||
} | ||
|
||
public async Task<Variable> UpdateRepositoryDeploymentsConfigVariableAsync(string workspaceId, string repositorySlug, Guid environmentUuid, Guid variableUuid, Variable variable) | ||
{ | ||
var response = await GetDeploymentsConfigUrl(workspaceId, repositorySlug, $"/environments/{environmentUuid:B}/variables/{variableUuid:B}") | ||
.PutJsonAsync(variable) | ||
.ConfigureAwait(false); | ||
|
||
return await HandleResponseAsync<Variable>(response).ConfigureAwait(false); | ||
} | ||
|
||
public async Task<bool> DeleteRepositoryDeploymentsConfigVariableAsync(string workspaceId, string repositorySlug, Guid environmentUuid, Guid variableUuid) | ||
{ | ||
var response = await GetDeploymentsConfigUrl(workspaceId, repositorySlug, $"/environments/{environmentUuid:B}/variables/{variableUuid:B}") | ||
.DeleteAsync() | ||
.ConfigureAwait(false); | ||
|
||
return await HandleResponseAsync(response).ConfigureAwait(false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters