// Create creates a workflow from the given factory name with the
// provided args. Returns the unique UUID of the workflow. The
// workflowpb.Workflow object is saved in the topo server after
// creation.
557939
func (m *Manager) Create(ctx context.Context, factoryName string, args []string) (string, error) {
	m.mu.Lock()
	defer m.mu.Unlock()

	// Find the factory.
	factory, ok := factories[factoryName]
	if !ok {
		return "", fmt.Errorf("no factory named %v is registered", factoryName)
	}

	// Create the initial workflowpb.Workflow object.
	w := &workflowpb.Workflow{
		Uuid:        gouuid.NewUUID().String(),
		CreateTime:  time.Now().UnixNano(),
		FactoryName: factoryName,
		State:       workflowpb.WorkflowState_NotStarted,
	}

	// Let the factory parse the parameters and initialize the
	// object.
	if err := factory.Init(m, w, args); err != nil {
		return "", err
	}
	rw, err := m.instantiateWorkflow(w)
	if err != nil {
		return "", err
	}

	// Now save the workflow in the topo server.
	rw.wi, err = m.ts.CreateWorkflow(ctx, w)
	if err != nil {
		return "", err
	}

	// And we're done.
	log.Infof("Created workflow %s (%s, %s)", w.Uuid, factoryName, w.Name)
	return w.Uuid, nil
}
467987
func (n *Network) Create() error {
	var err C.virError
	result := C.virNetworkCreateWrapper(n.ptr, &err)
	if result == -1 {
		return makeError(&err)
	}
	return nil
}
1010802
func (c *CodebaseController) Create(ctx *app.CreateCodebaseContext) error {
	_, err := login.ContextIdentity(ctx)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrUnauthorized(err.Error()))
	}
	var cb *codebase.Codebase
	err = application.Transactional(c.db, func(appl application.Application) error {
		cb, err = appl.Codebases().Load(ctx, ctx.CodebaseID)
		return err
	})
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}
	ns, err := c.getCheNamespace(ctx)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrInternal(err.Error()))
	}
	cheClient, err := c.NewCheClient(ctx, ns)
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, goa.ErrInternal(err.Error()))
	}

	stackID := "java-centos"
	if cb.StackID != nil && *cb.StackID != "" {
		stackID = *cb.StackID
	}

	workspace := che.WorkspaceRequest{
		Branch:     getWorkspaceBranch(ctx),
		StackID:    stackID,
		Repository: cb.URL,
	}
	workspaceResp, err := cheClient.CreateWorkspace(ctx, workspace)
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"codebase_id": cb.ID,
			"stack_id":    stackID,
			"err":         err,
		}, "unable to create workspaces")
		if werr, ok := err.(*che.StarterError); ok {
			log.Error(ctx, map[string]interface{}{
				"codebase_id": cb.ID,
				"stack_id":    stackID,
				"err":         err,
			}, "unable to create workspaces: %s", werr.String())
		}
		return jsonapi.JSONErrorResponse(ctx, goa.ErrInternal(err.Error()))
	}

	err = application.Transactional(c.db, func(appl application.Application) error {
		cb.LastUsedWorkspace = workspaceResp.Config.Name
		_, err := appl.Codebases().Save(ctx, cb)
		return err
	})
	if err != nil {
		return jsonapi.JSONErrorResponse(ctx, err)
	}
	ideURL := workspaceResp.GetHrefByRelOfWorkspaceLink(che.IdeUrlRel)
	resp := &app.WorkspaceOpen{
		Links: &app.WorkspaceOpenLinks{
			Open: &ideURL,
		},
	}
	return ctx.OK(resp)
}
177781
func (firewalls *Firewalls) Create(ctx context.Context, id string, firewall *Firewall) (fw *Firewall, err error) {
	buffer := new(bytes.Buffer)
	err = json.NewEncoder(buffer).Encode(firewall)
	if err != nil {
		return
	}
	response, err := httpDo(ctx, firewalls.Options, "POST", apiURL("/zones/%s/firewall/access_rules/rules", id), buffer)
	if err != nil {
		return
	}
	defer response.Body.Close()
	result, err := readResponse(response.Body)
	if err != nil {
		return
	}
	fw = new(Firewall)
	err = json.Unmarshal(result.Result, &fw)
	return
}
311184
func (f *Factory) Create(componentName string) (interface{}, error) {
	if info, exists := f.registry[componentName]; exists {
		return info.Constructor()
	}
	return nil, fmt.Errorf("Factory error: component '%s' does not exist", componentName)
}
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
}
710125
func (r *GormBoardRepository) Create(ctx context.Context, b Board) (*Board, error) {
	if len(b.Columns) <= 0 {
		return nil, errors.NewBadParameterError("columns", b.Columns).Expected("not empty")
	}
	if b.ID == uuid.Nil {
		b.ID = uuid.NewV4()
	}
	db := r.db.Create(&b)
	if db.Error != nil {
		return nil, errors.NewInternalError(ctx, db.Error)
	}
	log.Debug(ctx, map[string]interface{}{"board_id": b.ID}, "created work item board")
	// Create entries for each column in the column list
	for _, column := range b.Columns {
		if column.ID == uuid.Nil {
			column.ID = uuid.NewV4()
		}
		column.BoardID = b.ID
		db = db.Create(&column)
		if db.Error != nil {
			return nil, errors.NewInternalError(ctx, db.Error)
		}
	}
	return &b, nil
}
383558
func (s *REST) Create(ctx context.Context, obj runtime.Object, _ rest.ValidateObjectFunc, options *metav1.CreateOptions) (runtime.Object, error) {
	mapping, ok := obj.(*userinternal.UserIdentityMapping)
	if !ok {
		return nil, kerrs.NewBadRequest("invalid type")
	}
	Strategy.PrepareForCreate(ctx, mapping)
	createdMapping, _, err := s.createOrUpdate(ctx, obj, true)
	return createdMapping, err
}
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
}
616731
func Create(c *middleware.Context) {
	if c.Req.Method == "POST" {
		bucket, e := models.BucketCreate(c.Query("title"))
		if e != nil {
			fmt.Println(e)
			c.Error(500, e.Error())
			return
		}
		c.Redirect("/buckets/" + fmt.Sprint(bucket.Id))
		return
	}
	c.HTML(200, "buckets/create")
}
473848
func (m *GormUserRepository) Create(ctx context.Context, u *User) error {
	defer goa.MeasureSince([]string{"goa", "db", "user", "create"}, time.Now())
	if u.ID == uuid.Nil {
		u.ID = uuid.NewV4()
	}

	err := m.db.Create(u).Error
	if err != nil {
		log.Error(ctx, map[string]interface{}{
			"user_id": u.ID,
			"err":     err,
		}, "unable to create the user")
		return errs.WithStack(err)
	}
	log.Debug(ctx, map[string]interface{}{
		"user_id": u.ID,
	}, "User created!")
	return nil
}
508253
func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ *taskAPI.CreateTaskResponse, err error) {
	return nil, errdefs.ErrNotImplemented
}
1272002
func (l *linuxProcessor) Create(ctx context.Context, eventInfo *common.EventInfo) error {
	// This should never be called for Linux Processes
	return fmt.Errorf("Use start directly for Linux processes. Create not supported")
}
1197380
func (c *imageStreamMappings) Create(imageStreamMapping *image.ImageStreamMapping) (result *v1.Status, err error) {
	result = &v1.Status{}
	err = c.client.Post().
		Namespace(c.ns).
		Resource("imagestreammappings").
		Body(imageStreamMapping).
		Do().
		Into(result)
	return
}
186022
func (p *ProjectsClient) Create(ctx context.Context, org *identity.ID, name string) (*envelope.Project, error) {
	project := projectCreateRequest{}
	project.Body.OrgID = org
	project.Body.Name = name

	res := envelope.Project{}
	err := p.client.RoundTrip(ctx, "POST", "/projects", nil, &project, &res)
	return &res, err
}
1351498
func (c *foos) Create(foo *v1alpha1.Foo) (result *v1alpha1.Foo, err error) {
	result = &v1alpha1.Foo{}
	err = c.client.Post().
		Namespace(c.ns).
		Resource("foos").
		Body(foo).
		Do().
		Into(result)
	return
}
245568
func (r *GormWorkItemTypeGroupRepository) Create(ctx context.Context, g WorkItemTypeGroup) (*WorkItemTypeGroup, error) {
	defer goa.MeasureSince([]string{"goa", "db", "workitemtypegroup", "create"}, time.Now())
	if len(g.TypeList) <= 0 {
		return nil, errors.NewBadParameterError("type_list", g.TypeList).Expected("not empty")
	}
	if g.ID == uuid.Nil {
		g.ID = uuid.NewV4()
	}
	db := r.db.Create(&g)
	if db.Error != nil {
		return nil, errors.NewInternalError(ctx, db.Error)
	}
	log.Debug(ctx, map[string]interface{}{"witg_id": g.ID}, "created work item type group")
	// Create entries for each member in the type list
	for idx, ID := range g.TypeList {
		member := typeGroupMember{
			TypeGroupID:    g.ID,
			WorkItemTypeID: ID,
			Position:       idx,
		}
		db = db.Create(&member)
		if db.Error != nil {
			return nil, errors.NewInternalError(ctx, db.Error)
		}
	}
	return &g, nil
}