Skip to content

Commit a6a06b5

Browse files
Transparent Proxy: Seamless handling of Cross-level consumption of destination-fragment pairs (#903)
Co-authored-by: Matthias Kuhr <[email protected]>
1 parent e2643f5 commit a6a06b5

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyDestination.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public class TransparentProxyDestination implements HttpDestination
3838
static final String TENANT_SUBDOMAIN_HEADER_KEY = "x-tenant-subdomain";
3939
static final String TENANT_ID_HEADER_KEY = "x-tenant-id";
4040
static final String FRAGMENT_OPTIONAL_HEADER_KEY = "x-fragment-optional";
41+
static final String DESTINATION_LEVEL_HEADER_KEY = "x-destination-level";
42+
static final String FRAGMENT_LEVEL_HEADER_KEY = "x-fragment-level";
4143
static final String TOKEN_SERVICE_TENANT_HEADER_KEY = "x-token-service-tenant";
4244
static final String CLIENT_ASSERTION_HEADER_KEY = "x-client-assertion";
4345
static final String CLIENT_ASSERTION_TYPE_HEADER_KEY = "x-client-assertion-type";
@@ -675,6 +677,36 @@ public GatewayBuilder fragmentName( @Nonnull final String fragmentName )
675677
return header(new Header(FRAGMENT_NAME_HEADER_KEY, fragmentName));
676678
}
677679

680+
/**
681+
* Sets the destination level for the destination-gateway. See <a href=
682+
* "https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/dynamic-lookup-of-destinations">https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/dynamic-lookup-of-destinations</a>
683+
*
684+
* @param destinationLevel
685+
* The level of the destination to use.
686+
* @return This builder instance for method chaining.
687+
*/
688+
@Nonnull
689+
public GatewayBuilder destinationLevel(
690+
@Nonnull final DestinationServiceOptionsAugmenter.CrossLevelScope destinationLevel )
691+
{
692+
return header(new Header(DESTINATION_LEVEL_HEADER_KEY, destinationLevel.toString()));
693+
}
694+
695+
/**
696+
* Sets the fragment level for the destination-gateway. See <a href=
697+
* "https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/dynamic-lookup-of-destinations">https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/dynamic-lookup-of-destinations</a>
698+
*
699+
* @param fragmentLevel
700+
* The level of the fragment to use.
701+
* @return This builder instance for method chaining.
702+
*/
703+
@Nonnull
704+
public GatewayBuilder fragmentLevel(
705+
@Nonnull final DestinationServiceOptionsAugmenter.CrossLevelScope fragmentLevel )
706+
{
707+
return header(new Header(FRAGMENT_LEVEL_HEADER_KEY, fragmentLevel.toString()));
708+
}
709+
678710
/**
679711
* Sets the fragment optional flag for the destination-gateway. See <a href=
680712
* "https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/dynamic-lookup-of-destinations">https://help.sap.com/docs/connectivity/sap-btp-connectivity-cf/dynamic-lookup-of-destinations</a>

cloudplatform/connectivity-destination-service/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyDestinationTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,22 @@ void testGatewayHeaders()
7575
final TransparentProxyDestination destination =
7676
TransparentProxyDestination
7777
.gateway(TEST_DEST_NAME, VALID_URI.toString())
78+
.destinationLevel(DestinationServiceOptionsAugmenter.CrossLevelScope.SUBACCOUNT)
7879
.fragmentName("fragName")
80+
.fragmentLevel(DestinationServiceOptionsAugmenter.CrossLevelScope.PROVIDER_SUBACCOUNT)
7981
.fragmentOptional(true)
8082
.build();
8183

8284
assertThat(destination.getHeaders(VALID_URI))
8385
.contains(
8486
new Header(TransparentProxyDestination.DESTINATION_NAME_HEADER_KEY, TEST_DEST_NAME),
87+
new Header(
88+
TransparentProxyDestination.DESTINATION_LEVEL_HEADER_KEY,
89+
DestinationServiceOptionsAugmenter.CrossLevelScope.SUBACCOUNT.toString()),
8590
new Header(TransparentProxyDestination.FRAGMENT_NAME_HEADER_KEY, "fragName"),
91+
new Header(
92+
TransparentProxyDestination.FRAGMENT_LEVEL_HEADER_KEY,
93+
DestinationServiceOptionsAugmenter.CrossLevelScope.PROVIDER_SUBACCOUNT.toString()),
8694
new Header(TransparentProxyDestination.FRAGMENT_OPTIONAL_HEADER_KEY, "true"));
8795
}
8896

0 commit comments

Comments
 (0)