code: public void resolveRequestEndpoint(Request<?> request, String regionString) {
          if (regionString != null) {
              final Region r = RegionUtils.getRegion(regionString);
  
              if (r == null) {
                  throw new SdkClientException("Not able to determine region" +
                          " for " + regionString + ".Please upgrade to a newer " +
                          "version of the SDK");
              }
  
              endpointBuilder.withRegion(r);
          }
          final URI endpoint = endpointBuilder.getServiceEndpoint();
          if (shouldUseVirtualAddressing(endpoint)) {
              request.setEndpoint(convertToVirtualHostEndpoint(endpoint, bucketName));
              request.setResourcePath(SdkHttpUtils.urlEncode(getHostStyleResourcePath(), true));
          } else {
              request.setEndpoint(endpoint);
              if (bucketName != null) {
                  request.setResourcePath(SdkHttpUtils.urlEncode(getPathStyleResourcePath(), true));
              }
          }
      }
docs: Set the request's endpoint and resource path with the new region provided
  
  @param request Request to set endpoint for
  @param regionString  New region to determine endpoint to hit