Initializes the Cloudstack API
        Accepts arguments: 
            api_host (localhost)
            api_port (443)
            api_ssl (True)
            api_key
            api_secret
184071
def Initialize(api_key, api_secret, api_host="localhost", api_port=443, api_ssl=True, asyncblock=False, timeout=10, req_method="get"):
    
    config = Config()

    if api_ssl:
        proto = "https"
    else:
        proto = "http"
    api_url = "%s://%s:%s/client/api" % (proto, api_host, api_port)
    if os.access(os.path.expanduser("~") , os.W_OK):
        d = os.path.expanduser("~")
    else:
        d = tempfile.gettempdir()
    cache_file = os.getenv('MOLNCTRL_CACHE') or '.molnctrl_cache'
    if os.path.exists(os.path.join(d, cache_file)):
        apicache = pickle.load(open( os.path.join(d, cache_file), "rb" ))
    else:
        method = {'description': u'lists all available apis on the server, provided by the Api Discovery plugin',
            'isasync': False,
            'name': u'listApis',
            'params': [{'description': u'API name',
            'length': 255,
            'name': u'name',
            'related': [],
            'required': False,
            'type': u'string'}],
            'related': [],
            'requiredparams': []}
        _create_api_method(CSApi, "list_apis", method)
        c = CSApi(api_url, api_key, api_secret, asyncblock)
        apicache = cachemaker.monkeycache(c.list_apis())
        pickle.dump(apicache, open(os.path.join(d, cache_file), "wb"))

    for verb, methods in six.iteritems(apicache):
        if isinstance(methods, dict):
            for method in six.iterkeys(methods):
                _create_api_method(CSApi, "%s_%s" % (verb, method), methods[method])
    return CSApi(api_url, api_key, api_secret, asyncblock, timeout, req_method)
309585
def init(self):
        
        # check for existing environment. Only allow subsequent
        # 'mlaunch init' if they are identical.
        if self._load_parameters():
            if self.loaded_args != self.args:
                raise SystemExit('A different environment already exists '
                                 'at %s.' % self.dir)
            first_init = False
        else:
            first_init = True

        self.ssl_pymongo_options = self._get_ssl_pymongo_options(self.args)

        if (self._get_ssl_server_args() and not
                self.args['sslAllowConnectionsWithoutCertificates'] and not
                self.args['sslClientCertificate'] and not
                self.args['sslClientPEMKeyFile']):
            sys.stderr.write('warning: server requires certificates but no'
                             ' --sslClientCertificate provided\n')

        # number of default config servers
        if self.args['config'] == -1:
            self.args['config'] = 1

        # Check if config replicaset is applicable to this version
        current_version = self.getMongoDVersion()

        # Exit with error if --csrs is set and MongoDB < 3.1.0
        if (self.args['csrs'] and
                LooseVersion(current_version) < LooseVersion("3.1.0") and
                LooseVersion(current_version) != LooseVersion("0.0.0")):
            errmsg = (" \n * The '--csrs' option requires MongoDB version "
                      "3.2.0 or greater, the current version is %s.\n"
                      % current_version)
            raise SystemExit(errmsg)

        # add the 'csrs' parameter as default for MongoDB >= 3.3.0
        if (LooseVersion(current_version) >= LooseVersion("3.3.0") or
                LooseVersion(current_version) == LooseVersion("0.0.0")):
            self.args['csrs'] = True

        # construct startup strings
        self._construct_cmdlines()

        # write out parameters
        if self.args['verbose']:
            print("writing .mlaunch_startup file.")
        self._store_parameters()

        # exit if running in testing mode
        if self.test:
            sys.exit(0)

        # check if authentication is enabled, make key file
        if self.args['auth'] and first_init:
            if not os.path.exists(self.dir):
                os.makedirs(self.dir)
            keyfile = os.path.join(self.dir, "keyfile")
            os.system('openssl rand -base64 753 > %s' % keyfile)
            if os.name != 'nt':
                os.system('chmod 600 %s' % keyfile)

        # if not all ports are free, complain and suggest alternatives.
        all_ports = self.get_tagged(['all'])
        ports_avail = self.wait_for(all_ports, 1, 1, to_start=False)

        if not all(map(itemgetter(1), ports_avail)):
            dir_addon = (' --dir %s' % self.relative_dir
                         if self.relative_dir != './data' else '')
            errmsg = ('\nThe following ports are not available: %s\n\n'
                      % ', '.join([str(p[0])
                                   for p in ports_avail if not p[1]]))
            errmsg += (" * If you want to restart nodes from this "
                       "environment, use 'mlaunch start%s' instead.\n"
                       % dir_addon)
            errmsg += (" * If the ports are used by a different mlaunch "
                       "environment, stop those first with 'mlaunch stop "
                       "--dir <env>'.\n")
            errmsg += (" * You can also specify a different port range with "
                       "an additional '--port <startport>'\n")
            raise SystemExit(errmsg)

        if self.args['sharded']:

            shard_names = self._get_shard_names(self.args)

            # start mongod (shard and config) nodes and wait
            nodes = self.get_tagged(['mongod', 'down'])
            self._start_on_ports(nodes, wait=True, override_auth=True)

            # initiate replica sets if init is called for the first time
            if first_init:
                if self.args['csrs']:
                    # Initiate config servers in a replicaset
                    if self.args['verbose']:
                        print('Initiating config server replica set.')
                    members = sorted(self.get_tagged(["config"]))
                    self._initiate_replset(members[0], "configRepl")
                for shard in shard_names:
                    # initiate replica set on first member
                    if self.args['verbose']:
                        print('Initiating shard replica set %s.' % shard)
                    members = sorted(self.get_tagged([shard]))
                    self._initiate_replset(members[0], shard)

            # add mongos
            mongos = sorted(self.get_tagged(['mongos', 'down']))
            self._start_on_ports(mongos, wait=True, override_auth=True)

            if first_init:
                # add shards
                mongos = sorted(self.get_tagged(['mongos']))
                con = self.client('localhost:%i' % mongos[0])

                shards_to_add = len(self.shard_connection_str)
                nshards = con['config']['shards'].count()
                if nshards < shards_to_add:
                    if self.args['replicaset']:
                        print("adding shards. can take up to 30 seconds...")
                    else:
                        print("adding shards.")

                shard_conns_and_names = list(zip(self.shard_connection_str,
                                                 shard_names))
                while True:
                    try:
                        nshards = con['config']['shards'].count()
                    except Exception:
                        nshards = 0
                    if nshards >= shards_to_add:
                        break

                    for conn_str, name in shard_conns_and_names:
                        try:
                            res = con['admin'].command(SON([('addShard',
                                                             conn_str),
                                                       ('name', name)]))
                        except Exception as e:
                            if self.args['verbose']:
                                print('%s will retry in a moment.' % e)
                            continue

                        if res['ok']:
                            if self.args['verbose']:
                                print("shard %s added successfully" % conn_str)
                                shard_conns_and_names.remove((conn_str, name))
                                break
                        else:
                            if self.args['verbose']:
                                print(res + ' - will retry')

                    time.sleep(1)

        elif self.args['single']:
            # just start node
            nodes = self.get_tagged(['single', 'down'])
            self._start_on_ports(nodes, wait=False)

        elif self.args['replicaset']:
            # start nodes and wait
            nodes = sorted(self.get_tagged(['mongod', 'down']))
            self._start_on_ports(nodes, wait=True)

            # initiate replica set
            if first_init:
                self._initiate_replset(nodes[0], self.args['name'])

        # wait for all nodes to be running
        nodes = self.get_tagged(['all'])
        self.wait_for(nodes)

        # now that nodes are running, add admin user if authentication enabled
        if self.args['auth'] and self.args['initial-user'] and first_init:
            self.discover()
            nodes = []

            if self.args['sharded']:
                nodes = self.get_tagged(['mongos', 'running'])
            elif self.args['single']:
                nodes = self.get_tagged(['single', 'running'])
            elif self.args['replicaset']:
                print("waiting for primary to add a user.")
                if self._wait_for_primary():
                    nodes = self.get_tagged(['primary', 'running'])
                else:
                    raise RuntimeError("failed to find a primary, so adding "
                                       "admin user isn't possible")

            if not nodes:
                raise RuntimeError("can't connect to server, so adding admin "
                                   "user isn't possible")

            roles = []
            found_cluster_admin = False
            if self.args['auth_role_docs']:
                for role_str in self.args['auth_roles']:
                    role_doc = json.loads(role_str)
                    roles.append(role_doc)
                    if role_doc['role'] == "clusterAdmin":
                        found_cluster_admin = True
            else:
                roles = self.args['auth_roles']
                found_cluster_admin = "clusterAdmin" in roles

            if not found_cluster_admin:
                warnings.warn("the stop command will not work with auth "
                              "because the user does not have the "
                              "clusterAdmin role")

            self._add_user(sorted(nodes)[0], name=self.args['username'],
                           password=self.args['password'],
                           database=self.args['auth_db'],
                           roles=roles)

            if self.args['sharded']:
                for shard in shard_names:
                    members = sorted(self.get_tagged([shard]))
                    if self.args['verbose']:
                        print("adding users to %s" % shard)
                    self._add_user(members[0],
                                   name=self.args['username'],
                                   password=self.args['password'],
                                   database=self.args['auth_db'],
                                   roles=roles)

            if self.args['verbose']:
                print("added user %s on %s database" % (self.args['username'],
                                                        self.args['auth_db']))

        # in sharded env, if --mongos 0, kill the dummy mongos
        if self.args['sharded'] and self.args['mongos'] == 0:
            port = self.args['port']
            print("shutting down temporary mongos on localhost:%s" % port)
            username = self.args['username'] if self.args['auth'] else None
            password = self.args['password'] if self.args['auth'] else None
            authdb = self.args['auth_db'] if self.args['auth'] else None
            shutdown_host(port, username, password, authdb)

        # discover again, to get up-to-date info
        self.discover()

        # for sharded authenticated clusters, restart after first_init
        # to enable auth
        if self.args['sharded'] and self.args['auth'] and first_init:
            if self.args['verbose']:
                print("restarting cluster to enable auth...")
            self.restart()

        if self.args['auth'] and self.args['initial-user']:
            print('Username "%s", password "%s"'
                  % (self.args['username'], self.args['password']))

        if self.args['verbose']:
            print("done.")
1103340
def initialize(self, app: Flask, app_config):
        
        debug = app_config["debug"]
        port = app_config["http.port"]
        if debug:
            self.started_on_port = port
            app.run(host="0.0.0.0", debug=True, port=port)
        else:
            for port in range(port, port + 50):
                self.http_server = WSGIServer(('0.0.0.0', port), app)
                try:
                    self.http_server.start()
                except OSError:
                    # try next port
                    continue
                self.started_on_port = port
                break
378340
def __init(self):
        
        params = {
            "f" : "json",
        }
        json_dict = self._get(self._url, params,
                                 securityHandler=self._securityHandler,
                                 proxy_port=self._proxy_port,
                                 proxy_url=self._proxy_url)
        self._json_dict = json_dict
        self._json = json.dumps(json_dict, default=self._date_handler)
        attributes = [attr for attr in dir(self)
                      if not attr.startswith('__') and \
                      not attr.startswith('_')]
        for k,v in json_dict.items():
            if k in attributes:
                setattr(self, "_"+ k, json_dict[k])
            else:
                print("%s - attribute not implemented in Feature Layer." % k)
        if self._parentLayer is None:
            self._parentLayer = FeatureService(
                url=os.path.dirname(self._url),
                securityHandler=self._securityHandler,
                proxy_port=self._proxy_port,
                proxy_url=self._proxy_url, initialize=False)
706785
def init(self):
        """"""
        self.url = self.url.format(host=self.host, port=self.port,
                                   api_key=self.api_key)
49897
def build_from_developer_settings(api_name: str, api_version: str):
        
        developer_settings = read_developer_settings()

        api_host = "http://" + api_name + ".apis.devision.io"
        return ApiClient(
            host=api_host,
            api_version=api_version,
            access_token=None,
            refresh_token=developer_settings['refreshToken'],
            client_id=developer_settings['clientId'],
            client_secret=developer_settings['clientSecret'],
        )
365199
def init(opts):
    '''
    
    '''
    if 'host' not in opts['proxy']:
        log.critical('No \'host\' key found in pillar for this proxy.')
        return False
    if 'apikey' not in opts['proxy']:
        # If we do not have an apikey, we must have both a username and password
        if 'username' not in opts['proxy']:
            log.critical('No \'username\' key found in pillar for this proxy.')
            return False
        if 'password' not in opts['proxy']:
            log.critical('No \'passwords\' key found in pillar for this proxy.')
            return False

    DETAILS['url'] = 'https://{0}/api/'.format(opts['proxy']['host'])

    # Set configuration details
    DETAILS['host'] = opts['proxy']['host']
    if 'serial' in opts['proxy']:
        DETAILS['serial'] = opts['proxy'].get('serial')
        if 'apikey' in opts['proxy']:
            log.debug("Selected pan_key method for panos proxy module.")
            DETAILS['method'] = 'pan_key'
            DETAILS['apikey'] = opts['proxy'].get('apikey')
        else:
            log.debug("Selected pan_pass method for panos proxy module.")
            DETAILS['method'] = 'pan_pass'
            DETAILS['username'] = opts['proxy'].get('username')
            DETAILS['password'] = opts['proxy'].get('password')
    else:
        if 'apikey' in opts['proxy']:
            log.debug("Selected dev_key method for panos proxy module.")
            DETAILS['method'] = 'dev_key'
            DETAILS['apikey'] = opts['proxy'].get('apikey')
        else:
            log.debug("Selected dev_pass method for panos proxy module.")
            DETAILS['method'] = 'dev_pass'
            DETAILS['username'] = opts['proxy'].get('username')
            DETAILS['password'] = opts['proxy'].get('password')

    # Ensure connectivity to the device
    log.debug("Attempting to connect to panos proxy host.")
    query = {'type': 'op', 'cmd': '<show><system><info></info></system></show>'}
    call(query)
    log.debug("Successfully connected to panos proxy host.")

    DETAILS['initialized'] = True
617894
def _prepare_connection(**nxos_api_kwargs):
    '''
    
    '''
    nxos_api_kwargs = clean_kwargs(**nxos_api_kwargs)
    init_kwargs = {}
    # Clean up any arguments that are not required
    for karg, warg in six.iteritems(nxos_api_kwargs):
        if karg in RPC_INIT_KWARGS:
            init_kwargs[karg] = warg
    if 'host' not in init_kwargs:
        init_kwargs['host'] = 'localhost'
    if 'transport' not in init_kwargs:
        init_kwargs['transport'] = 'https'
    if 'port' not in init_kwargs:
        init_kwargs['port'] = 80 if init_kwargs['transport'] == 'http' else 443
    verify = init_kwargs.get('verify', True)
    if isinstance(verify, bool):
        init_kwargs['verify_ssl'] = verify
    else:
        init_kwargs['ca_bundle'] = verify
    if 'rpc_version' not in init_kwargs:
        init_kwargs['rpc_version'] = '2.0'
    if 'timeout' not in init_kwargs:
        init_kwargs['timeout'] = 60
    return init_kwargs
94080
def setup(self):
        ''''''
        log.debug( 'New request from address %s, port %d',  self.client_address )
        
        try:
            self.transport.load_server_moduli()
        except:
            log.exception( '(Failed to load moduli -- gex will be unsupported.)' )
            raise
        try:
            self.transport.add_server_key(self.host_key)
        except:
            if self.host_key is None:
                log.critical('Host key not set!  SSHHandler MUST define the host_key parameter.')
                raise NotImplementedError('Host key not set!  SSHHandler instance must define the host_key parameter.  Try host_key = paramiko_ssh.getRsaKeyFile("server_rsa.key").')
        
        try:
            # Tell transport to use this object as a server
            log.debug( 'Starting SSH server-side negotiation' )
            self.transport.start_server(server=self)
        except SSHException, e:
           log.warn('SSH negotiation failed. %s', e)
           raise
        
        # Accept any requested channels
        while True:
            channel = self.transport.accept(20)
            if channel is None:
                # check to see if any thread is running
                any_running = False
                for c, thread in self.channels.items():
                    if thread.is_alive():
                        any_running = True
                        break
                if not any_running:
                    break
            else:
                log.info( 'Accepted channel %s', channel )
74081
function initialize() 
	{
		parent::initialize();

		// Provider api end-points
		$this->api->api_base_url  = "https://api.citrixonline.com/";
		$this->api->authorize_url = "https://api.citrixonline.com/oauth/authorize";
		$this->api->token_url     = "https://api.citrixonline.com/oauth/access_token";

        $this->api->curl_authenticate_method  = "GET";
	}
931041
def __init(self):
        
        params = {
            "f" : "json",
        }
        json_dict = self._get(self._url, params,
                                 securityHandler=self._securityHandler,
                                 proxy_port=self._proxy_port,
                                 proxy_url=self._proxy_url)
        self._json = json.dumps(json_dict)
        self._json_dict = json_dict
        self.loadAttributes(json_dict=json_dict)
594318
def set_up_api_connection
      logger.info "connecting to rabbitmq HTTP API (#{api_config.sanitized_uri})"

      with_authentication_error_handler do
        with_connection_error_handler do
          @api_client = CarrotTop.new(host: api_config.host, port: api_config.port,
                                      user: api_config.username, password: api_config.password,
                                      ssl: api_config.ssl)
          @api_client.exchanges
        end
      end
    end
1178815
def __init(self):
        
        params = {
            "f" : "json"
        }
        json_dict = self._get(url=self._url, param_dict=params,
                                 securityHandler=self._securityHandler,
                                 proxy_url=self._proxy_url,
                                 proxy_port=self._proxy_port)
        attributes = [attr for attr in dir(self)
                      if not attr.startswith('__') and \
                      not attr.startswith('_')]
        for k,v in json_dict.items():
            if k in attributes:
                setattr(self, "_"+ k, json_dict[k])
            else:
                print( k, " - attribute not implemented in RouteNetworkLayer.")
            del k,v
553282
protected function initHttpClient()
    {

        // Middleware
        $obj_stack = HandlerStack::create();
        $obj_stack->push(ApplicationDefaultCredentials::getMiddleware(['https://www.googleapis.com/auth/datastore']));

        $str_base_url = self::DEFAULT_BASE_URL;

        if (getenv("DATASTORE_EMULATOR_HOST") !== FALSE) {
            $str_base_url = getenv("DATASTORE_EMULATOR_HOST");
        }

        // Create the HTTP client
        return new Client([
            'handler' => $obj_stack,
            'base_url' => $str_base_url,
            'auth' => 'google_auth'  // authorize all requests
        ]);
    }
594029
def init(port=8813, numRetries=10, host="localhost", label="default"):
    
    _connections[label] = connect(port, numRetries, host)
    switch(label)
    return getVersion()
390817
function init (prefs, callback) {
	options = _.extend(defaults, prefs);
	app = options.app || express();
	app.use(cors());

	ramlMocker.generate(options, process(function(requestsToMock){
		requestsToMock.forEach(function(reqToMock){
			addRoute(reqToMock);
		});
		log(new Array(30).join('='));
		log('%s[%s]%s API routes generated', colors.qyan, requestsToMock.length, colors.default);

		if(typeof callback === 'function'){
			callback(app);
		}
	}));

	var watcher = watch();
	var server = launchServer(app);

	function close () {
		if (watcher) { watcher.close(); }
		if (server) { server.close(); }
	}

	return {
		close: close,
		server: server,
		watcher: watcher
	};
}
1091281
function init(options) {
    self.email = options.email;
    self.key = options.token;
    self.cloudflareClient = new CloudFlareClient(options.email, options.token);
  }