/// <summary> /// Creates a new consent group, nominating who may participate. /// </summary> /// <param name="name">The name of the consent group.</param> /// <param name="members">The members of the group and what they are authorized to do.</param> /// <param name="keyFormat">A regular expression the consent key must conform to.</param> /// <param name="scopes">The consent scopes.</param> /// <returns>The created consent group.</returns> /// <exception cref="SerializationException">Unable process the service response.</exception> /// <exception cref="LogicTokenProviderException">Unable to issue an authorization token.</exception> /// <exception cref="ConsentValidationException">Invalid request details.</exception> /// <exception cref="ConsentConfigurationException">Invalid consent configuration details.</exception> public async Task <ConsentGroupResponse> CreateConsentGroup(string name, IList <ConsentGroupMemberRequest> members, string keyFormat = null, IList <string> scopes = null) { var client = this.CreateClient(); var request = new ConsentGroupRequest { Name = name, KeyFormat = keyFormat, Members = members, Scopes = scopes, }; var response = await client.CreateConsentGroupWithHttpMessagesAsync( subscriptionId : this.options.SubscriptionId, request : request).ConfigureAwait(false); switch (response.Response.StatusCode) { case System.Net.HttpStatusCode.OK: case System.Net.HttpStatusCode.Created: return((ConsentGroupResponse)response.Body); case System.Net.HttpStatusCode.BadRequest: throw new ConsentValidationException(response.Body as IDictionary <string, IList <string> >); default: throw new ConsentConfigurationException("Invalid configuration provided to access consent service", response.Body as string); } }
/// <summary> /// Updates the consent group, nominating who may participate. /// </summary> /// <param name="consentGroupId">The consent group to update.</param> /// <param name="name">The name of the consent group.</param> /// <param name="members">The members of the group and what they are authorized to do.</param> /// <param name="keyFormat">A regular expression the consent key must conform to.</param> /// <param name="scopes">The consent scopes.</param> /// <returns>The created consent group.</returns> /// <exception cref="SerializationException">Unable process the service response.</exception> /// <exception cref="LogicTokenProviderException">Unable to issue an authorization token.</exception> /// <exception cref="KeyNotFoundException">The consent group does not exist.</exception> /// <exception cref="ConsentValidationException">Invalid request details.</exception> /// <exception cref="ConsentConfigurationException">Invalid consent configuration details.</exception> public async Task <ConsentGroupResponse> UpdateConsentGroup(Guid consentGroupId, string name, IList <ConsentGroupMemberRequest> members, string keyFormat = null, IList <string> scopes = null) { var client = this.CreateClient(); var request = new ConsentGroupRequest { Name = name, KeyFormat = keyFormat, Members = members, Scopes = scopes, }; var response = await client.UpdateConsentGroupWithHttpMessagesAsync( subscriptionId : this.options.SubscriptionId, consentGroupId : consentGroupId, request : request).ConfigureAwait(false); switch (response.Response.StatusCode) { case System.Net.HttpStatusCode.OK: case System.Net.HttpStatusCode.Created: return((ConsentGroupResponse)response.Body); case System.Net.HttpStatusCode.NotFound: throw new KeyNotFoundException($"The consent group {name} does not exist"); case System.Net.HttpStatusCode.BadRequest: throw new ConsentValidationException(response.Body as IDictionary <string, IList <string> >); case System.Net.HttpStatusCode.Unauthorized: throw new ConsentConfigurationException($"You do not have permission to manage the consent group {name}"); default: throw new ConsentConfigurationException("Invalid configuration provided to access consent service", response.Body as string); } }
/// <summary> /// Update an existing consent group /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='subscriptionId'> /// The subscription responsible for managing this consent group /// </param> /// <param name='consentGroupId'> /// The consent group to update /// </param> /// <param name='request'> /// The details of the consent group being updated /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <object> UpdateConsentGroupAsync(this IInternalClient operations, System.Guid subscriptionId, System.Guid consentGroupId, ConsentGroupRequest request = default(ConsentGroupRequest), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.UpdateConsentGroupWithHttpMessagesAsync(subscriptionId, consentGroupId, request, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Update an existing consent group /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='subscriptionId'> /// The subscription responsible for managing this consent group /// </param> /// <param name='consentGroupId'> /// The consent group to update /// </param> /// <param name='request'> /// The details of the consent group being updated /// </param> public static object UpdateConsentGroup(this IInternalClient operations, System.Guid subscriptionId, System.Guid consentGroupId, ConsentGroupRequest request = default(ConsentGroupRequest)) { return(operations.UpdateConsentGroupAsync(subscriptionId, consentGroupId, request).GetAwaiter().GetResult()); }