code: function optionalDiscoverEndpoint(request) {
    var service = request.service;
    var api = service.api;
    var operationModel = api.operations ? api.operations[request.operation] : undefined;
    var inputShape = operationModel ? operationModel.input : undefined;
  
    var identifiers = marshallCustomIdentifiers(request, inputShape);
    var cacheKey = getCacheKey(request);
    if (Object.keys(identifiers).length > 0) {
      cacheKey = util.update(cacheKey, identifiers);
      if (operationModel) cacheKey.operation = operationModel.name;
    }
    var endpoints = AWS.endpointCache.get(cacheKey);
    if (endpoints && endpoints.length === 1 && endpoints[0].Address === '') {
      //endpoint operation is being made but response not yet received
      //or endpoint operation just failed in 1 minute
      return;
    } else if (endpoints && endpoints.length > 0) {
      //found endpoint record from cache
      request.httpRequest.updateEndpoint(endpoints[0].Address);
    } else {
      //endpoint record not in cache or outdated. make discovery operation
      var endpointRequest = service.makeRequest(api.endpointOperation, {
        Operation: operationModel.name,
        Identifiers: identifiers,
      });
      addApiVersionHeader(endpointRequest);
      endpointRequest.removeListener('validate', AWS.EventListeners.Core.VALIDATE_PARAMETERS);
      endpointRequest.removeListener('retry', AWS.EventListeners.Core.RETRY_CHECK);
      //put in a placeholder for endpoints already requested, prevent
      //too much in-flight calls
      AWS.endpointCache.put(cacheKey, [{
        Address: '',
        CachePeriodInMinutes: 1
      }]);
      endpointRequest.send(function(err, data) {
        if (data && data.Endpoints) {
          AWS.endpointCache.put(cacheKey, data.Endpoints);
        } else if (err) {
          AWS.endpointCache.put(cacheKey, [{
            Address: '',
            CachePeriodInMinutes: 1 //not to make more endpoint operation in next 1 minute
          }]);
        }
      });
    }
  }
docs: Call endpoint discovery operation when it's optional.
  When endpoint is available in cache then use the cached endpoints. If endpoints
  are unavailable then use regional endpoints and call endpoint discovery operation
  asynchronously. This is turned off by default.
  @param [object] request object
  @api private