Skip to content

Commit ddff6b1

Browse files
committed
Merge pull request #589 from carolynvs/fix-useinternalurl
Fix UseInternalUrl
2 parents e910af1 + 894840b commit ddff6b1

9 files changed

Lines changed: 48 additions & 32 deletions

File tree

src/corelib/Compute/v2_1/ComputeApiBuilder.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,26 @@ public class ComputeApiBuilder
3232
/// <summary />
3333
protected readonly ServiceEndpoint Endpoint;
3434

35-
/// <summary />
36-
public ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider authenticationProvider, string region)
37-
: this(serviceType, authenticationProvider, region, "2.1")
35+
/// <summary>
36+
/// Initializes a new instance of the <see cref="ComputeApiBuilder"/> class.
37+
/// </summary>
38+
/// <param name="serviceType">The service type for the desired compute provider.</param>
39+
/// <param name="authenticationProvider">The authentication provider.</param>
40+
/// <param name="region">The region.</param>
41+
/// <param name="useInternalUrl">if set to <c>true</c> uses the internal URLs specified in the ServiceCatalog, otherwise the public URLs are used.</param>
42+
public ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider authenticationProvider, string region, bool useInternalUrl)
43+
: this(serviceType, authenticationProvider, region, useInternalUrl, "2.1")
3844
{ }
3945

4046
/// <summary>
4147
/// Initializes a new instance of the <see cref="ComputeApiBuilder"/> class.
4248
/// </summary>
4349
/// <param name="serviceType">The service type for the desired compute provider.</param>
4450
/// <param name="authenticationProvider">The authentication provider.</param>
51+
/// <param name="useInternalUrl">if set to <c>true</c> uses the internal URLs specified in the ServiceCatalog, otherwise the public URLs are used.</param>
4552
/// <param name="region">The region.</param>
46-
/// <param name="microversion">The requested microversion.</param>
47-
protected ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider authenticationProvider, string region, string microversion)
53+
/// <param name="microversion">The requested API microversion.</param>
54+
protected ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider authenticationProvider, string region, bool useInternalUrl, string microversion)
4855
{
4956
if (serviceType == null)
5057
throw new ArgumentNullException("serviceType");
@@ -54,7 +61,7 @@ protected ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider au
5461
throw new ArgumentException("region cannot be null or empty", "region");
5562

5663
AuthenticationProvider = authenticationProvider;
57-
Endpoint = new ServiceEndpoint(serviceType, authenticationProvider, region, false, microversion, MicroversionHeader);
64+
Endpoint = new ServiceEndpoint(serviceType, authenticationProvider, region, useInternalUrl, microversion, MicroversionHeader);
5865
}
5966

6067
#region Servers

src/corelib/Compute/v2_1/ComputeService.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ public class ComputeService
2222
/// </summary>
2323
/// <param name="authenticationProvider">The authentication provider.</param>
2424
/// <param name="region">The region.</param>
25-
public ComputeService(IAuthenticationProvider authenticationProvider, string region)
25+
/// <param name="useInternalUrl">if set to <c>true</c> uses the internal URLs specified in the ServiceCatalog, otherwise the public URLs are used.</param>
26+
public ComputeService(IAuthenticationProvider authenticationProvider, string region, bool useInternalUrl = false)
2627
{
27-
_computeApi = new ComputeApiBuilder(ServiceType.Compute, authenticationProvider, region);
28+
_computeApi = new ComputeApiBuilder(ServiceType.Compute, authenticationProvider, region, useInternalUrl);
2829
}
2930

3031
#region Servers

src/corelib/Compute/v2_2/ComputeApiBuilder.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ namespace OpenStack.Compute.v2_2
77
public class ComputeApiBuilder : v2_1.ComputeApiBuilder
88
{
99
/// <summary />
10-
public ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider authenticationProvider, string region)
11-
: this(serviceType, authenticationProvider, region, "2.2")
10+
public ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider authenticationProvider, string region, bool useInternalUrl)
11+
: this(serviceType, authenticationProvider, region, useInternalUrl, "2.2")
1212
{ }
1313

1414
/// <summary />
15-
protected ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider authenticationProvider, string region, string microversion)
16-
: base(serviceType, authenticationProvider, region, microversion)
15+
protected ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider authenticationProvider, string region, bool useInternalUrl, string microversion)
16+
: base(serviceType, authenticationProvider, region, useInternalUrl, microversion)
1717
{ }
1818
}
1919
}

src/corelib/Compute/v2_2/ComputeService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ public class ComputeService
1212
private readonly ComputeApiBuilder _computeApiBuilder;
1313

1414
/// <summary />
15-
public ComputeService(IAuthenticationProvider authenticationProvider, string region)
15+
public ComputeService(IAuthenticationProvider authenticationProvider, string region, bool useInternalUrl)
1616
{
17-
_computeApiBuilder = new ComputeApiBuilder(ServiceType.Compute, authenticationProvider, region);
17+
_computeApiBuilder = new ComputeApiBuilder(ServiceType.Compute, authenticationProvider, region, useInternalUrl);
1818
}
1919

2020
#region Servers

src/corelib/Compute/v2_6/ComputeApiBuilder.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.ComponentModel;
33
using System.Threading;
44
using System.Threading.Tasks;
5-
using Flurl;
65
using Flurl.Extensions;
76
using Flurl.Http;
87
using OpenStack.Authentication;
@@ -14,13 +13,13 @@ namespace OpenStack.Compute.v2_6
1413
public class ComputeApiBuilder : v2_2.ComputeApiBuilder
1514
{
1615
/// <inheritdoc />
17-
public ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider authenticationProvider, string region)
18-
: this(serviceType, authenticationProvider, region, "2.6")
16+
public ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider authenticationProvider, string region, bool useInternalUrl)
17+
: this(serviceType, authenticationProvider, region, useInternalUrl, "2.6")
1918
{ }
2019

2120
/// <inheritdoc />
22-
protected ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider authenticationProvider, string region, string microversion)
23-
: base(serviceType, authenticationProvider, region, microversion)
21+
protected ComputeApiBuilder(IServiceType serviceType, IAuthenticationProvider authenticationProvider, string region, bool useInternalUrl, string microversion)
22+
: base(serviceType, authenticationProvider, region, useInternalUrl, microversion)
2423
{ }
2524

2625
#pragma warning disable 809

src/corelib/Compute/v2_6/ComputeService.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,10 @@ public class ComputeService
1010
{
1111
private readonly ComputeApiBuilder _computeApiBuilder;
1212

13-
/// <summary>
14-
/// Initializes a new instance of the <see cref="ComputeService"/> class.
15-
/// </summary>
16-
/// <param name="authenticationProvider">The authentication provider.</param>
17-
/// <param name="region">The region.</param>
18-
public ComputeService(IAuthenticationProvider authenticationProvider, string region)
13+
/// <summary />
14+
public ComputeService(IAuthenticationProvider authenticationProvider, string region, bool useInternalUrl = false)
1915
{
20-
_computeApiBuilder = new ComputeApiBuilder(ServiceType.Compute, authenticationProvider, region);
16+
_computeApiBuilder = new ComputeApiBuilder(ServiceType.Compute, authenticationProvider, region, useInternalUrl);
2117
}
2218

2319
#region Servers

src/corelib/Networking/v2/NetworkingApiBuilder.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public class NetworkingApiBuilder
3030
/// <param name="serviceType">The service type for the desired networking provider.</param>
3131
/// <param name="authenticationProvider">The authentication provider.</param>
3232
/// <param name="region">The region.</param>
33-
public NetworkingApiBuilder(IServiceType serviceType, IAuthenticationProvider authenticationProvider, string region)
33+
/// <param name="useInternalUrl">if set to <c>true</c> uses the internal URLs specified in the ServiceCatalog, otherwise the public URLs are used.</param>
34+
public NetworkingApiBuilder(IServiceType serviceType, IAuthenticationProvider authenticationProvider, string region, bool useInternalUrl)
3435
{
3536
if(serviceType == null)
3637
throw new ArgumentNullException("serviceType");
@@ -40,7 +41,7 @@ public NetworkingApiBuilder(IServiceType serviceType, IAuthenticationProvider au
4041
throw new ArgumentException("region cannot be null or empty", "region");
4142

4243
AuthenticationProvider = authenticationProvider;
43-
Endpoint = new ServiceEndpoint(serviceType, authenticationProvider, region);
44+
Endpoint = new ServiceEndpoint(serviceType, authenticationProvider, region, useInternalUrl);
4445
}
4546

4647
#region Networks

src/corelib/Networking/v2/NetworkingService.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ public class NetworkingService
2222
/// </summary>
2323
/// <param name="authenticationProvider">The authentication provider.</param>
2424
/// <param name="region">The region.</param>
25-
public NetworkingService(IAuthenticationProvider authenticationProvider, string region)
25+
/// <param name="useInternalUrl">if set to <c>true</c> uses the internal URLs specified in the ServiceCatalog, otherwise the public URLs are used.</param>
26+
public NetworkingService(IAuthenticationProvider authenticationProvider, string region, bool useInternalUrl = false)
2627
{
27-
_networkingApiBuilder = new NetworkingApiBuilder(ServiceType.Networking, authenticationProvider, region);
28+
_networkingApiBuilder = new NetworkingApiBuilder(ServiceType.Networking, authenticationProvider, region, useInternalUrl);
2829
}
2930

3031
#region Networks

src/corelib/ServiceEndpoint.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ public class ServiceEndpoint
2525
private readonly string _microversion;
2626
private readonly string _microversionHeader;
2727

28+
/// <summary>
29+
/// Initializes a new instance of the <see cref="ServiceEndpoint"/> class.
30+
/// </summary>
31+
/// <param name="serviceType">Type of the service.</param>
32+
/// <param name="authenticationProvider">The authentication provider.</param>
33+
/// <param name="region">The region.</param>
34+
/// <param name="useInternalUrl">Specifies if internal URLs should be used.</param>
35+
public ServiceEndpoint(IServiceType serviceType, IAuthenticationProvider authenticationProvider, string region, bool useInternalUrl)
36+
: this(serviceType, authenticationProvider, region, useInternalUrl, microversion: null, microversionHeader: null)
37+
{}
38+
2839
/// <summary>
2940
/// Initializes a new instance of the <see cref="ServiceEndpoint"/> class.
3041
/// </summary>
@@ -34,8 +45,8 @@ public class ServiceEndpoint
3445
/// <param name="useInternalUrl">Specifies if internal URLs should be used.</param>
3546
/// <param name="microversion">Specifies the microversion to send with each request.</param>
3647
/// <param name="microversionHeader">Specifies the header to use when setting the microversion.</param>
37-
public ServiceEndpoint(IServiceType serviceType, IAuthenticationProvider authenticationProvider, string region, bool useInternalUrl = false,
38-
string microversion = null, string microversionHeader = null)
48+
public ServiceEndpoint(IServiceType serviceType, IAuthenticationProvider authenticationProvider, string region, bool useInternalUrl,
49+
string microversion, string microversionHeader)
3950
{
4051
_serviceType = serviceType;
4152
_authenticationProvider = authenticationProvider;

0 commit comments

Comments
 (0)