// Create creates a new metric definition
422423
func (c *Client) Create(md MetricDefinition, o ...Modifier) (bool, error) {
	// Keep the order, add custom prepend
	o = prepend(o, c.URL("POST", TypeEndpoint(md.Type)), Data(md))

	r, err := c.Send(o...)
	if err != nil {
		return false, err
	}

	defer r.Body.Close()

	if r.StatusCode > 399 {
		err = c.parseErrorResponse(r)
		if err, ok := err.(*HawkularClientError); ok {
			if err.Code != http.StatusConflict {
				return false, err
			}
			return false, nil
		}
		return false, err
	}
	return true, nil
}
1096833
func (s *Storage) Create(name string, capacity uint, rate time.Duration) (leakybucket.Bucket, error) {
	b, ok := s.buckets[name]
	if ok {
		return b, nil
	}
	b = &bucket{
		capacity:  capacity,
		remaining: capacity,
		reset:     time.Now().Add(rate),
		rate:      rate,
	}
	s.buckets[name] = b
	return b, nil
}
508253
func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ *taskAPI.CreateTaskResponse, err error) {
	return nil, errdefs.ErrNotImplemented
}
384110
func (c *services) Create(service *api.Service) (result *api.Service, err error) {
	result = &api.Service{}
	err = c.client.Post().
		Namespace(c.ns).
		Resource("services").
		Body(service).
		Do().
		Into(result)
	return
}
1290767
func (c *Client) Create(namespace string, reader io.Reader, timeout int64, shouldWait bool) error {
	client, err := c.KubernetesClientSet()
	if err != nil {
		return err
	}
	if err := ensureNamespace(client, namespace); err != nil {
		return err
	}
	c.Log("building resources from manifest")
	infos, buildErr := c.BuildUnstructured(namespace, reader)
	if buildErr != nil {
		return buildErr
	}
	c.Log("creating %d resource(s)", len(infos))
	if err := perform(infos, createResource); err != nil {
		return err
	}
	if shouldWait {
		return c.waitForResources(time.Duration(timeout)*time.Second, infos)
	}
	return nil
}
1360042
func (m *Mercury) Create(ctx context.Context, key, val string, opts ...clientv3.OpOption) (*clientv3.TxnResponse, error) {
	return m.BatchCreate(ctx, map[string]string{key: val}, opts...)
}
1328965
func (c *endpoints) Create(endpoints *api.Endpoints) (result *api.Endpoints, err error) {
	result = &api.Endpoints{}
	err = c.client.Post().
		Namespace(c.ns).
		Resource("endpoints").
		Body(endpoints).
		Do().
		Into(result)
	return
}
303990
func (w *Writer) Create(name string, f *File) error {
	if err := w.finishInode(); err != nil {
		return err
	}
	dir, existing, childname, err := w.lookup(name, false)
	if err != nil {
		return err
	}
	var reuse *inode
	if existing != nil {
		if existing.IsDir() {
			if f.Mode&TypeMask != S_IFDIR {
				return fmt.Errorf("%s: cannot replace a directory with a file", name)
			}
			reuse = existing
		} else if f.Mode&TypeMask == S_IFDIR {
			return fmt.Errorf("%s: cannot replace a file with a directory", name)
		} else if existing.LinkCount < 2 {
			reuse = existing
		}
	} else {
		if f.Mode&TypeMask == S_IFDIR && dir.LinkCount >= format.MaxLinks {
			return fmt.Errorf("%s: exceeded parent directory maximum link count", name)
		}
	}
	child, err := w.makeInode(f, reuse)
	if err != nil {
		return fmt.Errorf("%s: %s", name, err)
	}
	if existing != child {
		if existing != nil {
			existing.LinkCount--
		}
		dir.Children[childname] = child
		child.LinkCount++
		if child.IsDir() {
			dir.LinkCount++
		}
	}
	if child.Mode&format.TypeMask == format.S_IFREG {
		w.startInode(name, child, f.Size)
	}
	return nil
}
115007
func (s *ServicesService) Create(svc *Service) (*Service, *http.Response, error) {
	return s.CreateWithContext(context.TODO(), svc)
}
195646
func (c *resourceQuotas) Create(resourceQuota *api.ResourceQuota) (result *api.ResourceQuota, err error) {
	result = &api.ResourceQuota{}
	err = c.r.Post().Namespace(c.ns).Resource("resourceQuotas").Body(resourceQuota).Do().Into(result)
	return
}
136625
func (m *MachinesClient) Create(ctx context.Context, orgID, teamID *identity.ID,
	name string, output ProgressFunc) (*apitypes.MachineSegment, *base64.Value, error) {

	secret, err := createTokenSecret()
	if err != nil {
		return nil, nil, err
	}

	mcr := apitypes.MachinesCreateRequest{
		Name:   name,
		OrgID:  orgID,
		TeamID: teamID,
		Secret: secret,
	}

	result := &apitypes.MachineSegment{}
	err = m.client.DaemonRoundTrip(ctx, "POST", "/machines", nil, &mcr, &result, output)
	return result, secret, err
}
1270948
func Create(name string) *Registry {
	return &Registry{name: name, registrants: map[string]Registrant{}}
}
286538
func (h *fs) Create(filename string) (io.WriteCloser, error) {
	return os.Create(filename)
}
1168639
func (s *GroupsService) Create(name string) *GroupsCreateCall {
	var call GroupsCreateCall
	call.service = s
	call.name = name
	return &call
}
773665
func (r *GormQueryRepository) Create(ctx context.Context, q *Query) error {
	defer goa.MeasureSince([]string{"goa", "db", "Query", "create"}, time.Now())
	q.ID = uuid.NewV4()
	if q.Creator == uuid.Nil {
		return errors.NewBadParameterError("creator cannot be nil", q.Creator).Expected("valid user ID")
	}
	var v map[string]interface{}
	if err := json.Unmarshal([]byte(q.Fields), &v); err != nil {
		return errors.NewBadParameterError("query field is invalid JSON syntax", q.Fields).Expected("valid JSON")
	}
	// Parse fields to make sure that query is valid
	exp, _, err := search.ParseFilterString(ctx, q.Fields)
	if err != nil || exp == nil {
		log.Error(ctx, map[string]interface{}{
			"space_id": q.SpaceID,
			"fields":   q.Fields,
		}, "unable to parse the query fields")
		return err
	}
	err = r.db.Create(q).Error
	if err != nil {
		if gormsupport.IsCheckViolation(err, "queries_title_check") {
			return errors.NewBadParameterError("Title", q.Title).Expected("not empty")
		}
		// combination of title, space ID and creator should be unique
		if gormsupport.IsUniqueViolation(err, "queries_title_space_id_creator_unique") {
			log.Error(ctx, map[string]interface{}{
				"err":      err,
				"title":    q.Title,
				"space_id": q.SpaceID,
			}, "unable to create query because a query with same title already exists in the space by same creator")
			return errors.NewDataConflictError(fmt.Sprintf("query already exists with title = %s , space_id = %s, creator = %s", q.Title, q.SpaceID, q.Creator))
		}
		log.Error(ctx, map[string]interface{}{}, "error adding Query: %s", err.Error())
		return err
	}
	return nil
}
1101527
func (c *FakeLimitRanges) Create(limitRange *corev1.LimitRange) (result *corev1.LimitRange, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewCreateAction(limitrangesResource, c.ns, limitRange), &corev1.LimitRange{})

	if obj == nil {
		return nil, err
	}
	return obj.(*corev1.LimitRange), err
}
1156524
func (namespace *HostComputeNamespace) Create() (*HostComputeNamespace, error) {
	logrus.Debugf("hcn::HostComputeNamespace::Create id=%s", namespace.Id)

	jsonString, err := json.Marshal(namespace)
	if err != nil {
		return nil, err
	}

	logrus.Debugf("hcn::HostComputeNamespace::Create JSON: %s", jsonString)
	namespace, hcnErr := createNamespace(string(jsonString))
	if hcnErr != nil {
		return nil, hcnErr
	}
	return namespace, nil
}