code: @Deprecated
      public static String parseServiceName(URI endpoint) {
          String host = endpoint.getHost();
  
          // If we don't recognize the domain, throw an exception.
          if (!host.endsWith(".amazonaws.com")) {
              throw new IllegalArgumentException(
                  "Cannot parse a service name from an unrecognized endpoint ("
                  + host
                  + ").");
          }
  
          String serviceAndRegion =
              host.substring(0, host.indexOf(".amazonaws.com"));
  
          // Special cases for S3 endpoints with bucket names embedded.
          if (serviceAndRegion.endsWith(".s3")
              || S3_ENDPOINT_PATTERN.matcher(serviceAndRegion).matches()) {
              return "s3";
          }
  
          char separator = '.';
  
          // If we don't detect a separator between service name and region, then
          // assume that the region is not included in the hostname, and it's only
          // the service name (ex: "http://iam.amazonaws.com").
          if (serviceAndRegion.indexOf(separator) == -1) {
              return serviceAndRegion;
          }
  
          String service =
              serviceAndRegion.substring(0, serviceAndRegion.indexOf(separator));
  
          return service;
      }
docs: Parses the service name from an endpoint. Can only handle endpoints of
  the form 'service.[region.]amazonaws.com'.
  
  @Deprecated This method currently doesn't support BJS endpoints. This
  method is used only in AWS4Signer to identify the service name from an
  endpoint. This method is broken as it no longer returns the service
  name to used for signing for all AWS services. This method will be
  removed as part of next major version upgrade.