Skip to content

Commit

Permalink
Use managed HttpProvider for MonitoringIngestionClient (#839)
Browse files Browse the repository at this point in the history
* Use managed HttpProvider for MonitoringIngestionClient
  • Loading branch information
yawkat authored Mar 6, 2024
1 parent 940612c commit 1c51e7c
Showing 1 changed file with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
import com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider;
import com.oracle.bmc.auth.RegionProvider;
import com.oracle.bmc.http.ClientConfigurator;
import com.oracle.bmc.http.client.HttpProvider;
import com.oracle.bmc.http.signing.RequestSignerFactory;
import com.oracle.bmc.monitoring.MonitoringClient;
import com.oracle.bmc.monitoring.requests.PostMetricDataRequest;
import com.oracle.bmc.monitoring.responses.PostMetricDataResponse;
import io.micronaut.core.annotation.Nullable;

import jakarta.inject.Singleton;

import java.util.Objects;

/**
Expand All @@ -46,6 +47,8 @@ public class MonitoringIngestionClient {
private final RequestSignerFactory requestSignerFactory;
private final RegionProvider regionProvider;
private final AbstractAuthenticationDetailsProvider authenticationDetailsProvider;
@Nullable
private final HttpProvider httpProvider;

private MonitoringClient delegate;

Expand All @@ -57,17 +60,40 @@ public class MonitoringIngestionClient {
* @param requestSignerFactory request signer factory
* @param regionProvider region provider
* @param authenticationDetailsProvider authentication details provider
* @param httpProvider HTTP provider
*/
public MonitoringIngestionClient(ClientConfiguration clientConfiguration,
@Nullable ClientConfigurator clientConfigurator,
@Nullable RequestSignerFactory requestSignerFactory,
RegionProvider regionProvider,
AbstractAuthenticationDetailsProvider authenticationDetailsProvider) {
AbstractAuthenticationDetailsProvider authenticationDetailsProvider,
@Nullable HttpProvider httpProvider) {
this.clientConfiguration = clientConfiguration;
this.clientConfigurator = clientConfigurator;
this.requestSignerFactory = requestSignerFactory;
this.regionProvider = regionProvider;
this.authenticationDetailsProvider = authenticationDetailsProvider;
this.httpProvider = httpProvider;
}

/**
* Creates {@link MonitoringIngestionClient}.
*
* @param clientConfiguration client configuration
* @param clientConfigurator client configurator
* @param requestSignerFactory request signer factory
* @param regionProvider region provider
* @param authenticationDetailsProvider authentication details provider
*
* @deprecated Use constructor with {@link HttpProvider} instead
*/
@Deprecated
public MonitoringIngestionClient(ClientConfiguration clientConfiguration,
@Nullable ClientConfigurator clientConfigurator,
@Nullable RequestSignerFactory requestSignerFactory,
RegionProvider regionProvider,
AbstractAuthenticationDetailsProvider authenticationDetailsProvider) {
this(clientConfiguration, clientConfigurator, requestSignerFactory, regionProvider, authenticationDetailsProvider, null);
}

/**
Expand All @@ -91,6 +117,9 @@ public MonitoringClient getDelegate() {
if (requestSignerFactory != null) {
builder.requestSignerFactory(requestSignerFactory);
}
if (httpProvider != null) {
builder.httpProvider(httpProvider);
}

delegate = builder.build(authenticationDetailsProvider);
}
Expand Down

0 comments on commit 1c51e7c

Please sign in to comment.