// StackScriptCreate maps to the 'stackscript.create' call.
//
// https://www.linode.com/api/stackscript/stackscript.create
503068
func (c *Client) StackScriptCreate(label string, distIDList string, script string,
	description *string, isPublic *bool, revNote *string) (ssID int, err error) {

	args := make(map[string]interface{})
	args["Label"] = label
	args["Description"] = description
	args["DistributionIDList"] = distIDList
	args["rev_note"] = revNote
	args["script"] = script

	if isPublic != nil {
		if *isPublic == true {
			args["isPublic"] = 1
		} else {
			args["isPublic"] = 0
		}
	}

	data, err := c.apiCall("stackscript.create", args)
	if err != nil {
		return 0, err
	}

	err = unmarshalSingle(data, "StackScriptID", &ssID)
	if err != nil {
		return 0, err
	}

	return ssID, nil
}
1101676
func (e *Executor) Create(id string, spec specs.Spec, stdout, stderr io.WriteCloser) error {
	opts := runctypes.RuncOptions{
		RuntimeRoot: filepath.Join(e.rootDir, "runtime-root"),
	}
	ctx := context.Background()
	err := e.client.Create(ctx, id, &spec, &opts)
	if err != nil {
		status, err2 := e.client.Status(ctx, id)
		if err2 != nil {
			if !errdefs.IsNotFound(err2) {
				logrus.WithError(err2).WithField("id", id).Warn("Received an error while attempting to read plugin status")
			}
		} else {
			if status != containerd.Running && status != containerd.Unknown {
				if err2 := e.client.Delete(ctx, id); err2 != nil && !errdefs.IsNotFound(err2) {
					logrus.WithError(err2).WithField("plugin", id).Error("Error cleaning up containerd container")
				}
				err = e.client.Create(ctx, id, &spec, &opts)
			}
		}

		if err != nil {
			return errors.Wrap(err, "error creating containerd container")
		}
	}

	_, err = e.client.Start(ctx, id, "", false, attachStreamsFunc(stdout, stderr))
	if err != nil {
		deleteTaskAndContainer(ctx, e.client, id, nil)
	}
	return err
}
1116933
func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ *taskAPI.CreateTaskResponse, err error) {
	s.mu.Lock()
	defer s.mu.Unlock()

	container, err := runc.NewContainer(ctx, s.platform, r)
	if err != nil {
		return nil, err
	}

	s.containers[r.ID] = container

	s.send(&eventstypes.TaskCreate{
		ContainerID: r.ID,
		Bundle:      r.Bundle,
		Rootfs:      r.Rootfs,
		IO: &eventstypes.TaskIO{
			Stdin:    r.Stdin,
			Stdout:   r.Stdout,
			Stderr:   r.Stderr,
			Terminal: r.Terminal,
		},
		Checkpoint: r.Checkpoint,
		Pid:        uint32(container.Pid()),
	})

	return &taskAPI.CreateTaskResponse{
		Pid: uint32(container.Pid()),
	}, nil
}
50993
func (d *Deployer) Create(ctx context.Context) (*compute.Instance, error) {
	if err := d.enableAPIs(); err != nil {
		return nil, projectIDError{
			id:    d.Conf.Project,
			cause: err,
		}
	}
	if err := d.checkProjectID(); err != nil {
		return nil, err
	}

	computeService, _ := compute.New(d.Client)
	storageService, _ := storage.New(d.Client)

	fwc := make(chan error, 1)
	go func() {
		fwc <- d.setFirewall(ctx, computeService)
	}()

	config := cloudConfig(d.Conf)
	const maxCloudConfig = 32 << 10 // per compute API docs
	if len(config) > maxCloudConfig {
		return nil, fmt.Errorf("cloud config length of %d bytes is over %d byte limit", len(config), maxCloudConfig)
	}

	if zone, err := d.projectHasInstance(); zone != "" {
		return nil, instanceExistsError{
			project: d.Conf.Project,
			zone:    zone,
		}
	} else if err != nil {
		return nil, fmt.Errorf("could not scan project for existing instances: %v", err)
	}

	if err := d.setBuckets(ctx, storageService); err != nil {
		return nil, fmt.Errorf("could not create buckets: %v", err)
	}

	if err := d.createInstance(ctx, computeService); err != nil {
		return nil, fmt.Errorf("could not create compute instance: %v", err)
	}

	inst, err := computeService.Instances.Get(d.Conf.Project, d.Conf.Zone, d.Conf.Name).Do()
	if err != nil {
		return nil, fmt.Errorf("error getting instance after creation: %v", err)
	}
	if Verbose {
		ij, _ := json.MarshalIndent(inst, "", "    ")
		d.Printf("Instance: %s", ij)
	}

	if err = <-fwc; err != nil {
		return nil, fmt.Errorf("could not create firewall rules: %v", err)
	}
	return inst, nil
}
1262161
func (c *FakeAppProjects) Create(appProject *v1alpha1.AppProject) (result *v1alpha1.AppProject, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewCreateAction(appprojectsResource, c.ns, appProject), &v1alpha1.AppProject{})

	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha1.AppProject), err
}
374278
func NewCreate(ctx *middleware.Context, handler CreateHandler) *Create {
	return &Create{Context: ctx, Handler: handler}
}
1189634
func (t *LinodeService) Create(dataCenterId int, planId int, paymentTerm int) (*LinodeResponse, error) {
	u := &url.Values{}
	u.Add("DatacenterID", strconv.Itoa(dataCenterId))
	u.Add("PlanID", strconv.Itoa(planId))
	u.Add("PaymentTerm", strconv.Itoa(paymentTerm))
	v := LinodeResponse{}
	if err := t.client.do("linode.create", u, &v.Response); err != nil {
		return nil, err
	}

	if err := json.Unmarshal(v.RawData, &v.LinodeId); err != nil {
		return nil, err
	}
	return &v, nil
}
1168639
func (s *GroupsService) Create(name string) *GroupsCreateCall {
	var call GroupsCreateCall
	call.service = s
	call.name = name
	return &call
}
1114150
func (c *Client) AppCreate(options *AppCreateOpts) (*App, error) {
	var appRes App
	return &appRes, c.Post(&appRes, "/apps", options)
}
260547
func (c *Client) LinodeDiskCreate(linodeID int, label string, dType string,
	size int) (jobID int, diskID int, err error) {

	args := make(map[string]interface{})
	args["LinodeID"] = linodeID
	args["Label"] = label
	args["Type"] = dType
	args["Size"] = size

	data, err := c.apiCall("linode.disk.create", args)
	if err != nil {
		return 0, 0, err
	}

	out := struct {
		JobID  int `json:"JobID"`
		DiskID int `json:"DiskID"`
	}{}

	err = json.Unmarshal(data, &out)
	if err != nil {
		return 0, 0, err
	}

	return out.JobID, out.DiskID, err
}
1000238
func (zs *Server) Create(ctx context.Context, filePath string, contents []byte) (topo.Version, error) {
	zkPath := path.Join(zs.root, filePath)

	pathCreated, err := CreateRecursive(ctx, zs.conn, zkPath, contents, 0, zk.WorldACL(PermFile), -1)
	if err != nil {
		return nil, convertError(err, zkPath)
	}

	// Now do a Get to get the version. If the content doesn't
	// match, it means someone else already changed the file,
	// between our Create and Get. It is safer to return an error here,
	// and let the calling process recover if it can.
	data, stat, err := zs.conn.Get(ctx, pathCreated)
	if err != nil {
		return nil, convertError(err, zkPath)
	}
	if !bytes.Equal(data, contents) {
		return nil, fmt.Errorf("file contents changed between zk.Create and zk.Get")
	}

	return ZKVersion(stat.Version), nil
}
1042055
func (m *MockNodeInterface) Create(arg0 *v1.Node) (*v1.Node, error) {
	ret := m.ctrl.Call(m, "Create", arg0)
	ret0, _ := ret[0].(*v1.Node)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
79909
func (cli *Client) PluginCreate(ctx context.Context, createContext io.Reader, createOptions types.PluginCreateOptions) error {
	headers := http.Header(make(map[string][]string))
	headers.Set("Content-Type", "application/x-tar")

	query := url.Values{}
	query.Set("name", createOptions.RepoName)

	resp, err := cli.postRaw(ctx, "/plugins/create", query, createContext, headers)
	ensureReaderClosed(resp)
	return err
}
41796
func (mr *MockClusterRoleInterfaceMockRecorder) Create(arg0 interface{}) *gomock.Call {
	return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockClusterRoleInterface)(nil).Create), arg0)
}
812428
func (r *Runtime) Create() (err error) {
	var args []string
	args = append(args, "create")
	if r.PidFile != "" {
		args = append(args, "--pid-file", r.PidFile)
	}
	if r.BundleDir != "" {
		args = append(args, "--bundle", r.BundleDir)
	}
	if r.ID != "" {
		args = append(args, r.ID)
	}
	cmd := exec.Command(r.RuntimeCommand, args...)
	id := uuid.NewV4().String()
	r.stdout, err = os.OpenFile(filepath.Join(r.bundleDir(), fmt.Sprintf("stdout-%s", id)), os.O_CREATE|os.O_EXCL|os.O_RDWR, 0600)
	if err != nil {
		return err
	}
	cmd.Stdout = r.stdout
	r.stderr, err = os.OpenFile(filepath.Join(r.bundleDir(), fmt.Sprintf("stderr-%s", id)), os.O_CREATE|os.O_EXCL|os.O_RDWR, 0600)
	if err != nil {
		return err
	}
	cmd.Stderr = r.stderr

	err = cmd.Run()
	if err == nil {
		return err
	}

	if e, ok := err.(*exec.ExitError); ok {
		stdout, stderr, _ := r.ReadStandardStreams()
		if len(stderr) == 0 {
			stderr = stdout
		}
		e.Stderr = stderr
		return e
	}
	return err
}
154119
func (l Local) Create(_ context.Context, path string) (io.WriteCloser, error) {
	dir := l.fullPath(filepath.Dir(path))
	if _, err := os.Stat(dir); os.IsNotExist(err) {
		if err := os.MkdirAll(dir, LocalCreatePathMode); err != nil {
			return nil, err
		}
	}

	f, err := os.Create(l.fullPath(path))
	if err != nil {
		return nil, err
	}
	return f, nil
}
31316
func (c *FakeFischers) Create(fischer *v1alpha1.Fischer) (result *v1alpha1.Fischer, err error) {
	obj, err := c.Fake.
		Invokes(testing.NewRootCreateAction(fischersResource, fischer), &v1alpha1.Fischer{})
	if obj == nil {
		return nil, err
	}
	return obj.(*v1alpha1.Fischer), err
}