Implements a server responder for
        :meth:`~pywbem.WBEMConnection.CreateInstance`

        Modify a CIM instance in the local repository.

        Raises:

            CIMError: CIM_ERR_ALREADY_EXISTS, CIM_ERR_INVALID_CLASS
495938
def _fake_modifyinstance(self, namespace, **params):
        

        if self._repo_lite:
            raise CIMError(
                CIM_ERR_NOT_SUPPORTED,
                "ModifyInstance not supported when repo_lite set.")

        # Validate namespace
        instance_repo = self._get_instance_repo(namespace)

        modified_instance = deepcopy(params['ModifiedInstance'])
        property_list = params['PropertyList']

        # Return if empty property list
        if property_list is not None and not property_list:
            return

        if modified_instance is not None and not modified_instance:
            return

        if not isinstance(modified_instance, CIMInstance):
            raise CIMError(
                CIM_ERR_INVALID_PARAMETER,
                _format("The ModifiedInstance parameter is not a valid "
                        "CIMInstance. Rcvd type={0}", type(modified_instance)))

        # Classnames in instance and path must match
        if modified_instance.classname != modified_instance.path.classname:
            raise CIMError(
                CIM_ERR_INVALID_PARAMETER,
                _format("ModifyInstance classname in path and instance do "
                        "not match. classname={0!A}, path.classname={1!A}",
                        modified_instance.classname,
                        modified_instance.path.classname))

        # Get class including properties from superclasses from repo
        try:
            target_class = self.GetClass(modified_instance.classname,
                                         namespace=namespace,
                                         LocalOnly=False,
                                         IncludeQualifiers=True,
                                         IncludeClassOrigin=True)
        except CIMError as ce:
            if ce.status_code == CIM_ERR_NOT_FOUND:
                raise CIMError(
                    CIM_ERR_INVALID_CLASS,
                    _format("Cannot modify instance because its creation "
                            "class {0!A} does not exist in namespace {1!A}.",
                            modified_instance.classname, namespace))
            raise

        # get key properties and all class props
        cl_props = [p.name for p in six.itervalues(target_class.properties)]
        key_props = [p.name for p in six.itervalues(target_class.properties)
                     if 'key' in p.qualifiers]

        # Get original instance in repo.  Does not copy the orig instance.
        mod_inst_path = modified_instance.path.copy()
        if modified_instance.path.namespace is None:
            mod_inst_path.namespace = namespace

        orig_instance_tup = self._find_instance(mod_inst_path, instance_repo)
        if orig_instance_tup[0] is None:
            raise CIMError(
                CIM_ERR_NOT_FOUND,
                _format("Original Instance {0!A} not found in namespace {1!A}",
                        modified_instance.path, namespace))
        original_instance = orig_instance_tup[1]

        # Remove duplicate properties from property_list
        if property_list:
            if len(property_list) != len(set(property_list)):
                property_list = list(set(property_list))

        # Test that all properties in modified instance and property list
        # are in the class
        if property_list:
            for p in property_list:
                if p not in cl_props:
                    raise CIMError(
                        CIM_ERR_INVALID_PARAMETER,
                        _format("Property {0!A} in PropertyList not in class "
                                "{1!A}", p, modified_instance.classname))
        for p in modified_instance:
            if p not in cl_props:
                raise CIMError(
                    CIM_ERR_INVALID_PARAMETER,
                    _format("Property {0!A} in ModifiedInstance not in class "
                            "{1!A}", p, modified_instance.classname))

        # Set the class value for properties in the property list but not
        # in the modified_instance. This sets just the value component.
        mod_inst_props = set(modified_instance.keys())
        new_props = mod_inst_props.difference(set(cl_props))
        if new_props:
            for new_prop in new_props:
                modified_instance[new_prop] = \
                    target_class.properties[new_prop].value

        # Remove all properties that do not change value between original
        # instance and modified instance
        for p in list(modified_instance):
            if original_instance[p] == modified_instance[p]:
                del modified_instance[p]

        # Confirm no key properties in remaining modified instance
        for p in key_props:
            if p in modified_instance:
                raise CIMError(
                    CIM_ERR_INVALID_PARAMETER,
                    _format("ModifyInstance cannot modify key property {0!A}",
                            p))

        # Remove any properties from modified instance not in the property_list
        if property_list:
            for p in list(modified_instance):
                if p not in property_list:
                    del modified_instance[p]

        # Exception if property in instance but not class or types do not
        # match
        for pname in modified_instance:
            if pname not in target_class.properties:
                raise CIMError(
                    CIM_ERR_INVALID_PARAMETER,
                    _format("Property {0!A} specified in ModifiedInstance is "
                            "not exposed by class {1!A} in namespace {2!A}",
                            pname, target_class.classname, namespace))

            cprop = target_class.properties[pname]
            iprop = modified_instance.properties[pname]
            if iprop.is_array != cprop.is_array \
                    or iprop.type != cprop.type \
                    or iprop.array_size != cprop.array_size:
                raise CIMError(
                    CIM_ERR_INVALID_PARAMETER,
                    _format("Instance and class property name={0!A} type "
                            "or other attributes do not match: "
                            "instance={1!A}, class={2!A}",
                            pname, iprop, cprop))

        # Modify the value of properties in the repo with those from
        # modified instance
        index = orig_instance_tup[0]
        instance_repo[index].update(modified_instance.properties)
        return
294605
def register(self, cls, instance):
        
        if not issubclass(cls, DropletInterface):
            raise TypeError('Given class is not a NAZInterface subclass: %s'
                            % cls)

        if not isinstance(instance, cls):
            raise TypeError('Given instance does not implement the class: %s'
                            % instance)

        if instance.name in self.INSTANCES_BY_NAME:
            if self.INSTANCES_BY_NAME[instance.name] != instance:
                raise ValueError('Given name is registered '
                                 'by other instance: %s' % instance.name)

        self.INSTANCES_BY_INTERFACE[cls].add(instance)
        self.INSTANCES_BY_NAME[instance.name] = instance
316892
def create(self, instance, errors):
        
        if errors:
            return self.errors(errors)
        return self.created(instance)
1136837
def _instance_transform(fqdn, o, *args, **kwargs):
    
    return _package_transform(o, fqdn, start=0, *args, **kwargs)
665989
def insert(self, identified):
        

        if not isinstance(identified, self._class):
            raise self.Error("Passed instance is not of the needed class",
                             self.Error.INVALID_INSTANCE_CLASS, instance=identified)

        try:
            if self._objects[identified.key] != identified:
                raise self.Error("Passes instance's key '%s' is already occupied" % identified.key,
                                 self.Error.KEY_EXISTS, key=identified.key, instance=identified)
        except KeyError:
            self._objects[identified.key] = identified
            self._events.insert.trigger(list=self, instance=identified)
        return identified
270800
def assert_instance_created(self, model_class, **kwargs):
        
        return _InstanceContext(
            self.assert_instance_does_not_exist,
            self.assert_instance_exists,
            model_class,
            **kwargs
        )
582729
def Create(self, name):
    
    precondition.AssertType(name, Text)

    try:
      constructor = self._constructors[name]
    except KeyError:
      message = "No constructor for name '%s' has been registered"
      message %= name
      raise ValueError(message)

    instance = constructor()
    if not isinstance(instance, self._cls):
      message = ("Constructor %r for name '%s' returned instance of type %r "
                 "(expected %r)")
      message %= (constructor, name, type(instance), self._cls)
      raise TypeError(message)

    return instance
166853
def create(cls, custom_headers=None):
        

        if custom_headers is None:
            custom_headers = {}

        request_map = {

        }
        request_map_string = converter.class_to_json(request_map)
        request_map_string = cls._remove_field_for_request(request_map_string)

        api_client = client.ApiClient(cls._get_api_context())
        request_bytes = request_map_string.encode()
        endpoint_url = cls._ENDPOINT_URL_CREATE
        response_raw = api_client.post(endpoint_url, request_bytes,
                                       custom_headers)

        return BunqResponseSandboxUser.cast_from_bunq_response(
            cls._from_json(response_raw, cls._OBJECT_TYPE_POST)
        )
289259
def create(cls, source, *, transform_args=None):
    
    if transform_args is None:
      transform_args = cls.transform_args

    return cls(get_obj(source, *transform_args))
448272
function reprovisionInstance(uuid, image_uuid, callback) {
    assert.string(uuid, 'uuid');
    assert.string(image_uuid, 'image_uuid');

    var opts = {};
    opts.image_uuid = image_uuid;

    return (this.put(sprintf('/instances/%s/upgrade', uuid), opts, callback));
}
72731
def upsert(cls, name, **fields):
        """"""
        instance = cls.get(name)
        if instance:
            instance._set_fields(fields)
        else:
            instance = cls(name=name, **fields)
            instance = failsafe_add(cls.query.session, instance, name=name)
        return instance
1159904
def update_or_create(cls, org, provider, exists):
        
        instance, created = cls.objects.update_or_create(
            org=org,
            provider=provider,
            defaults={'exists': exists},
        )

        return instance, created
1253660
def instance(cls) -> 'MiddlewareManager':
        

        if cls._instance is None:
            cls._instance = cls()
            cls._instance.init()
        return cls._instance
149910
def createInstance(self, codec=None):
        
        if type(self.klass) is type:
            return self.klass.__new__(self.klass)

        return self.klass()
326971
def modified_created(instance):
    
    if 'modified' in instance and 'created' in instance and \
            instance['modified'] < instance['created']:
        msg = "'modified' (%s) must be later or equal to 'created' (%s)"
        return JSONError(msg % (instance['modified'], instance['created']),
                         instance['id'])
1287008
def create(self, collector, tryImport=True):
        
        cls = self.getClass(tryImport=tryImport)
        if not self.successfullyImported:
            raise ImportError("Class not successfully imported: {}".format(self.exception))
        return cls(collector)
1368713
def p_mp_createInstance(p):
    """"""
    inst = p[1]
    if p.parser.verbose:
        p.parser.log(
            _format("Creating instance of {0!A}.", inst.classname))
    try:
        p.parser.handle.CreateInstance(inst)
    except CIMError as ce:
        if ce.status_code == CIM_ERR_ALREADY_EXISTS:
            if p.parser.verbose:
                p.parser.log(
                    _format("Instance of class {0!A} already exist. "
                            "Modifying...", inst.classname))
            try:
                p.parser.handle.ModifyInstance(inst)
            except CIMError as ce:
                if ce.status_code == CIM_ERR_NOT_SUPPORTED:
                    if p.parser.verbose:
                        p.parser.log(
                            _format("ModifyInstance not supported. "
                                    "Deleting instance of {0!A}: {1}",
                                    inst.classname, inst.path))
                    p.parser.handle.DeleteInstance(inst.path)
                    if p.parser.verbose:
                        p.parser.log(
                            _format("Creating instance of {0!A}.",
                                    inst.classname))
                    p.parser.handle.CreateInstance(inst)
        else:
            ce.file_line = (p.parser.file, p.lexer.lineno)
            raise