Skip to content

Commit

Permalink
Merge pull request #89 from oracle/release_2021-11-09
Browse files Browse the repository at this point in the history
Releasing version 29.0.0
  • Loading branch information
bhagwatvyas committed Nov 9, 2021
2 parents 00ed6d3 + 7ac54ac commit 4c4c468
Show file tree
Hide file tree
Showing 37 changed files with 668 additions and 55 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file.

The format is based on Keep a [Changelog](http://keepachangelog.com/).

## 29.0.0 - 2021-11-09
### Added
- Support for drill down metadata in the Management Dashboard service
- Support for operator access control on dedicated autonomous databases in the Operator Access Control service

### Breaking Changes
- The `ResourceType`, and `IsEnforcedAlways` fields changed from optional to required in the CreateOperatorControlAssignmentDetails model in the Operatoraccesscontrol service
- The `ApproverGroupsList` field changed from optional to required in the CreateOperatorControlDetails model in the Operatoraccesscontrol service
- The `IsFullyPreApproved`, and `requiredIsEnforcedAlways` fields changed from optional to required in the UpdateOperatorControlAssignmentDetails model in the Operatoraccesscontrol service
- The `OperatorControlName`, `ApproverGroupsList`, and `IsFullyPreApproved` fields changed from optional to required in the UpdateOperatorControlDetails model in the Operatoraccesscontrol service
- The `ResourceType` type changed from `string` to `System.Nullable<ResourceTypes>` in the OperatorControlAssignmentSummary model in the Operatoraccesscontrol service

### Fixed
- Refreshing Instance Principals tokens after they expire

## 28.1.0 - 2021-11-02
### Added
- Support for the Database Tools service
Expand Down
33 changes: 1 addition & 32 deletions Common/Src/ClientBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
*/

using System;
using System.Collections.Generic;
using System.Net.Http;
using Oci.Common.Auth;
using Oci.Common.Http;
using Oci.Common.Http.Signing;
Expand All @@ -16,11 +14,7 @@ namespace Oci.Common
public abstract class ClientBase : IDisposable
{
bool disposed = false;
private readonly Dictionary<SigningStrategy, RequestSigner> availableRequestSigners;
private readonly RequestSigner requestSigner;

protected static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
protected RestClientHandler clientHandler;
protected readonly RestClient restClient;
protected Service service;
protected string userAgent = null;
Expand Down Expand Up @@ -52,10 +46,7 @@ public abstract class ClientBase : IDisposable
public ClientBase(IBasicAuthenticationDetailsProvider authProvider, ClientConfiguration clientConfiguration, RequestSigner requestSigner)
{
ClientConfiguration clientConfigurationToUse = clientConfiguration ?? new ClientConfiguration();
this.clientHandler = new RestClientHandler(RequestReceptor);
this.restClient = new RestClient(clientHandler, clientConfigurationToUse);
this.requestSigner = requestSigner;
this.availableRequestSigners = GetAvailableRequestSigners(authProvider);
this.restClient = new RestClient(authProvider, clientConfigurationToUse, requestSigner);
this.restClient.SetDefaultUserAgent(GetUserAgent(clientConfigurationToUse.ClientUserAgent));
}

Expand Down Expand Up @@ -102,27 +93,5 @@ private string GetUserAgent(string clientUserAgent)
}
return userAgent;
}

internal void RequestReceptor(HttpRequestMessage requestMessage)
{
RequestSigner requestSignerToUse = requestSigner;
if (requestMessage.Properties.TryGetValue(SigningStrategy.SIGNING_STRATEGY_PROPERTY_NAME_KEY, out var signingStrategy))
{
requestSignerToUse = availableRequestSigners.TryGetValue((SigningStrategy)signingStrategy, out var desiredSigner) ?
desiredSigner : requestSignerToUse;
}

requestSignerToUse.SignRequest(requestMessage);
}

private Dictionary<SigningStrategy, RequestSigner> GetAvailableRequestSigners(IBasicAuthenticationDetailsProvider authProvider)
{
var signers = new Dictionary<SigningStrategy, RequestSigner>();
foreach (SigningStrategy strategy in SigningStrategy.Values)
{
signers.Add(strategy, new DefaultRequestSigner(authProvider, strategy));
}
return signers;
}
}
}
86 changes: 84 additions & 2 deletions Common/Src/Http/RestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,67 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Oci.Common.Auth;
using Oci.Common.Http.Internal;
using Oci.Common.Http.Signing;
using Oci.Common.Model;
using Oci.Common.Utils;

namespace Oci.Common.Http
{
/// <summary>A REST client implementation.</summary>
public class RestClient
{
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
private static readonly int MAX_RETRIES_FOR_TOKEN_REFRESH = 2;
private readonly Dictionary<SigningStrategy, RequestSigner> availableRequestSigners;
private RequestSigner requestSigner;
private readonly IBasicAuthenticationDetailsProvider authProvider;

private void RefreshSigner()
{
((AbstractRequestingAuthenticationDetailsProvider)this.authProvider).Refresh();
if (this.requestSigner is DefaultRequestSigner)
{
this.requestSigner = new DefaultRequestSigner(this.authProvider);
}
}

/// This is DEPRECATED. Please use the RestClient constructor using IBasicAuthenticationDetailsProvider.
public RestClient(RestClientHandler handler)
{
this.httpClient = new HttpClient(handler);
}

/// This is DEPRECATED. Please use the RestClient constructor using IBasicAuthenticationDetailsProvider.
public RestClient(RestClientHandler handler, ClientConfiguration clientConfiguration)
{
this.httpClient = new HttpClient(handler);
this.httpClient.Timeout = TimeSpan.FromMilliseconds(clientConfiguration.TimeoutMillis);
this.httpClient.MaxResponseContentBufferSize = clientConfiguration.ResponseContentBufferBytes;
}

public RestClient() : this(null as RestClientHandler) { }
public RestClient(IBasicAuthenticationDetailsProvider authProvider, RequestSigner requestSigner)
{
this.authProvider = authProvider;
this.restClientHandler = new RestClientHandler(RequestReceptor);
this.httpClient = new HttpClient(restClientHandler);
this.requestSigner = requestSigner;
this.availableRequestSigners = GetAvailableRequestSigners(this.authProvider);
}

public RestClient(IBasicAuthenticationDetailsProvider authProvider, ClientConfiguration clientConfiguration, RequestSigner requestSigner) : this(authProvider, requestSigner)
{
this.httpClient.Timeout = TimeSpan.FromMilliseconds(clientConfiguration.TimeoutMillis);
this.httpClient.MaxResponseContentBufferSize = clientConfiguration.ResponseContentBufferBytes;
}

public RestClient() : this(null as IBasicAuthenticationDetailsProvider, null as RequestSigner) { }

/// <summary>Disposes the HTTP client</summary>
public void Dispose()
Expand Down Expand Up @@ -71,7 +105,33 @@ public void SetDefaultUserAgent(string userAgent)
/// <returns>A Task of HttpResponseMessage returned.</returns>
public async Task<HttpResponseMessage> HttpSend(HttpRequestMessage httpRequest, CancellationToken cancellationToken = default)
{
return await this.httpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);
if (this.authProvider is AbstractRequestingAuthenticationDetailsProvider)
{
int attempts = 0;
HttpResponseMessage responseMessage = null;
while (attempts < MAX_RETRIES_FOR_TOKEN_REFRESH)
{
++attempts;
// A new copy of the request message needs to be created because it is disposed each time it is sent, and
// resending the same request will result in the following error message:
// "The request message was already sent. Cannot send the same request message multiple times."
var newRequestMessage = HttpUtils.CloneHttpRequestMessage(httpRequest);
responseMessage = await this.httpClient.SendAsync(newRequestMessage, cancellationToken).ConfigureAwait(false);
if (!responseMessage.IsSuccessStatusCode && responseMessage.StatusCode == System.Net.HttpStatusCode.Unauthorized)
{
this.RefreshSigner();
}
else
{
break;
}
}
return responseMessage;
}
else
{
return await this.httpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);
}
}

/// <summary>Check if the HttpResponseMessage is a successful response.</summary>
Expand Down Expand Up @@ -109,6 +169,28 @@ public void CheckHttpResponseMessage(HttpRequestMessage httpRequest, HttpRespons
}
}

internal void RequestReceptor(HttpRequestMessage requestMessage)
{
RequestSigner requestSignerToUse = this.requestSigner;
if (requestMessage.Properties.TryGetValue(SigningStrategy.SIGNING_STRATEGY_PROPERTY_NAME_KEY, out var signingStrategy))
{
requestSignerToUse = this.availableRequestSigners.TryGetValue((SigningStrategy)signingStrategy, out var desiredSigner) ?
desiredSigner : requestSignerToUse;
}

requestSignerToUse.SignRequest(requestMessage);
}

private Dictionary<SigningStrategy, RequestSigner> GetAvailableRequestSigners(IBasicAuthenticationDetailsProvider authProvider)
{
var signers = new Dictionary<SigningStrategy, RequestSigner>();
foreach (SigningStrategy strategy in SigningStrategy.Values)
{
signers.Add(strategy, new DefaultRequestSigner(authProvider, strategy));
}
return signers;
}
private readonly HttpClient httpClient = null;
private readonly RestClientHandler restClientHandler = null;
}
}
4 changes: 2 additions & 2 deletions Common/Src/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ namespace Oci.Common
{
public class Version
{
public static string MAJOR = "28";
public static string MINOR = "1";
public static string MAJOR = "29";
public static string MINOR = "0";
public static string PATCH = "0";
public static string TAG = "";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ public class CreateManagementDashboardDetails
[JsonProperty(PropertyName = "parametersConfig")]
public System.Collections.Generic.List<System.Object> ParametersConfig { get; set; }

/// <value>
/// Drill-down configuration to define the destination of a drill-down action.
/// </value>
[JsonProperty(PropertyName = "drilldownConfig")]
public System.Collections.Generic.List<System.Object> DrilldownConfig { get; set; }

/// <value>
/// Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only.
/// Example: {&quot;bar-key&quot;: &quot;value&quot;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ public class CreateManagementSavedSearchDetails
[JsonProperty(PropertyName = "parametersConfig")]
public System.Collections.Generic.List<System.Object> ParametersConfig { get; set; }

/// <value>
/// Drill-down configuration to define the destination of a drill-down action.
/// </value>
[JsonProperty(PropertyName = "drilldownConfig")]
public System.Collections.Generic.List<System.Object> DrilldownConfig { get; set; }

/// <value>
/// Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only.
/// Example: {&quot;bar-key&quot;: &quot;value&quot;}
Expand Down
6 changes: 6 additions & 0 deletions Managementdashboard/models/ManagementDashboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ public class ManagementDashboard
[JsonProperty(PropertyName = "parametersConfig")]
public System.Collections.Generic.List<System.Object> ParametersConfig { get; set; }

/// <value>
/// Drill-down configuration to define the destination of a drill-down action.
/// </value>
[JsonProperty(PropertyName = "drilldownConfig")]
public System.Collections.Generic.List<System.Object> DrilldownConfig { get; set; }

/// <value>
/// Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only.
/// Example: {&quot;bar-key&quot;: &quot;value&quot;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ public class ManagementDashboardForImportExportDetails
[JsonProperty(PropertyName = "parametersConfig")]
public System.Collections.Generic.List<System.Object> ParametersConfig { get; set; }

/// <value>
/// Drill-down configuration to define the destination of a drill-down action.
/// </value>
[JsonProperty(PropertyName = "drilldownConfig")]
public System.Collections.Generic.List<System.Object> DrilldownConfig { get; set; }

/// <value>
/// Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only.
/// Example: {&quot;bar-key&quot;: &quot;value&quot;}
Expand Down
6 changes: 6 additions & 0 deletions Managementdashboard/models/ManagementSavedSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ public class ManagementSavedSearch
[JsonProperty(PropertyName = "parametersConfig")]
public System.Collections.Generic.List<System.Object> ParametersConfig { get; set; }

/// <value>
/// Drill-down configuration to define the destination of a drill-down action.
/// </value>
[JsonProperty(PropertyName = "drilldownConfig")]
public System.Collections.Generic.List<System.Object> DrilldownConfig { get; set; }

/// <value>
/// Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only.
/// Example: {&quot;bar-key&quot;: &quot;value&quot;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,11 @@ public class ManagementSavedSearchForImportDetails
[JsonProperty(PropertyName = "parametersConfig")]
public System.Collections.Generic.List<System.Object> ParametersConfig { get; set; }

/// <value>
/// Drill-down configuration to define the destination of a drill-down action.
/// </value>
[JsonProperty(PropertyName = "drilldownConfig")]
public System.Collections.Generic.List<System.Object> DrilldownConfig { get; set; }

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ public class UpdateManagementDashboardDetails
[JsonProperty(PropertyName = "parametersConfig")]
public System.Collections.Generic.List<System.Object> ParametersConfig { get; set; }

/// <value>
/// Drill-down configuration to define the destination of a drill-down action.
/// </value>
[JsonProperty(PropertyName = "drilldownConfig")]
public System.Collections.Generic.List<System.Object> DrilldownConfig { get; set; }

/// <value>
/// Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only.
/// Example: {&quot;bar-key&quot;: &quot;value&quot;}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ public class UpdateManagementSavedSearchDetails
[JsonProperty(PropertyName = "parametersConfig")]
public System.Collections.Generic.List<System.Object> ParametersConfig { get; set; }

/// <value>
/// Drill-down configuration to define the destination of a drill-down action.
/// </value>
[JsonProperty(PropertyName = "drilldownConfig")]
public System.Collections.Generic.List<System.Object> DrilldownConfig { get; set; }

/// <value>
/// Simple key-value pair that is applied without any predefined name, type or scope. Exists for cross-compatibility only.
/// Example: {&quot;bar-key&quot;: &quot;value&quot;}
Expand Down
40 changes: 40 additions & 0 deletions Operatoraccesscontrol/AccessRequestsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,46 @@ public async Task<RejectAccessRequestResponse> RejectAccessRequest(RejectAccessR
}
}

/// <summary>
/// Reviews the access request.
///
/// </summary>
/// <param name="request">The request object containing the details to send. Required.</param>
/// <param name="retryConfiguration">The retry configuration that will be used by to send this request. Optional.</param>
/// <param name="cancellationToken">The cancellation token to cancel this operation. Optional.</param>
/// <returns>A response object containing details about the completed operation</returns>
/// <example>Click <a href="https://docs.cloud.oracle.com/en-us/iaas/tools/dot-net-examples/latest/operatoraccesscontrol/ReviewAccessRequest.cs.html">here</a> to see an example of how to use ReviewAccessRequest API.</example>
public async Task<ReviewAccessRequestResponse> ReviewAccessRequest(ReviewAccessRequestRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
{
logger.Trace("Called reviewAccessRequest");
Uri uri = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/accessRequests/{accessRequestId}/action/review".Trim('/')));
HttpMethod method = new HttpMethod("POST");
HttpRequestMessage requestMessage = Converter.ToHttpRequestMessage(uri, method, request);
requestMessage.Headers.Add("Accept", "application/json");
GenericRetrier retryingClient = Retrier.GetPreferredRetrier(retryConfiguration, this.retryConfiguration);
HttpResponseMessage responseMessage;

try
{
if (retryingClient != null)
{
responseMessage = await retryingClient.MakeRetryingCall(this.restClient.HttpSend, requestMessage, cancellationToken).ConfigureAwait(false);
}
else
{
responseMessage = await this.restClient.HttpSend(requestMessage).ConfigureAwait(false);
}
this.restClient.CheckHttpResponseMessage(requestMessage, responseMessage);

return Converter.FromHttpResponseMessage<ReviewAccessRequestResponse>(responseMessage);
}
catch (Exception e)
{
logger.Error($"ReviewAccessRequest failed with error: {e.Message}");
throw;
}
}

/// <summary>
/// Revokes an already approved access request.
///
Expand Down

0 comments on commit 4c4c468

Please sign in to comment.