// Create creates a new space template and all the artifacts (e.g. work item
// types, work item link types) in the system.
164076
func (r *GormRepository) Create(ctx context.Context, s SpaceTemplate) (*SpaceTemplate, error) {
	if uuid.Equal(s.ID, uuid.Nil) {
		s.ID = uuid.NewV4()
	}

	if err := s.Validate(); err != nil {
		log.Error(ctx, map[string]interface{}{"space_template": s, "err": err}, "space template is invalid")
		return nil, errs.Wrap(err, "space template is invalid")
	}

	// Create space template
	db := r.db.Create(&s)
	if err := db.Error; err != nil {
		log.Error(ctx, map[string]interface{}{"space_template": s, "err": err}, "failed to create space template")
		// name needs to be unique
		if gormsupport.IsUniqueViolation(err, "space_templates_name_uidx") {
			return nil, errors.NewBadParameterError("name", s.Name).Expected("unique")
		}
		return nil, errs.Wrap(err, "failed to create space template")
	}
	log.Debug(ctx, map[string]interface{}{"space_template_id": s.ID}, "space template created successfully")
	return &s, nil
}
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
}
386374
func (c *WorkItemLinkController) Create(ctx *app.CreateWorkItemLinkContext) error {
	currentUserIdentityID, err := login.ContextIdentity(ctx)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewUnauthorizedError(err.Error()))
	}
	modelLink, err := ConvertLinkToModel(app.WorkItemLinkSingle{
		Data: ctx.Payload.Data,
	})
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}
	var createdModelLink *link.WorkItemLink
	err = application.Transactional(c.db, func(appl application.Application) error {
		var err error
		createdModelLink, err = appl.WorkItemLinks().Create(ctx.Context, modelLink.SourceID, modelLink.TargetID, modelLink.LinkTypeID, *currentUserIdentityID)
		return err
	})
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}
	// convert from model to rest representation
	createdAppLink := ConvertLinkFromModel(ctx.Request, *createdModelLink)
	if err := enrichLinkSingle(ctx.Context, c.db, ctx.Request, &createdAppLink); err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}
	ctx.ResponseWriter.Header().Set("Location", app.WorkItemLinkHref(createdAppLink.Data.ID))
	return ctx.Created(&createdAppLink)
}
347971
func (client *Client) CreateTemplate(ctx context.Context, template Template) (string, error) {
	content := map[string]interface{}{
		"name":     template.Name,
		"template": template.Content,
	}

	if err := client.request(ctx, "POST", "templates", content, &template); err != nil {
		return "", err
	}

	return template.ID, nil
}
508253
func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ *taskAPI.CreateTaskResponse, err error) {
	return nil, errdefs.ErrNotImplemented
}
945878
func (c *helmReleases) Create(helmRelease *v1beta1.HelmRelease) (result *v1beta1.HelmRelease, err error) {
	result = &v1beta1.HelmRelease{}
	err = c.client.Post().
		Namespace(c.ns).
		Resource("helmreleases").
		Body(helmRelease).
		Do().
		Into(result)
	return
}
624692
func (p *Project) Create(c *check.C, image string) types.ContainerJSON {
	container, err := p.project.Create(image)
	c.Assert(err, check.IsNil,
		check.Commentf("error while creating the container with image %s", image))
	return container
}
38690
func (k *kubernetesClient) Create(context.ProviderCallContext, environs.CreateParams) error {
	// must raise errors.AlreadyExistsf if it's already exist.
	return k.createNamespace(k.namespace)
}
984695
func (c *WorkItemCommentsController) Create(ctx *app.CreateWorkItemCommentsContext) error {
	var newComment comment.Comment
	err := application.Transactional(c.db, func(appl application.Application) error {
		_, err := appl.WorkItems().LoadByID(ctx, ctx.WiID)
		if err != nil {
			return goa.ErrNotFound(err.Error())
		}
		currentUserIdentityID, err := login.ContextIdentity(ctx)
		if err != nil {
			return goa.ErrUnauthorized(err.Error())
		}

		reqComment := ctx.Payload.Data
		markup := rendering.NilSafeGetMarkup(reqComment.Attributes.Markup)
		var parentCommentID id.NullUUID
		if reqComment.Relationships != nil && reqComment.Relationships.ParentComment != nil {
			stringUUID := *reqComment.Relationships.ParentComment.Data.ID
			tempUUID, err := uuid.FromString(stringUUID)
			if err != nil {
				return jsonapi.JSONErrorResponse(ctx, err)
			}
			parentCommentID = id.NullUUID{
				UUID:  tempUUID,
				Valid: true,
			}
		}
		newComment = comment.Comment{
			ParentID:        ctx.WiID,
			Body:            reqComment.Attributes.Body,
			Markup:          markup,
			Creator:         *currentUserIdentityID,
			ParentCommentID: parentCommentID,
		}

		err = appl.Comments().Create(ctx, &newComment, *currentUserIdentityID)
		if err != nil {
			return goa.ErrInternal(err.Error())
		}

		res := &app.CommentSingle{
			Data: ConvertComment(ctx.Request, newComment),
		}
		return ctx.OK(res)
	})
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}
	if ctx.ResponseData.Status == 200 {
		c.notification.Send(ctx, notification.NewCommentCreated(newComment.ID.String()))
	}
	return nil
}
784914
func (m *GormCodebaseRepository) Create(ctx context.Context, codebase *Codebase) error {
	defer goa.MeasureSince([]string{"goa", "db", "codebase", "create"}, time.Now())
	if codebase.ID == uuid.Nil {
		codebase.ID = uuid.NewV4()
	}

	if err := m.db.Create(codebase).Error; err != nil {
		// if codebase already exists in the space
		if gormsupport.IsUniqueViolation(err, "codebases_spaceid_url_idx") {
			log.Error(ctx, map[string]interface{}{
				"err":      err,
				"URL":      codebase.URL,
				"space_id": codebase.SpaceID,
			},
				"unable to create codebase because the codebase with same URL already exists in space")
			errStr := fmt.Sprintf("codebase already exists with URL = %s, space_id = %s",
				codebase.URL, codebase.SpaceID)
			return errors.NewDataConflictError(errStr)
		}
		goa.LogError(ctx, "error adding Codebase", "error", err.Error())
		return errs.WithStack(err)
	}

	return nil
}
1068681
func Create(t *testing.T, ctx context.Context, client client.APIClient, ops ...func(*TestContainerConfig)) string { // nolint: golint
	t.Helper()
	config := &TestContainerConfig{
		Config: &container.Config{
			Image: "busybox",
			Cmd:   []string{"top"},
		},
		HostConfig:       &container.HostConfig{},
		NetworkingConfig: &network.NetworkingConfig{},
	}

	for _, op := range ops {
		op(config)
	}

	c, err := client.ContainerCreate(ctx, config.Config, config.HostConfig, config.NetworkingConfig, config.Name)
	assert.NilError(t, err)

	return c.ID
}
397682
func (c *SpaceCodebasesController) Create(ctx *app.CreateSpaceCodebasesContext) error {
	identityID, err := login.ContextIdentity(ctx)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrUnauthorized(err.Error()))
	}
	// Validate Request
	if ctx.Payload.Data == nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError("data", nil).Expected("not nil"))
	}
	reqIter := ctx.Payload.Data
	if reqIter.Attributes.Type == nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError("data.attributes.type", nil).Expected("not nil"))
	}
	if reqIter.Attributes.URL == nil {
		return jsonapi.JSONErrorResponse(ctx, errors.NewBadParameterError("data.attributes.url", nil).Expected("not nil"))
	}
	// the default value of cveScan
	cveScan := false
	if reqIter.Attributes.CveScan != nil {
		cveScan = *reqIter.Attributes.CveScan
	}

	var cdb *codebase.Codebase
	err = application.Transactional(c.db, func(appl application.Application) error {
		sp, err := appl.Spaces().Load(ctx, ctx.SpaceID)
		if err != nil {
			return err
		}
		if *identityID != sp.OwnerID {
			return errors.NewForbiddenError("user is not the space owner")
		}
		cdb = &codebase.Codebase{
			SpaceID: ctx.SpaceID,
			Type:    *reqIter.Attributes.Type,
			URL:     *reqIter.Attributes.URL,
			StackID: reqIter.Attributes.StackID,
			CVEScan: cveScan,
		}
		return appl.Codebases().Create(ctx, cdb)
	})
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}

	res := &app.CodebaseSingle{
		Data: ConvertCodebase(ctx.Request, *cdb),
	}
	ctx.ResponseData.Header().Set("Location", rest.AbsoluteURL(ctx.Request, app.CodebaseHref(res.Data.ID)))
	return ctx.Created(res)
}
1096218
func (pts *PipelineTemplatesService) Create(ctx context.Context, name string, st []*Stage) (ptr *PipelineTemplate, resp *APIResponse, err error) {
	apiVersion, err := pts.client.getAPIVersion(ctx, "admin/templates")
	if err != nil {
		return nil, nil, err
	}

	pt := PipelineTemplateRequest{
		Name:   name,
		Stages: st,
	}
	ptr = &PipelineTemplate{}

	_, resp, err = pts.client.postAction(ctx, &APIClientRequest{
		Path:         "admin/templates",
		APIVersion:   apiVersion,
		RequestBody:  pt,
		ResponseBody: ptr,
	})

	return

}
1222210
func Create(target *Surface) *Context {
	ret := wrapContext(C.cairo_create(target.Ptr))
	if err := ret.status(); err != nil {
		panic(err)
	}
	return ret
}
472767
func (c *examples) Create(example *v1.Example) (result *v1.Example, err error) {
	result = &v1.Example{}
	err = c.client.Post().
		Namespace(c.ns).
		Resource("examples").
		Body(example).
		Do().
		Into(result)
	return
}
678416
func (r *GormWorkItemLinkTypeRepository) Create(ctx context.Context, linkType WorkItemLinkType) (*WorkItemLinkType, error) {
	defer goa.MeasureSince([]string{"goa", "db", "workitemlinktype", "create"}, time.Now())
	if err := linkType.CheckValidForCreation(); err != nil {
		log.Error(ctx, map[string]interface{}{
			"wilt_id": linkType.ID.String(),
			"err":     err,
		}, "failed to validate link type")
		return nil, errs.WithStack(err)
	}
	db := r.db.Create(&linkType)
	if db.Error != nil {
		if gormsupport.IsUniqueViolation(db.Error, "work_item_link_types_name_idx") {
			log.Error(ctx, map[string]interface{}{
				"err":               db.Error,
				"space_template_id": linkType.SpaceTemplateID,
				"wilt_name":         linkType.Name,
			}, "unable to create work item link type because a link already exists with the same space_template_id and name")
			return nil, errors.NewDataConflictError(fmt.Sprintf("work item link type already exists with the same space_template_id: %s; name: %s ", linkType.SpaceTemplateID, linkType.Name))
		}
		log.Error(ctx, map[string]interface{}{
			"wilt_id": linkType.ID.String(),
			"err":     db.Error,
		}, "failed to create work item link type")
		return nil, errors.NewInternalError(ctx, errs.Wrap(db.Error, "failed to create link type"))
	}
	log.Info(ctx, map[string]interface{}{
		"wilt_id": linkType.ID.String(),
	}, "created work item link type")
	return &linkType, nil
}
710304
func (c *projectRequests) Create(projectRequest *project.ProjectRequest) (result *project.Project, err error) {
	result = &project.Project{}
	err = c.client.Post().
		Resource("projectrequests").
		Body(projectRequest).
		Do().
		Into(result)
	return
}