// GetAPINameByPattern return API name by analyze pattern
7364
func GetAPINameByPattern(
	pattern string,
	repl func(string) string,
) string {
	result := pattern
	result = regexpAPIVersionPrefix.ReplaceAllString(result, "")

	result = regexpAPIParam.ReplaceAllStringFunc(result, func(str string) string {
		param := str[1:]
		return "(?P<" + param + ">[^/]+)"
	})

	result = regexpAPIParam2.ReplaceAllStringFunc(result, func(str string) string {
		matches := regexpAPIParam2.FindStringSubmatch(str)
		param := matches[1]
		if repl == nil {
			return ""
		}
		return repl(param)
	})

	result = regexpAPISlashCamelCase.ReplaceAllStringFunc(result, func(str string) string {
		return strings.ToUpper(str[1:])
	})

	// remove all slash
	result = strings.Replace(result, "/", "", -1)

	return result
}
1069198
func getAPIError(code APIErrorCode) APIError {
	if apiErr, ok := errorCodes[code]; ok {
		return apiErr
	}
	return errorCodes.ToAPIErr(ErrInternalError)
}
1320784
func (t *Template) GetAWSKinesisAnalyticsApplicationOutputWithName(name string) (*resources.AWSKinesisAnalyticsApplicationOutput, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSKinesisAnalyticsApplicationOutput:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSKinesisAnalyticsApplicationOutput not found", name)
}
764289
func NewAPI(spec *loads.Document) *API {
	var an *analysis.Spec
	if spec != nil && spec.Spec() != nil {
		an = analysis.New(spec.Spec())
	}
	api := &API{
		spec:           spec,
		analyzer:       an,
		consumers:      make(map[string]runtime.Consumer, 10),
		producers:      make(map[string]runtime.Producer, 10),
		authenticators: make(map[string]runtime.Authenticator),
		operations:     make(map[string]map[string]runtime.OperationHandler),
		ServeError:     errors.ServeError,
		Models:         make(map[string]func() interface{}),
		formats:        strfmt.NewFormats(),
	}
	return api.WithJSONDefaults()
}
1074347
func FailedPattern(name, in, pattern string) *Validation {
	var msg string
	if in == "" {
		msg = fmt.Sprintf(patternFailNoIn, name, pattern)
	} else {
		msg = fmt.Sprintf(patternFail, name, in, pattern)
	}

	return &Validation{
		code:    PatternFailCode,
		Name:    name,
		In:      in,
		message: msg,
	}
}
906820
func (t *Template) GetAllAWSApiGatewayDomainNameResources() map[string]*resources.AWSApiGatewayDomainName {
	results := map[string]*resources.AWSApiGatewayDomainName{}
	for name, untyped := range t.Resources {
		switch resource := untyped.(type) {
		case *resources.AWSApiGatewayDomainName:
			results[name] = resource
		}
	}
	return results
}
249767
func isPattern(generator string) bool {
	for _, ptn := range PATTERNS {
		if ptn == generator {
			return true
		}
	}
	return false
}
950607
func (t *Template) GetAWSApiGatewayRestApiWithName(name string) (*resources.AWSApiGatewayRestApi, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSApiGatewayRestApi:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSApiGatewayRestApi not found", name)
}
552791
func ValidatePattern(p string, val string) bool {
	knownPatternsLock.RLock()
	r, ok := knownPatterns[p]
	knownPatternsLock.RUnlock()
	if !ok {
		r = regexp.MustCompile(p) // DSL validation makes sure regexp is valid
		knownPatternsLock.Lock()
		knownPatterns[p] = r
		knownPatternsLock.Unlock()
	}
	return r.MatchString(val)
}
324776
func (t *Template) GetAWSIAMUserWithName(name string) (*resources.AWSIAMUser, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSIAMUser:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSIAMUser not found", name)
}
748870
func (c *autoRegisterController) GetAPIServiceToSync(name string) *apiregistration.APIService {
	c.apiServicesToSyncLock.RLock()
	defer c.apiServicesToSyncLock.RUnlock()

	return c.apiServicesToSync[name]
}
95117
func (s *specAggregator) GetAPIServiceInfo(apiServiceName string) (handler http.Handler, etag string, exists bool) {
	s.rwMutex.RLock()
	defer s.rwMutex.RUnlock()

	if info, existingService := s.openAPISpecs[apiServiceName]; existingService {
		return info.handler, info.etag, true
	}
	return nil, "", false
}
1218357
func (t *Template) GetAWSKinesisAnalyticsV2ApplicationOutputWithName(name string) (*resources.AWSKinesisAnalyticsV2ApplicationOutput, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSKinesisAnalyticsV2ApplicationOutput:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSKinesisAnalyticsV2ApplicationOutput not found", name)
}
695182
func MustPattern(p Pattern, err error) Pattern {
	if err != nil {
		grpclog.Fatalf("Pattern initialization failed: %v", err)
	}
	return p
}
263397
func (t *Template) GetAWSAppMeshMeshWithName(name string) (*resources.AWSAppMeshMesh, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSAppMeshMesh:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSAppMeshMesh not found", name)
}
858773
func IsPattern(str string) bool {
	for i := 0; i < len(str); i++ {
		if str[i] == '*' || str[i] == '?' {
			return true
		}
	}
	return false
}
1328612
func (o *GetFqdnCacheIDParams) WithMatchpattern(matchpattern *string) *GetFqdnCacheIDParams {
	o.SetMatchpattern(matchpattern)
	return o
}