Validate and create the reference in Zotero and return the created item.
490751
def create_distant_reference(self, ref_data):
        """"""
        self.validate_reference_data(ref_data)
        creation_status = self._zotero_lib.create_items([ref_data])
        try:
            created_item = creation_status["successful"]["0"]
            return created_item
        except KeyError as e:
            print(creation_status)
            raise CreateZoteroItemError from e
206425
def create(self, item, **kwargs):
        
        response = self._new_response()
        if self._prototype_handler.check(item, 'create', response):
            self._encrypt(item)
            params = {'Item': item}
            self._call_ddb_method(self.table.put_item,
                                  params, response)
            if response.status == 'success':
                response.data = item
        response.prepare()
        return response
1176088
public function createQtiItem()
    {
        try {
            // Check if it's post method
            if ($this->getRequestMethod()!=Request::HTTP_POST) {
                throw new \common_exception_NotImplemented('Only post method is accepted to create empty item.');
            }

            $label = $this->hasRequestParameter('label') ? $this->getRequestParameter('label') : '';
            // Call service to import package
            $item = $this->getDestinationClass()->createInstance($label);
            
            //set the QTI type
            $itemService = \taoItems_models_classes_ItemsService::singleton();
            $itemService->setItemModel($item, $this->getResource(ItemModel::MODEL_URI));

            $this->returnSuccess($item->getUri());

        } catch (\Exception $e) {
            $this->returnFailure($e);
        }
    }
493372
def validate(self):
        
        schema = Schema(self.__class__.SCHEMA)
        resolver = RefResolver.from_schema(
            schema,
            store=REGISTRY,
        )
        validate(self, schema, resolver=resolver)
881604
public function reference()
    {
    	// Get this content's type and format it to our needs.
    	$formattedName =  str_replace(' ', '', ucwords( strtolower( str_replace( '_', ' ', $this->getReferenceType() ) ) ));

    	// Create the related entity class dynamically.
		$referenceClass = 'Domain\\' . $formattedName . '\Data\MySQL\Eloquent\Model';

		return $this->hasOne($referenceClass, 'id', 'reference_id');
    }
1017486
def _create(cls, model_class, *args, **kwargs):
        """"""
        if cls._meta.django_get_or_create:
            return cls._get_or_create(model_class, *args, **kwargs)

        manager = cls._get_manager(model_class)
        return manager.create(*args, **kwargs)
564597
public function createItem()
    {
        if(!\tao_helpers_Request::isAjax()){
            throw new common_exception_BadRequest('wrong request mode');
        }
        $clazz = new \core_kernel_classes_Resource($this->getRequestParameter('id'));
        if ($clazz->isClass()) {
            $clazz = new \core_kernel_classes_Class($clazz);
        } else {
            foreach ($clazz->getTypes() as $type) {
                // determine class from selected instance
                $clazz = $type;
                break;
            }
        }
        $service = \taoItems_models_classes_ItemsService::singleton();

        $label = $service->createUniqueLabel($clazz);
        $item = $service->createInstance($clazz, $label);

        if(!is_null($item)){
            $service->setItemModel($item, new \core_kernel_classes_Resource(ItemModel::MODEL_URI));
            $this->getEventManager()->trigger(new ItemCreatedEvent($item->getUri()));
            $response = array(
                'label'	=> $item->getLabel(),
                'uri' 	=> $item->getUri()
            );
        } else {
            $response = false;
        }
        $this->returnJson($response);
    }
444615
def create_items(sender, instance, **kwargs):
    
    if instance.item_id is None and instance.item is None:
        item = Item()
        if hasattr(instance, 'active'):
            item.active = getattr(instance, 'active')
        item.save()
        instance.item = item
901602
public int create(Reference object, HookCreate create) {
		return getResourceFactory()
				.getApiResource(
						"/hook/" + object.getType() + "/" + object.getId()
								+ "/")
				.entity(create, MediaType.APPLICATION_JSON)
				.post(HookCreateResponse.class).getId();
	}
906353
def create(self, **kwargs):
        """"""
        self._check_create_parameters(**kwargs)
        if kwargs['checkPayload'] is True:
            self._meta_data['minimum_additional_parameters'] = {
                'allowTextMessage', 'allowJsonMessage', 'allowBinaryMessage'
            }
        if 'allowTextMessage' in kwargs:
            self._meta_data['required_creation_parameters'].update((
                'plainTextProfileReference',)
            )
        if 'allowJsonMessage' in kwargs:
            self._meta_data['required_creation_parameters'].update((
                'jsonProfileReference',)
            )
        return super(Websocket_Url, self)._create(**kwargs)
1047634
def create_item_returning_id(self, api):
        
        resp = api.create_item(self)
        item = resp.json()
        return item['id']
1294612
public function validate()
    {
        $order = $this->getInfoInstance()->getOrder();

        if ($order) {
            // Force to generate REF from Order ID.
            $this->assignData(null);
        }

        return parent::validate();
    }
1067143
def create(self, locator):
        
        for registration in self._registrations:
            this_locator = registration.locator

            if this_locator == locator:
                try:
                    return registration.factory(locator)
                except Exception as ex:
                    if isinstance(ex, CreateException):
                        raise ex
                    
                    raise CreateException(
                        None,
                        "Failed to create object for " + str(locator)
                    ).with_cause(ex)
24859
protected function createResourceCallable()
    {
        return function (array $data, array $values, ErrorBag $errorBag) {
            $model = $this->getDataModel()->newInstance();

            foreach ($values as $attribute => $value) {
                $model->setAttribute($attribute, $value);
            }

            if (!empty($data['id'])) {
                $model->setAttribute($model->getKeyName(), $data['id']);
            }

            try {
                $model->save();

                //We need to load the model from the DB in case the user is utilizing getRequiredFields() on the transformer.
                $model = $model->fresh();
            } catch (\Exception $e) {
                $errorBag[] = new Error('creation_error', 'Resource could not be created');
                throw $e;
            }

            return $model;
        };
    }
253739
public function createItem()
	{
		try {
			$siteid = $this->_getContext()->getLocale()->getSiteId();
		} catch( Exception $e ) {
			$siteid = null;
		}

		$values = array( 'siteid' => $siteid );
		return $this->_createItem( $values );
	}
558442
def model(method):
        """"""
        def wrapper(self, *args, **kwargs):
            if self.__model__ is None:
                raise ValidationError(
                    'You cannot perform CRUD operations without selecting a '
                    'model first.',
                )
            return method(self, *args, **kwargs)
        return wrapper
1015469
def perform_get_or_create(self, request, *args, **kwargs):
        """"""
        serializer = self.get_serializer(data=request.data)
        serializer.is_valid(raise_exception=True)
        process = serializer.validated_data.get('process')
        process_input = request.data.get('input', {})

        fill_with_defaults(process_input, process.input_schema)

        checksum = get_data_checksum(process_input, process.slug, process.version)
        data_qs = Data.objects.filter(
            checksum=checksum,
            process__persistence__in=[Process.PERSISTENCE_CACHED, Process.PERSISTENCE_TEMP],
        )
        data_qs = get_objects_for_user(request.user, 'view_data', data_qs)
        if data_qs.exists():
            data = data_qs.order_by('created').last()
            serializer = self.get_serializer(data)
            return Response(serializer.data)