Fetch existing stages for a specific API

@return {Promise} which resolves to all stages for the specific API
495862
function(apiId) {
        return APIG.getStages({
            restApiId: apiId
        }).promise().then(function(data) {
            return data.item;
        });
    }
1105478
function(options) {
    debug.trace('fetchAll %s', JSON.stringify(options));
    options = _.clone(options) || {};
    options.action = 'read';
    var self = this;
    function handleError(err) {
      if (options.ignoreFailures) {
        return when.resolve(self);
      }
      return when.reject(err);
    }
    return this
      .fetch(options)
      .then(function() {
        if (!self.relationDefinitions) {
          return self;
        }
        return self
          .fetchRelations(options)
          .then(function() {
            return self;
          }, handleError);
      }, handleError);
  }
512448
function() {
            var url = this.getURL(),
                $promise = ajax.fetch(url, Crocodoc.ASSET_REQUEST_RETRIES);

            // @NOTE: promise.then() creates a new promise, which does not copy
            // custom properties, so we need to create a futher promise and add
            // an object with the abort method as the new target
            return $promise.then(processJSONContent).promise({
                abort: $promise.abort
            });
        }
163040
function(apiId) {
        return new Promise(function(resolve, reject) {
            APIG.deleteRestApi({
                restApiId: apiId
            }, function(err) {
                if (err) {
                    if (err.code === 404 || err.code === 'NotFoundException') {
                        // API didn't exist to begin with
                        return resolve(apiId);
                    }

                    return reject(err);
                }

                resolve(apiId);
            });
        });
    }
171648
function getPreviousStep(that) {
        var curStage,  prevStage;
        curStage = node.game.getCurrentGameStage();
        if (curStage.stage === 0) return;
        prevStage = node.game.getPreviousStep();
        if (prevStage.stage === 0) return;
        if ((curStage.stage > prevStage.stage) && !that.acrossStages) {
            return false;
        }
        if ((curStage.round > prevStage.round) && !that.acrossRounds) {
            return false;
        }
        return prevStage;
    }
1080304
function () {
        return hooks.process(this._getApi())
            .then(function handleHooks(data) {
                if (Type.isInitialized(data) && !!data) {
                    return data;
                } else if (this.isPromiseChainStopped) {
                    return false;
                }
                return router
                    .process(this.request.method, this.parsedUrl, this.getRequestHeaders()) // find route
                    .then(this._resolveRoute.bind(this)); // resolve route chain
            }.bind(this)) // handle hook chain
            .then(this._compress.bind(this))
            .then(this._render.bind(this)) // resolve route chain
            .catch(this._handleError.bind(this)) // catch hook error
            .then(this._compress.bind(this))
            .then(this._render.bind(this)) // render hook error
            .catch(this._handleError.bind(this)) // catch render error
            .then(this._compress.bind(this))
            .then(this._render.bind(this)); // resolve render error
    }
966780
function() {
                var def = _promise.deferred();

                folderObj.ensureFolder().success(function() {
                    var subFolderCount = 0;
                    for (var folderName in _subFolders) {
                        subFolderCount++;
                    }

                    if (subFolderCount > 0) {
                        var resolver = def.getMultiStepResolver(subFolderCount);
                        for (var folderName in _subFolders) {
                            _subFolders[folderName].ensureFolderTree()
                                .success(function() {
                                    resolver.stepComplete();
                                }).fail(function() {
                                    resolver.reject();
                                });
                        }
                    } else {
                        def.resolve();
                    }
                });

                return def.promise();
            }
1357362
function getPRsForRepo(repo) {
  print(['Fetching PRs for ', clc.yellow.bold(`${repo.owner.login}/${repo.name}`)], debug);
  return new Promise((resolve, reject) => {
    github.pullRequests.getAll({
      user: repo.owner.login,
      repo: repo.name,
      state: 'open'
    }, (err, prs) => {
      if (err) {
        return reject(err);
      }
      return resolve(prs.filter((pr) => {
        return pr && pr.head;
      }));
    });
  });
}
107095
async function fetchAll(connection, query, params){

    // execute query
    const [result] = await _query(connection, query, params);

    // entry found ?
    return result || [];
}
458168
def fetch(params, endpoint_path = 'previews')
      options = prepare_request(params)
      response = default_connection(BASE_URL, params.debug)
                   .post do |req|
                    req.url("/v2/#{endpoint_path}/")
                     req.body = JSON.generate(options)
                   end

      parse(response.body)
    end
697906
function getAllItems() {
  return new Promise(resolve => {
    const res = [];
    return instance.pkgs.then(db => {
      db.transaction(db.name)
        .objectStore(db.name).openCursor()
        .onsuccess = event => {
          const cursor = event.target.result;
          if (cursor) {
            res.push(cursor.value);
            cursor.continue();
          } else {
            resolve(res);
          }
        };
    });
  });
}
912983
function(options) {
    var self = this;

    options = options || {};

    var error = options.error;

    var fns = [
      _.bind(self.preFetch, self, options),
      _.bind(PromisedModel.prototype.fetch, self, options),
      _.bind(self.afterFetch, self, options)
    ];
    return sequence(fns).then(function () {
      self.fetchStatus = 'fetched';
      return self;
    }, function (err) {
      if (error) error.call(options, self, err);
      return failWithError(options, err);
    });
  }
272619
function loadEndpoints() {
  // Shortcut if endpoints already have been loaded
  if (endpoints !== undefined) {
    return Promise.resolve(endpoints);
  }

  const endpointSpecsPath = path.join(process.cwd(), plugin.config.endpointsPath);

  return plugin.myrmex.fire('beforeEndpointsLoad')
  .spread(() => {
    const endpointPromises = [];
    file.walkSync(endpointSpecsPath, (dirPath, dirs, files) => {
      // We are looking for directories that have the name of an HTTP method
      const subPath = dirPath.substr(endpointSpecsPath.length);
      const resourcePathParts = subPath.split(path.sep);
      const method = resourcePathParts.pop();
      if (plugin.httpMethods.indexOf(method) === -1) { return; }

      // We construct the path to the resource
      const resourcePath = resourcePathParts.join('/');

      endpointPromises.push(loadEndpoint(endpointSpecsPath, resourcePath, method));
    });
    return Promise.all(endpointPromises);
  })
  .then(endpoints => {
    return plugin.myrmex.fire('afterEndpointsLoad', endpoints);
  })
  .spread(loadedEndpoints => {
    endpoints = loadedEndpoints;
    return Promise.resolve(endpoints);
  })
  .catch(e => {
    if (e.code === 'ENOENT' && path.basename(e.path) === path.basename(plugin.config.endpointsPath)) {
      return Promise.resolve([]);
    }
    Promise.reject(e);
  });
}
971778
function () {
  var deferred = Q.defer();
  getPlatforms().then(function (platforms) {
    var activePlatforms = _(platforms).where({ isAdded : true });
    if (activePlatforms.length > 0) {
      display.success('platforms found: ' + _(activePlatforms).pluck('name').join(', '));
      deferred.resolve();
    } else {
      display.error(
        'No cordova platforms found. ' +
        'Make sure you are in the root folder of your Cordova project ' +
        'and add platforms with \'cordova platform add\''
      );
      deferred.reject();
    }
  });
  return deferred.promise;
}
1153007
function fetchResults (searchText) {
    var items = $scope.$parent.$eval(itemExpr),
        term  = searchText.toLowerCase(),
        isList = angular.isArray(items),
        isPromise = !!items.then; // Every promise should contain a `then` property

    if (isList) onResultsRetrieved(items);
    else if (isPromise) handleAsyncResults(items);

    function handleAsyncResults(items) {
      if (!items) return;

      items = $q.when(items);
      fetchesInProgress++;
      setLoading(true);

      $mdUtil.nextTick(function () {
          items
            .then(onResultsRetrieved)
            .finally(function(){
              if (--fetchesInProgress === 0) {
                setLoading(false);
              }
            });
      },true, $scope);
    }

    function onResultsRetrieved(matches) {
      cache[term] = matches;

      // Just cache the results if the request is now outdated.
      // The request becomes outdated, when the new searchText has changed during the result fetching.
      if ((searchText || '') !== ($scope.searchText || '')) {
        return;
      }

      handleResults(matches);
    }
  }
1274276
function() {
        const flow = this._chooseFlow();
        console.log("Active flow => %s", JSON.stringify(flow));
        const nextStage = this._firstUncompletedStage(flow);
        console.log("Next stage: %s", nextStage);
        return nextStage;
    }
1321846
function () {
    const oThis = this
      , promiseArray = [];

    return new Promise(async function (onResolve, onReject) {
      for (var chain in setupConfig.chains) {
        promiseArray.push(oThis._isRunning(chain));
      }
      return Promise.all(promiseArray).then(onResolve);
    });
  }