Create a backend :class:`stdnet.odm.Structure` handler.

        :param instance: a :class:`stdnet.odm.Structure`
        :param client: Optional client handler.
962047
def structure(self, instance, client=None):
        '''
        '''
        struct = self.struct_map.get(instance._meta.name)
        if struct is None:
            raise ModelNotAvailable('"%s" is not available for backend '
                                    '"%s"' % (instance._meta.name, self))
        client = client if client is not None else self.client
        return struct(instance, self, client)
1239445
def create(cls, object_type=None, object_uuid=None, **kwargs):
        
        assert 'pid_value' in kwargs

        kwargs.setdefault('status', cls.default_status)
        if object_type and object_uuid:
            kwargs['status'] = PIDStatus.REGISTERED

        return super(OAIIDProvider, cls).create(
            object_type=object_type, object_uuid=object_uuid, **kwargs)
1244867
function createHandler(options) {
  /**
   * Client request handler
   * Data from the incoming request (plus options) is forwarded to the AWS module
   */
  return async (ctx) => {
    const { credentials, endpoint, region } = options
    const { rawBody: body, header: headers, method, url: path } = ctx.request

    console.log(chalk.cyan(method, path))

    const params = { body, credentials, endpoint, headers, method, path, region }
    const req = createSignedAWSRequest(params)
    const res = await sendAWSRequest(req)

    ctx.status = 200
    ctx.type = 'application/json'
    ctx.response.header = stripProxyResHeaders(res)
    ctx.body = res.body
  }
}
678168
def netengine(self):
        
        # return None if no backend chosen yet
        if not self.backend:
            return None

        # init instance of the netengine backend if not already done
        if not self.__netengine:
            NetengineBackend = self.backend_class
            arguments = self._build_netengine_arguments()

            self.__netengine = NetengineBackend(**arguments)

        # return netengine instance
        return self.__netengine
343110
def create(self, data, **kwargs):
        
        self.client.post(self.url, data=data)
1005544
def buildProtocol(self, addr):
        
        self.resetDelay()
        self.client = self.protocol(self._parameters)
        self.client.factory = self
        self.client.ready.addCallback(lambda _: self._on_client_ready())
        return self.client
958532
def create_new_client(self, give_focus=True, filename='', is_cython=False,
                          is_pylab=False, is_sympy=False, given_name=None):
        """"""
        self.master_clients += 1
        client_id = dict(int_id=to_text_string(self.master_clients),
                         str_id='A')
        cf = self._new_connection_file()
        show_elapsed_time = self.get_option('show_elapsed_time')
        reset_warning = self.get_option('show_reset_namespace_warning')
        ask_before_restart = self.get_option('ask_before_restart')
        client = ClientWidget(self, id_=client_id,
                              history_filename=get_conf_path('history.py'),
                              config_options=self.config_options(),
                              additional_options=self.additional_options(
                                      is_pylab=is_pylab,
                                      is_sympy=is_sympy),
                              interpreter_versions=self.interpreter_versions(),
                              connection_file=cf,
                              menu_actions=self.menu_actions,
                              options_button=self.options_button,
                              show_elapsed_time=show_elapsed_time,
                              reset_warning=reset_warning,
                              given_name=given_name,
                              ask_before_restart=ask_before_restart,
                              css_path=self.css_path)

        # Change stderr_dir if requested
        if self.test_dir is not None:
            client.stderr_dir = self.test_dir

        self.add_tab(client, name=client.get_name(), filename=filename)

        if cf is None:
            error_msg = self.permission_error_msg.format(jupyter_runtime_dir())
            client.show_kernel_error(error_msg)
            return

        # Check if ipykernel is present in the external interpreter.
        # Else we won't be able to create a client
        if not CONF.get('main_interpreter', 'default'):
            pyexec = CONF.get('main_interpreter', 'executable')
            has_spyder_kernels = programs.is_module_installed(
                                                        'spyder_kernels',
                                                        interpreter=pyexec,
                                                        version='>=1.0.0')
            if not has_spyder_kernels:
                client.show_kernel_error(
                        _("Your Python environment or installation doesn't "
                          "have the <tt>spyder-kernels</tt> module or the "
                          "right version of it installed. "
                          "Without this module is not possible for "
                          "Spyder to create a console for you.<br><br>"
                          "You can install it by running in a system terminal:"
                          "<br><br>"
                          "<tt>conda install spyder-kernels</tt>"
                          "<br><br>or<br><br>"
                          "<tt>pip install spyder-kernels</tt>"))
                return

        self.connect_client_to_kernel(client, is_cython=is_cython,
                                      is_pylab=is_pylab, is_sympy=is_sympy)
        if client.shellwidget.kernel_manager is None:
            return
        self.register_client(client)
799405
def create(self, **kwargs):
        

        response = self.ghost.execute_post('%s/' % self._type_name, json={
            self._type_name: [
                kwargs
            ]
        })

        return self._model_type(response.get(self._type_name)[0])
58968
def get_client(client=None):
    
    global _client

    tmp_client = client is not None
    if not tmp_client:
        config = getattr(django_settings, "ELASTIC_APM", {})
        client = config.get("CLIENT", default_client_class)

    if _client[0] != client:
        client_class = import_string(client)
        instance = client_class()
        if not tmp_client:
            _client = (client, instance)
        return instance
    return _client[1]
393691
function createClientType() {
    log.info("create client");
    // [ -Events- ]
    // error - when there's a problem with a received message
    // open - when the connection is open
    // close - when the connection is closed
    // message - when there's a message from the hub
    // [ -Constructor- ]
    function Client() {
        log.info("instantiate client");
        // get non-ambiguous this
        var self = this;
        // Call parent constructor
        Client.super_.call(self);
        // Internal structures
        self._transport = undefined;
        self._txRegistry = {};
        self._lastTxId = 0;
        self._txLimit = 1000;
        self._state = "NOT_OPENED";
        self._messageDispatch = {
            distribution: self._handleDistribution.bind(self),
            published: self._handlePublication.bind(self),
            subscribed: self._handleSubscription.bind(self),
            unsubscribed: self._handleUnsubscription.bind(self),
        };
        // state listeners
        self.once("open", function handleOpened() {
            self._state = "OPEN";
        }).once("close", function handleClosed() {
            self._state = "CLOSED";
        });
        // constructor - return undefined
        return undefined;
    }
    // [ -Inheritance- ]
    util.inherits(Client, events.EventEmitter);
    // [ -Private API- ]
    // check state for OPEN
    Client.prototype._checkState = function clientCheckState() {
        if (this._state !== "OPEN") {
            throw new VError("Nonsensical to call before 'open' or after 'close' events");
        }
        return this;
    };
    // get a transaction ID
    Client.prototype._getTxID = function clientGetTxID() {
        var txid;
        // try the last txid + 1 first
        var candidate = this._lastTxId + 1;
        // try to get a txid until we get one, or we've failed _txLimit times
        // (this means we have _txLimit txid's already assigned)
        var tries = 0;
        while (txid === undefined && tries < this._txLimit) {
            tries++;
            candidate %= this._txLimit;
            if (this._txRegistry[candidate] === undefined) {
                txid = candidate;
            } else {
                candidate++;
            }
        }
        // catch the error exit
        if (txid === undefined) {
            throw new VError("Cannot issue a transaction ID - too many outstanding transactions (%d)", this._txLimit);
        }
        // set the last txid and return it to the caller
        this._lastTxId = txid;
        return txid;
    };
    // register a transaction ID
    Client.prototype._registerTxID = function clientRegisterTxID(txid, cb) {
        this._txRegistry[txid] = cb;
        // allow chaining
        return this;
    };
    // retire a transaction ID
    Client.prototype._retireTxID = function clientRetireTxID(txid) {
        delete this._txRegistry[txid];
        // allow chaining
        return this;
    };
    // handle publication message
    Client.prototype._handlePublication = function clientHandlePublication(messageObj) {
        log.info("client handle publication");
        // validate message
        var error = validateProperties(
            messageObj,
           "published message from transport layer",
           ['type', 'message', 'channel', 'number', 'transactionID'],
           []
        );
        // FIXME - message should be JSON
        // FIXME - channel should be string
        // FIXME - number should be a number
        // FIXME - txid should be number
        // FIXME - need a test for no tx callback (on purpose)
        if (error) { this.emit('error', error); return null; }
        var transactionCallback = this._txRegistry[messageObj.transactionID];
        if (transactionCallback) {
            transactionCallback(null, messageObj.message, messageObj.channel, messageObj.number);
            this._retireTxID(messageObj.transactionID);
        } else {
            this.emit('error', new VError("received a message with an unrecognized transaction ID: %j", messageObj));
        }
        // allow chaining
        return this;
    };
    // handle subscription message
    Client.prototype._handleSubscription = function clientHandleSubscription(messageObj) {
        log.info("client on subscribed");
        var error = validateProperties(
            messageObj,
           "subscribed message from transport layer",
           ['type', 'pattern', 'number', 'transactionID'],
           []
        );
        // FIXME - pattern should be regex
        // FIXME - number should be a number
        if (error) { this.emit('error', error); return null; }
        var transactionCallback = this._txRegistry[messageObj.transactionID];
        if (transactionCallback) {
            log.debug("calling tx callback with", messageObj.pattern, messageObj.number);
            transactionCallback(null, messageObj.pattern, messageObj.number);
            this._retireTxID(messageObj.transactionID);
        } else {
            this.emit('error', new VError("received a message with an unrecognized transaction ID: %j", messageObj));
        }
        // allow chaining
        return this;
    };
    // handle unsubscription message
    Client.prototype._handleUnsubscription = function clientHandleUnsubscription(messageObj) {
        log.info("client on unsubscribed");
        var error = validateProperties(
            messageObj,
           "unsubscribed message from transport layer",
           ['type', 'pattern', 'number', 'transactionID'],
           []
        );
        // FIXME - pattern should be regex
        // FIXME - number should be a number
        if (error) { this.emit('error', error); return null; }
        var transactionCallback = this._txRegistry[messageObj.transactionID];
        if (transactionCallback) {
            transactionCallback(null, messageObj.pattern, messageObj.number);
            this._retireTxID(messageObj.transactionID);
        } else {
            this.emit('error', new VError("received a message with an unrecognized transaction ID: %j", messageObj));
        }
        // allow chaining
        return this;
    };
    // handle distributions
    Client.prototype._handleDistribution = function clientDistribute(messageObj) {
        log.info("client on distribution");
        var error = validateProperties(
            messageObj,
           "distribution message from transport layer",
           ['type', 'message', 'channel', 'match'],
           []
        );
        // FIXME - message should be JSON
        // FIXME - channel should be string
        // FIXME - match should be a regex
        if (error) { this.emit('error', error); return null; }
        this.emit('message', messageObj.message, messageObj.channel, messageObj.match);
        // allow chaining
        return this;
    };
    // handle messages from the transport layer
    Client.prototype._handleMessage = function clientHandleMessage(messageObj) {
        log.info("client handle message", this._id, messageObj);
        // parse the message type and respond accordingly
        var handler = this._messageDispatch[messageObj.type];
        if (handler === undefined) {
            this.emit('error', new VError("No dispatcher found for message type (%s) (%j)", messageObj.type, messageObj));
        } else {
            handler(messageObj);
        }
        // allow chaining
        return this;
    };
    // [ -Public API- ]
    // get/set the limit for the max number of client-initiated
    // transactions in flight simultaneously
    Client.prototype.txLimit = function clientTxLimit(limit) {
        if (limit) {
            this._txLimit = limit;
        }
        return this._txLimit;
    };
    // subscribe a subscriber
    Client.prototype.subscribe = function clientSubscribe(pattern, cb) {
        log.info("client subscribe", this._transport._id, pattern);
        // get a non-ambiguous "this"
        var self = this;
        // check state
        this._checkState();
        // get a transaction id
        var txid;
        try {
            txid = self._getTxID();
        } catch (e) {
            callback(cb)(new VError(e, "cannot subscribe - no transaction ID available."));
            // early return because we don't want to execute anything else,
            // and js has no try/catch/else
            return self;
        }
        self._registerTxID(txid, callback(cb));
        // send subscription request
        self._transport.send({
            type: 'subscription',
            'pattern': pattern,
            transactionID: txid,
        }, function handleCompletion(error) {
            // if there's an error, need to retire the TXID early.
            // assumes a send error means the message was not sent,
            // and there's not going to be a corresponding response.
            if (error) {
                self._retireTxID(txid);
                cb(error);
            }
            return null;
        });
        // allow chaining of calls
        return self;
    };
    // unsubscribe a pattern
    Client.prototype.unsubscribe = function clientUnsubscribe(pattern, cb) {
        log.info("client unsubscribe", this._transport._id, pattern);
        // get a non-ambiguous "this"
        var self = this;
        // check state
        this._checkState();
        // get a transaction id
        var txid;
        try {
            txid = self._getTxID();
        } catch (e) {
            callback(cb)(new VError(e, "cannot unsubscribe - no transaction ID available."));
            return self;
        }
        self._registerTxID(txid, callback(cb));
        // send unsubscription request
        self._transport.send({
            type: 'unsubscription',
            'pattern': pattern,
            transactionID: txid,
        }, function handleCompletion(error) {
            // if there's an error, need to retire the TXID early.
            // assumes a send error means the message was not sent,
            // and there's not going to be a corresponding response.
            if (error) {
                self._retireTxID(txid);
                callback(cb)(error);
            }
            return null;
        });
        // allow chaining
        return self;
    };
    // publish to subscribers
    Client.prototype.publish = function clientPublish(message, channel, cb) {
        log.info("client publish", this._transport._id, message);
        var self = this;
        // check state
        this._checkState();
        // get a transaction id
        var txid;
        try {
            txid = self._getTxID();
        } catch (e) {
            callback(cb)(new VError(e, "cannot publish - no transaction ID available."));
            return self;
        }
        self._registerTxID(txid, callback(cb));
        // send publication request
        self._transport.send({
            type: 'publication',
            'message': message,
            'channel': channel,
            transactionID: txid,
        }, function handleCompletion(error) {
            // if there's an error, need to retire the TXID early.
            // assumes a send error means the message was not sent,
            // and there's not going to be a corresponding response.
            if (error) {
                self._retireTxID(txid);
                callback(cb)(new VError(error, "Error sending to hub"));
            }
            return null;
        });
        // allow chaining
        return self;
    };
    // close a transport object
    Client.prototype.close = function clientClose() {
        log.info("client close");
        if (this._state !== "OPEN") {
            throw new VError("Cannot close a client which is not open");
        }
        this._transport.close();
        // it doesn't make sense to do anything with the object after this,
        // so return null
        return null;
    };
    // connect to listening client
    Client.prototype.connect = function clientConnect(url, cb) {
        log.info("client connect");
        // only allow this to be called once on the object
        if (this._transport) {
            // throw immediately - this is programmer error
            throw new VError("'connect' has already been called on this client.");
        }
        // add cb to listeners
        if (cb) {
            this.on('open', cb);
        }
        // open a new transport connection
        this._transport = new ActualTransportClient();
        this._transport.connect(url);
        // proxy some events
        this._transport.on('open', this.emit.bind(this, 'open'));
        this._transport.on('close', this.emit.bind(this, 'close'));
        // handle messages from transport
        this._transport.on('message', this._handleMessage.bind(this));
        // it doesn't make sense to do anything with the object until connect
        // calls back, so return null
        return null;
    };
    // return a new Client
    return Client;
}
1073281
def MI_createInstance(self,
                          env,
                          instance):
        # pylint: disable=invalid-name
        

        logger = env.get_logger()
        logger.log_debug('CIMProvider MI_createInstance called...')
        rval = None
        ch = env.get_cimom_handle()
        cimClass = ch.GetClass(instance.classname,
                               instance.path.namespace,
                               LocalOnly=False,
                               IncludeQualifiers=True)
        # CIMOM has already filled in default property values for
        # props with default values, if values not supplied by client.
        rval = self.set_instance(env=env,
                                 instance=instance,
                                 previous_instance=None,
                                 cim_class=cimClass)
        rval = build_instance_name(rval, cimClass)
        logger.log_debug('CIMProvider MI_createInstance returning')
        return rval
1336458
def define_methods_into(client)
      links.each do |link|
        @client.define_singleton_method(link.method_signature) do |params = {}, headers = {}|
          Request.call(client: client, headers: headers, link: link, params: params)
        end
      end
    end
1308232
async def _create_connection(self, req: 'ClientRequest',
                                 traces: List['Trace'],
                                 timeout: 'ClientTimeout') -> ResponseHandler:
        
        if req.proxy:
            _, proto = await self._create_proxy_connection(
                req, traces, timeout)
        else:
            _, proto = await self._create_direct_connection(
                req, traces, timeout)

        return proto
528420
def create(client, _type, **kwargs):
    """"""
    obj = client.factory.create("ns0:%s" % _type)
    for key, value in kwargs.items():
        setattr(obj, key, value)
    return obj
1205041
def instantiate_client(self, config):
        
        modules = config.module.split('.')
        class_name = modules.pop()
        module_path = '.'.join(modules)

        client_instance = getattr(
            __import__(module_path, {}, {}, ['']),
            class_name
        )()

        client_instance.add_config(config)

        return client_instance
1243489
def _build_and_attach_node(endpoint_class, method_name=nil)
      # Create the new endpoint
      endpoint_instance = endpoint_class.new(@requester, method_name, self)
      # Attach the endpoint as an instance variable and method
      method_name ||= endpoint_class.name.demodulize.underscore
      self.instance_variable_set("@#{method_name}", endpoint_instance)
      self.define_singleton_method(method_name.to_s) { endpoint_instance }
      endpoint_instance
    end
945255
def init_app(cls, app, callback=None):
        
        processed = set()
        cls.__views__ = set()
        cls.is_always_available = False
        for base in cls.__mro__:
            for name, attr in base.__dict__.items():
                if name in processed:
                    continue
                processed.add(name)
                if isinstance(attr, ViewHandler):
                    if base != cls:  # Copy ViewHandler instances into subclasses
                        # TODO: Don't do this during init_app. Use a metaclass
                        # and do this when the class is defined.
                        attr = attr.copy_for_subclass()
                        setattr(cls, name, attr)
                    attr.__set_name__(cls, name)  # Required for Python < 3.6
                    cls.__views__.add(name)
                    attr.init_app(app, cls, callback=callback)
                    if not hasattr(attr.wrapped_func, 'is_available'):
                        cls.is_always_available = True