@@ -26,19 +26,9 @@ public class ExternalResourceDefinitionBuilder
26
26
protected virtual string ? Name { get ; set ; }
27
27
28
28
/// <summary>
29
- /// Gets/sets the uri that references the external resource
29
+ /// Gets/sets the endpoint at which to get the defined resource
30
30
/// </summary>
31
- protected virtual Uri ? Uri { get ; set ; }
32
-
33
- /// <summary>
34
- /// Gets/sets a reference to the authentication policy to use
35
- /// </summary>
36
- protected virtual Uri ? AuthenticationReference { get ; set ; }
37
-
38
- /// <summary>
39
- /// Gets/sets the authentication policy to use
40
- /// </summary>
41
- protected virtual AuthenticationPolicyDefinition ? Authentication { get ; set ; }
31
+ protected virtual OneOf < EndpointDefinition , Uri > ? Endpoint { get ; set ; }
42
32
43
33
/// <inheritdoc/>
44
34
public virtual IExternalResourceDefinitionBuilder WithName ( string name )
@@ -48,53 +38,33 @@ public virtual IExternalResourceDefinitionBuilder WithName(string name)
48
38
}
49
39
50
40
/// <inheritdoc/>
51
- public virtual IExternalResourceDefinitionBuilder WithUri ( Uri uri )
41
+ public virtual IExternalResourceDefinitionBuilder WithEndpoint ( OneOf < EndpointDefinition , Uri > endpoint )
52
42
{
53
- ArgumentNullException . ThrowIfNull ( uri ) ;
54
- this . Uri = uri ;
43
+ ArgumentNullException . ThrowIfNull ( endpoint ) ;
44
+ this . Endpoint = endpoint ;
55
45
return this ;
56
46
}
57
47
58
48
/// <inheritdoc/>
59
- public virtual IExternalResourceDefinitionBuilder UseAuthentication ( Uri reference )
60
- {
61
- ArgumentNullException . ThrowIfNull ( reference ) ;
62
- this . AuthenticationReference = reference ;
63
- return this ;
64
- }
65
-
66
- /// <inheritdoc/>
67
- public virtual IExternalResourceDefinitionBuilder UseAuthentication ( AuthenticationPolicyDefinition authentication )
68
- {
69
- ArgumentNullException . ThrowIfNull ( authentication ) ;
70
- this . Authentication = authentication ;
71
- return this ;
72
- }
73
-
74
- /// <inheritdoc/>
75
- public virtual IExternalResourceDefinitionBuilder UseAuthentication ( Action < IAuthenticationPolicyDefinitionBuilder > setup )
49
+ public virtual IExternalResourceDefinitionBuilder WithEndpoint ( Action < IEndpointDefinitionBuilder > setup )
76
50
{
77
51
ArgumentNullException . ThrowIfNull ( setup ) ;
78
- var builder = new AuthenticationPolicyDefinitionBuilder ( ) ;
52
+ var builder = new EndpointDefinitionBuilder ( ) ;
79
53
setup ( builder ) ;
80
- this . Authentication = builder . Build ( ) ;
54
+ this . Endpoint = builder . Build ( ) ;
81
55
return this ;
82
56
}
83
57
84
58
/// <inheritdoc/>
85
59
public virtual ExternalResourceDefinition Build ( )
86
60
{
87
- if ( this . Uri == null ) throw new NullReferenceException ( "The uri that references the external resource must be set" ) ;
88
- var reference = new ExternalResourceDefinition ( )
61
+ if ( this . Endpoint == null ) throw new NullReferenceException ( "The endpoint at which to get the defined resource must be set" ) ;
62
+ var externalResource = new ExternalResourceDefinition ( )
89
63
{
90
64
Name = this . Name ,
91
- Uri = this . Uri
65
+ Endpoint = this . Endpoint
92
66
} ;
93
- if ( this . AuthenticationReference == null ) reference . Authentication = new ( ) { Ref = this . AuthenticationReference } ;
94
- else if ( this . Authentication != null ) reference . Authentication = this . Authentication ;
95
- return reference ;
67
+ return externalResource ;
96
68
}
97
69
98
- EndpointDefinition IEndpointDefinitionBuilder < IExternalResourceDefinitionBuilder > . Build ( ) => this . Build ( ) ;
99
-
100
70
}
0 commit comments