Creates a resource with the given ID (optional) and attributes.
331779
def create(self, resource_id=None, attributes=None):
        

        if attributes is None:
            attributes = {}

        result = None
        if not resource_id:
            result = self.client._post(
                self._url(resource_id),
                self._resource_class.create_attributes(attributes),
                headers=self._resource_class.create_headers(attributes)
            )
        else:
            result = self.client._put(
                self._url(resource_id),
                self._resource_class.create_attributes(attributes),
                headers=self._resource_class.create_headers(attributes)
            )

        return result
992724
def insert(self, resource, doc_or_docs, **kwargs):
        """"""
        ids = []
        kwargs.update(self._es_args(resource))
        for doc in doc_or_docs:
            self._update_parent_args(resource, kwargs, doc)
            _id = doc.pop('_id', None)
            res = self.elastic(resource).index(body=doc, id=_id, **kwargs)
            doc.setdefault('_id', res.get('_id', _id))
            ids.append(doc.get('_id'))
        self._refresh_resource_index(resource)
        return ids
1235226
public static JsonArrayDocument create(String id, JsonArray content) {
        return new JsonArrayDocument(id, 0, content, 0, null);
    }
186175
public function create($id, array $attributes)
    {
        $typeModelName = $this->getTypeModelName();

        $nodeType = $typeModelName::findOrFail($id);

        $nodeField = $nodeType->addField($attributes);

        $this->builderService->buildField(
            $nodeField->getName(),
            $nodeField->getType(),
            $nodeField->isIndexed(),
            $nodeType->getName(),
            $nodeType
        );

        return $nodeField;
    }
199939
function Resource(spec, options) {
  if (!(this instanceof Resource)) {
    return new Resource(spec, options);
  }

  if (typeof spec !== 'object') {
    throw new Error('resource spec must be an object');
  }

  debug('create resource %s', spec.path, spec);

  this.spec = spec;
  this.list = [];
  this.options = options || {};

  this.middleware = {};
  this.operations = {};
}
532129
public String create(String id, Integer size, HashSet<String> data, String originalVersion)
      throws IOException {
    if (collectionCachePath != null) {
      // initialization
      Date date = clear();
      // create always new version, unless explicit original version is provided
      String version;
      if(originalVersion!=null&&versionToItem.containsKey(originalVersion)) {
        version = originalVersion;
      } else {
        do {
          version = UUID.randomUUID().toString();
        } while (versionToItem.containsKey(version));
      }  
      // create new item
      MtasSolrCollectionCacheItem item;
      if (id != null) {
        item = new MtasSolrCollectionCacheItem(id, size, data);
        // remove if item with id already exists
        deleteById(id);
      } else {
        item = new MtasSolrCollectionCacheItem(version, size, data);
      }
      // register
      idToVersion.put(id, version);
      expirationVersion.put(version, date.getTime() + (1000 * lifeTime));
      versionToItem.put(version, item);
      // store data in file
      File file = collectionCachePath.resolve(version).toFile();
      try (OutputStream outputStream = new FileOutputStream(file);
          Writer outputStreamWriter = new OutputStreamWriter(outputStream,
              StandardCharsets.UTF_8);) {
        outputStreamWriter.write(encode(item));
        // set correct time to reconstruct administration on restart
        if (!file.setLastModified(date.getTime())) {
          log.debug("couldn't change filetime " + file.getAbsolutePath());
        }
        // don't store data in memory
        item.data = null;
        // return version
        return version;
      } catch (IOException e) {
        idToVersion.remove(id);
        expirationVersion.remove(version);
        versionToItem.remove(version);
        throw new IOException("couldn't create " + version, e);
      }
    } else {
      throw new IOException("no cachePath available, can't store data");
    }
  }
425166
@Override
	@Transactional
	public String getResource(String id)
	{
		final TemplateCall call = templater.template("resource_template");

		final ResourceTemplateEntity entity = resourceProvisionService.getOrCreateTemplate(id);

		if (entity == null)
			throw new RestException(404, "No such resource with id: " + id);

		call.set("entity", entity);
		call.set("nonce", nonceStore.getValue());

		return call.process();
	}
640497
public static Operation of(String id, String producer) {
    return newBuilder(id, producer).build();
  }
1195931
def resource(id)
      hash = http_get(url('/resources/%s', id))
      Resource.new(hash)
    rescue ::Hawkular::Exception => e
      return if e.cause.is_a?(::RestClient::NotFound)
      raise
    end
677061
function createResource(url, params, methods) {
      var resource;

      params = _.defaults({}, params, defaultParams);
      methods = _.defaults({}, methods, defaultMethods);
      resource = $resource(url, params, methods);

      // overwrite $save to automatically call $create or $update
      resource.prototype.$save = function save() {
        if (!this._id) {
          return this.$create();
        }

        return this.$update();
      };

      return resource;
    }
1205210
@UiThread
  public T create(S options) {
    T t = options.build(currentId, this);
    annotations.put(t.getId(), t);
    currentId++;
    updateSource();
    return t;
  }
1309560
def create(name, *ids)
      resource = self.class::RESOURCE_COLLECTION % { account_id: account.id }
      params = to_params.merge!(app_store_identifiers: ids.join(','), name: name)
      response = Request.new(account.client, :post, resource, params: params).perform
      from_response(response.body[:data])
    end
189591
def add(name, resource, attributes = {})
      resources[name] = resource
      resource.update_attributes(attributes) if attributes.any?
      resource
    end
1208664
public static Bean create(final BeanId id) {
        Preconditions.checkNotNull(id);
        Bean bean = new Bean(id);
        bean.set(id.getSchema());
        return bean;
    }
685815
public void addState(final String id, final Collection<Attribute> attributes) {
    this.stateMap.put(id, attributes);
  }
670671
public User withId(final long id) {
      return new User(id, username, displayName, slug, email, createTimestamp, url, metadata);
   }
651184
public static StringDocument create(String id, String content) {
        return new StringDocument(id, 0, content, 0, null);
    }