// CreateNamedResource returns a function that will handle a resource creation with name.
778471
func CreateNamedResource(r rest.NamedCreater, scope *RequestScope, admission admission.Interface) http.HandlerFunc {
	return createHandler(r, scope, admission, true)
}
697264
func NewNamespaceNamer(shortNames bool) *NamespaceNamer {
	return &NamespaceNamer{shortNames: shortNames, re: regexp.MustCompile(invalidTokensExpr)}
}
887233
func (s *CreateAuthorizerOutput) SetIdentitySource(v []*string) *CreateAuthorizerOutput {
	s.IdentitySource = v
	return s
}
790564
func CreateCustomResourceDefinitions(clientset apiextensionsclient.Interface) error {
	if err := createCNPCRD(clientset); err != nil {
		return err
	}

	if err := createCEPCRD(clientset); err != nil {
		return err
	}

	return nil
}
304054
func (p *Postgres) createDataSourceName() string {
	parameters := []string{}

	addParam := func(key, val string) {
		parameters = append(parameters, fmt.Sprintf("%s=%s", key, val))
	}

	addParam("connect_timeout", strconv.Itoa(p.ConnectionTimeout))

	// detect host:port for backwards-compatibility
	host, port, err := net.SplitHostPort(p.Host)
	if err != nil {
		// not host:port, probably unix socket or bare address

		host = p.Host

		if p.Port != 0 {
			port = strconv.Itoa(int(p.Port))
		}
	}

	if host != "" {
		addParam("host", dataSourceStr(host))
	}

	if port != "" {
		addParam("port", port)
	}

	if p.User != "" {
		addParam("user", dataSourceStr(p.User))
	}

	if p.Password != "" {
		addParam("password", dataSourceStr(p.Password))
	}

	if p.Database != "" {
		addParam("dbname", dataSourceStr(p.Database))
	}

	if p.SSL.Mode == "" {
		// Assume the strictest mode if unspecified.
		addParam("sslmode", dataSourceStr(sslVerifyFull))
	} else {
		addParam("sslmode", dataSourceStr(p.SSL.Mode))
	}

	if p.SSL.CAFile != "" {
		addParam("sslrootcert", dataSourceStr(p.SSL.CAFile))
	}

	if p.SSL.CertFile != "" {
		addParam("sslcert", dataSourceStr(p.SSL.CertFile))
	}

	if p.SSL.KeyFile != "" {
		addParam("sslkey", dataSourceStr(p.SSL.KeyFile))
	}

	return strings.Join(parameters, " ")
}
985411
func (s *Service) CreateSource(ctx context.Context, src *influxdb.Source) error {
	err := s.kv.Update(ctx, func(tx Tx) error {
		src.ID = s.IDGenerator.ID()

		// Generating an organization id if it missing or invalid
		if !src.OrganizationID.Valid() {
			src.OrganizationID = s.IDGenerator.ID()
		}

		return s.putSource(ctx, tx, src)
	})
	if err != nil {
		return &influxdb.Error{
			Err: err,
		}
	}
	return nil
}
1100425
func NewResourceDefinition(name string, dsl func()) *ResourceDefinition {
	return &ResourceDefinition{
		Name:      name,
		MediaType: "text/plain",
		DSLFunc:   dsl,
	}
}
50116
func IsStandardResourceName(str string) bool {
	return standardResources.Has(str) || IsQuotaHugePageResourceName(core.ResourceName(str))
}
282462
func validateResourceName(value string, fldPath *field.Path) field.ErrorList {
	allErrs := field.ErrorList{}
	if !validation.IsQualifiedName(value) {
		return append(allErrs, field.Invalid(fldPath, value, qualifiedNameErrorMsg))
	}

	if len(strings.Split(value, "/")) == 1 {
		if !api.IsStandardResourceName(value) {
			return append(allErrs, field.Invalid(fldPath, value, "must be a standard resource type or fully qualified"))
		}
	}

	return field.ErrorList{}
}
959541
func (b *Builder) ResourceNames(resource string, names ...string) *Builder {
	for _, name := range names {
		// See if this input string is of type/name format
		tuple, ok, err := splitResourceTypeName(name)
		if err != nil {
			b.errs = append(b.errs, err)
			return b
		}

		if ok {
			b.resourceTuples = append(b.resourceTuples, tuple)
			continue
		}
		if len(resource) == 0 {
			b.errs = append(b.errs, fmt.Errorf("the argument %q must be RESOURCE/NAME", name))
			continue
		}

		// Use the given default type to create a resource tuple
		b.resourceTuples = append(b.resourceTuples, resourceTuple{Resource: resource, Name: name})
	}
	return b
}
743623
func (m *ResultColumn) SourceName() string {
	if m.Col != nil && m.Col.SourceField != "" {
		return m.Col.SourceField
	}
	return m.Name
}
449276
func (g *Generator) makeAliasForName(name string) *string {
	var prefixesCount int
	for _, imp := range g.imports {
		if strings.HasPrefix(imp.String(), name) {
			prefixesCount++
		}
	}

	alias := fmt.Sprintf("%s%d", name, prefixesCount+1)

	return &alias
}
742416
func NewResource(context hap.Context, imgFn GetImageFunc) *Resource {
	r := Resource{
		context: context,
		imgFn:   imgFn,
	}

	return &r
}
1043430
func createService(client corev1.ServicesGetter, namespace string) error {
	obj := generateService(namespace)
	_, err := client.Services(obj.Namespace).Create(obj)
	return err
}
270597
func (d *DNS) CreateDomainResource(r *Resource) (*ResourceResponse, error) {
	// Ensure that the resource has a name.
	if len(r.Name) == 0 {
		return nil, linode.NewError(errors.New("dns: creating a resource requires Name be specified"))
	}

	// Initialize parameters that are shared across resource types.
	params := linode.Parameters{
		"DomainID": strconv.Itoa(r.DomainID),
		"Name":     r.Name,
		"TTL_Sec":  strconv.Itoa(r.TTL_Sec),
	}

	// Ensure that the resource has a valid, supported type.
	r.Type = strings.ToUpper(r.Type)
	switch r.Type {
	case "A":
	case "AAAA":
	case "CNAME":
	case "MX":
	case "NS":
	case "TXT":
		// No further processing required for these types.
		break
	case "SRV":
		// Ensure that SRV has a protocol.
		if len(r.Protocol) == 0 {
			return nil, linode.NewError(errors.New("dns: creating a SRV resource requires Priority be specified"))
		}
		params.Set("Protocol", r.Protocol)
		break
	default:
		// Unsupported type.
		return nil, linode.NewError(errors.New("dns: can not create resource of unsupported type: " + r.Type))
	}
	params.Set("Type", r.Type)

	// Ensure that the resource has a valid target.
	if len(r.Target) == 0 {
		return nil, linode.NewError(errors.New("dns: creating a resource requires Target to be specified"))
	}
	params.Set("Target", r.Target)

	if r.Name == "MX" || r.Name == "SRV" {
		// If priority is defined, ensure that it's valid.
		if r.Priority != nil {
			priority, ok := r.Priority.(int)
			if !ok {
				return nil, linode.NewError(errors.New("dns: priority must be specified as an int"))
			}
			if priority < 0 || priority > 255 {
				return nil, linode.NewError(errors.New("dns: priority must be within the range of 0-255"))
			}
			r.Priority = priority
			params.Set("Priority", strconv.Itoa(priority))
		}
	}

	// Create the resource.
	return d.createDomainResource(params)
}
407788
func (s *SourceService) CreateSource(ctx context.Context, src *influxdb.Source) error {
	p, err := influxdb.NewPermission(influxdb.WriteAction, influxdb.SourcesResourceType, src.OrganizationID)
	if err != nil {
		return err
	}

	if err := IsAllowed(ctx, *p); err != nil {
		return err
	}

	return s.s.CreateSource(ctx, src)
}
436893
func (s *ServiceOfferingService) NewCreateServiceOfferingParams(displaytext string, name string) *CreateServiceOfferingParams {
	p := &CreateServiceOfferingParams{}
	p.p = make(map[string]interface{})
	p.p["displaytext"] = displaytext
	p.p["name"] = name
	return p
}