Api1.6 equivalent
356778
def get_servers_by_tag(tags)
      # Take tags and collapse it,
      # Default case, tag is AND
      if @match_all
        t = tags.join("&tag=")
        filter = "tag=#{t}"
        servers = Connection.instances(filter)
      else
        t = tags.join(",")
        filter = "tag=#{t}"
        servers = Connection.instances(filter)
      end

      if servers.nil?
        if @ignore_errors
          Log.warn "[#{Chimp.get_job_uuid}] Tag query returned no results: #{tags.join(" ")}"
        else
          raise "[#{Chimp.get_job_uuid}] Tag query returned no results: #{tags.join(" ")}\n"
        end
      elsif servers.empty?
        if @ignore_errors
          Log.warn "[#{Chimp.get_job_uuid}] Tag query returned no results: #{tags.join(" ")}"
        else
          raise "[#{Chimp.get_job_uuid}] Tag query returned no results: #{tags.join(" ")}\n"
        end
      end

      servers = verify_tagged_instances(servers,tags)

      return(servers)
    end
605516
private ApiListType executeRequest(Call call) throws IOException, ApiException {
    return client.handleResponse(call.execute(), listType);
  }
1165360
def build_api_object(uo=None, api_key=None, uo_id=None, uo_type=None):
        
        if uo is not None:
            api_key = uo.resolve_api_key() if uo.resolve_api_key() is not None else api_key
            uo_id = uo.uo_id if uo.uo_id is not None else uo_id
            uo_type = uo.uo_type if uo.uo_type is not None else uo_type

        if uo_type is None or uo_type == EBConsts.INVALID_KEY_TYPE:
            uo_type = 0

        return "%s%010x%010x" % (api_key, uo_id, uo_type)
39921
def generate_api_for_source(self, source_fpath: str):
        """"""
        content = self.convert_content(source_fpath)
        if content is None:
            return

        dest_fpath = self.dest_fpath(source_fpath)
        self.create_fpath_dir(dest_fpath)

        with open(dest_fpath, 'w+') as dest_f:
            json.dump(content, dest_f, cls=DateTimeJsonEncoder)
624617
def api(self):
        
        functions = [x[0]for x in inspect.getmembers(self, predicate=inspect.ismethod)
                     if not x[0].startswith('_')]

        full_api = {
            'doc': u"When posting data you have to use the JSON format.",
            'api': []
        }
        my_daemon_type = "%s" % getattr(self.app, 'type', 'unknown')
        my_address = getattr(self.app, 'host_name', getattr(self.app, 'name', 'unknown'))
        if getattr(self.app, 'address', '127.0.0.1') not in ['127.0.0.1']:
            # If an address is explicitely specified, I must use it!
            my_address = self.app.address
        for fun in functions:
            endpoint = {
                'daemon': my_daemon_type,
                'name': fun,
                'doc': getattr(self, fun).__doc__,
                'uri': '%s://%s:%s/%s' % (getattr(self.app, 'scheme', 'http'),
                                          my_address,
                                          self.app.port, fun),
                'args': {}
            }

            try:
                spec = inspect.getfullargspec(getattr(self, fun))
            except Exception:  # pylint: disable=broad-except
                # pylint: disable=deprecated-method
                spec = inspect.getargspec(getattr(self, fun))
            args = [a for a in spec.args if a not in ('self', 'cls')]
            if spec.defaults:
                a_dict = dict(list(zip(args, spec.defaults)))
            else:
                a_dict = dict(list(zip(args, ("No default value",) * len(args))))

            endpoint["args"] = a_dict
            full_api['api'].append(endpoint)

        return full_api
136272
function ApiclientAdapter(resource) {
    this.admin = admin;
    this.resource = resource || {};

    // loop through API interface for resource to get methods to expose
    var me = this;
    _.each(resource.api, function (methodInfo, httpMethod) {
        _.each(methodInfo, function (operation, path) {
            me[operation] = function (req) {
                return me.send(httpMethod, path, req);
            };
        });
    });
}
3881
def _api(fn):
        """"""
        @_functools.wraps(fn)
        def _fn(self, *args, **kwargs):
            self._throttle_wait()
            if not self._SID:
                raise RuntimeError('Session closed. Invoke connect() before.')
            return fn(self, *args, **kwargs)
        return _fn
228172
function() {
  // Path to apis.js file
  var apis_js = path.join(__dirname, '../src', 'apis.js');
  // Create content
  // Use json-stable-stringify rather than JSON.stringify to guarantee
  // consistent ordering (see http://bugzil.la/1200519)
  var content = "/* eslint-disable */\nmodule.exports = " + stringify(apis, {
    space: '  '
  }) + ";";
  fs.writeFileSync(apis_js, content, {encoding: 'utf-8'});
}
86976
def api_version(self, v):
        """"""
        self._api_version = v
        if (self._api_version >= '2.0'):
            self.default_quality = 'default'
            self.allowed_qualities = ['default', 'color', 'bitonal', 'gray']
        else:  # versions 1.0 and 1.1
            self.default_quality = 'native'
            self.allowed_qualities = ['native', 'color', 'bitonal', 'grey']
684337
private ObjectNode makeRequest(final String api) {
        ObjectNode req = JSON.objectNode();
        req.put("api", api);
        return req;
    }
774979
def to_api_repr(self):
        """"""
        configuration = self._configuration.to_api_repr()

        resource = {
            "jobReference": self._properties["jobReference"],
            "configuration": configuration,
        }
        configuration["query"]["query"] = self.query

        return resource
1087095
def _api_group_for_type(cls):
    
    _groups = {
        (u"v1beta1", u"Deployment"): u"extensions",
        (u"v1beta1", u"DeploymentList"): u"extensions",
        (u"v1beta1", u"ReplicaSet"): u"extensions",
        (u"v1beta1", u"ReplicaSetList"): u"extensions",
    }
    key = (
        cls.apiVersion,
        cls.__name__.rsplit(u".")[-1],
    )
    group = _groups.get(key, None)
    return group
643859
def lint_api(api_name, old, new, locations):
    """"""
    is_new_api = not old
    api_location = locations['api']
    changelog = new.get('changelog', {})
    changelog_location = api_location

    if locations['changelog']:
        changelog_location = list(locations['changelog'].values())[0]

    # apis must have documentation if they are new
    if not new.get('doc'):
        msg_type = LintError if is_new_api else LintWarning
        yield msg_type(
            'doc',
            'missing docstring documentation',
            api_name=api_name,
            location=locations.get('view', api_location)
        )

    introduced_at = new.get('introduced_at')
    if introduced_at is None:
        yield LintError(
            'introduced_at',
            'missing introduced_at field',
            location=api_location,
        )

    if not is_new_api:
        # cannot change introduced_at if we already have it
        old_introduced_at = old.get('introduced_at')
        if old_introduced_at is not None:
            if old_introduced_at != introduced_at:
                yield LintError(
                    'introduced_at',
                    'introduced_at changed from {} to {}',
                    old_introduced_at,
                    introduced_at,
                    api_name=api_name,
                    location=api_location,
                )

    # cannot change url
    if new['url'] != old.get('url', new['url']):
        yield LintError(
            'url',
            'url changed from {} to {}',
            old['url'],
            new['url'],
            api_name=api_name,
            location=api_location,
        )

    # cannot add required fields
    for removed in set(old.get('methods', [])) - set(new['methods']):
        yield LintError(
            'methods',
            'HTTP method {} removed',
            removed,
            api_name=api_name,
            location=api_location,
        )

    for schema in ['request_schema', 'response_schema']:
        new_schema = new.get(schema)
        if new_schema is None:
            continue

        schema_location = locations[schema]
        old_schema = old.get(schema, {})

        for message in walk_schema(
                schema, old_schema, new_schema, root=True, new_api=is_new_api):
            if isinstance(message, CheckChangelog):
                if message.revision not in changelog:
                    yield LintFixit(
                        message.name,
                        'No changelog entry for revision {}',
                        message.revision,
                        location=changelog_location,
                    )
            else:
                # add in here, saves passing it down the recursive call
                message.location = schema_location
                yield message
301563
function populateApiFromInterface(api, iface) {
  Object.keys(iface).forEach(function (key) {
    api.add(key, iface[key]);
  });
}
1081839
def apis(self):
        """"""
        value = self.attributes['apis']
        if isinstance(value, six.string_types):
            value = shlex.split(value)
        return value
194918
async def batch_call_api(container, apis, timeout = 120.0):
    
    apiHandles = [(object(), api) for api in apis]
    apiEvents = [ModuleAPICall(handle, targetname, name, params = params)
                 for handle, (targetname, name, params) in apiHandles]
    apiMatchers = tuple(ModuleAPIReply.createMatcher(handle) for handle, _ in apiHandles)
    async def process():
        for e in apiEvents:
            await container.wait_for_send(e)
    container.subroutine(process(), False)
    eventdict = {}
    async def process2():
        ms = len(apiMatchers)
        matchers = Diff_(apiMatchers)
        while ms:
            ev, m = await matchers
            matchers = Diff_(matchers, remove=(m,))
            eventdict[ev.handle] = ev
    await container.execute_with_timeout(timeout, process2())
    for e in apiEvents:
        if e.handle not in eventdict:
            e.canignore = True
            container.scheduler.ignore(ModuleAPICall.createMatcher(e.handle))
    return [eventdict.get(handle, None) for handle, _ in apiHandles]
1281621
protected Api getApi(String orgId, String apiId, String version) throws IOException {
        String apiIdx = getApiIdx(orgId, apiId, version);
        Api api;
        synchronized (mutex) {
            api = apiCache.get(apiIdx);
        }

        if (api == null) {
            api = super.getApi(getApiId(orgId, apiId, version));
            synchronized (mutex) {
                if (api != null) {
                    apiCache.put(apiIdx, api);
                }
            }
        }

        return api;
    }