|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Text; |
| 4 | +using GitLabApiClient.Internal.Utilities; |
| 5 | +using GitLabApiClient.Models.Branches.Responses; |
| 6 | +using Newtonsoft.Json; |
| 7 | + |
| 8 | +namespace GitLabApiClient.Models.Branches.Requests |
| 9 | +{ |
| 10 | + /// <summary> |
| 11 | + /// Protects a branch. |
| 12 | + /// </summary> |
| 13 | + public sealed class ProtectBranchRequest |
| 14 | + { |
| 15 | + |
| 16 | + /// <summary> |
| 17 | + /// Initializes a new instance of the <see cref="ProtectBranchRequest"/> class. |
| 18 | + /// </summary> |
| 19 | + /// <param name="projectId">ID or URL-Encoded path of the project.</param> |
| 20 | + /// <param name="name">The name of the branch or wildcard.</param> |
| 21 | + /// <param name="pushAccessLevel">Access levels allowed to push.</param> |
| 22 | + /// <param name="mergeAccessLevel">Access levels allowed to merge.</param> |
| 23 | + /// <param name="unprotectAccessLevel">Access levels allowed to unprotect.</param> |
| 24 | + public ProtectBranchRequest( |
| 25 | + string projectId, |
| 26 | + string name, |
| 27 | + ProtectedRefAccessLevels? pushAccessLevel = ProtectedRefAccessLevels.MAINTAINER_ACCESS, |
| 28 | + ProtectedRefAccessLevels? mergeAccessLevel = ProtectedRefAccessLevels.MAINTAINER_ACCESS, |
| 29 | + ProtectedRefAccessLevels? unprotectAccessLevel = ProtectedRefAccessLevels.MAINTAINER_ACCESS) |
| 30 | + { |
| 31 | + Guard.NotEmpty(projectId, nameof(projectId)); |
| 32 | + Guard.NotEmpty(name, nameof(name)); |
| 33 | + |
| 34 | + PushAccessLevel = pushAccessLevel.ToString(); |
| 35 | + MergeAccessLevel = mergeAccessLevel.ToString(); |
| 36 | + UnprotectAccessLevel = unprotectAccessLevel.ToString(); |
| 37 | + } |
| 38 | + |
| 39 | + /// <summary> |
| 40 | + /// Id or URL-Encoded path of the project. |
| 41 | + /// </summary> |
| 42 | + [JsonProperty("id")] |
| 43 | + public string ProjectId { get; set; } |
| 44 | + |
| 45 | + /// <summary> |
| 46 | + /// The name of the branch or wildcard. |
| 47 | + /// </summary> |
| 48 | + [JsonProperty("name")] |
| 49 | + public string Name { get; set; } |
| 50 | + |
| 51 | + /// <summary> |
| 52 | + /// Access levels allowed to push (defaults: 40, maintainer access level). |
| 53 | + /// </summary> |
| 54 | + [JsonProperty("push_access_level")] |
| 55 | + public string PushAccessLevel { get; set; } |
| 56 | + |
| 57 | + /// <summary> |
| 58 | + /// Access levels allowed to merge (defaults: 40, maintainer access level). |
| 59 | + /// </summary> |
| 60 | + [JsonProperty("merge_access_level")] |
| 61 | + public string MergeAccessLevel { get; set; } |
| 62 | + |
| 63 | + /// <summary> |
| 64 | + /// Access levels allowed to unprotect (defaults: 40, maintainer access level). |
| 65 | + /// </summary> |
| 66 | + [JsonProperty("unprotect_access_level")] |
| 67 | + public string UnprotectAccessLevel { get; set; } |
| 68 | + } |
| 69 | +} |
0 commit comments