util

package
v0.0.0-...-31ffa90 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2025 License: MPL-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearDoubleQuote

func ClearDoubleQuote(s string) string

func ConvertKeys

func ConvertKeys(input interface{}) interface{}

convertKeys recursively converts all keys in a map from camelCase to snake_case

func ConvertMapToObject

func ConvertMapToObject(ctx context.Context, data map[string]interface{}) (types.Object, error)

Convert nested map structured json into terraform object

func CreateFuncMap

func CreateFuncMap() template.FuncMap

func DiagOff

func DiagOff[V, T interface{}](input func(ctx context.Context, elementType T, elements any) (V, diag.Diagnostics), ctx context.Context, elementType T, elements any) V

func ExtractDto

func ExtractDto(jsonFilePath, refreshObjectName string) ([]byte, error)

func ExtractPath

func ExtractPath(s string) string

func ExtractResourceName

func ExtractResourceName(jsonFilePath string) (string, error)

func FirstAlphabet

func FirstAlphabet(s string) string

func FirstAlphabetToLowerCase

func FirstAlphabetToLowerCase(s string) string

func FirstAlphabetToUpperCase

func FirstAlphabetToUpperCase(s string) string

func JoinStrings

func JoinStrings(sep string, items []string) string

func MakeIdGetter

func MakeIdGetter(target string) string

func MakeRequest

func MakeRequest(method, path, endpoint, reqBody string) (map[string]interface{}, error)

func MustAbs

func MustAbs(path string) string

func PathToPascal

func PathToPascal(s string) string

func ReadAndUnmarshal

func ReadAndUnmarshal[T any](filePath string, result *T) error

func RemoveDuplicates

func RemoveDuplicates(filePath string) error

func RemovingWhiteSpace

func RemovingWhiteSpace(input string) string

func SliceContains

func SliceContains(slice []string, value string) bool

func ToCamelCase

func ToCamelCase(s string) string

func ToLowerCase

func ToLowerCase(s string) string

func ToPascalCase

func ToPascalCase(s string) string

Types

type Attribute

type Attribute struct {
	resource.Attribute
	Computed bool `json:"computed"`
	Optional bool `json:"optional"`
	Required bool `json:"required"`
}

type Components

type Components struct {
	Schemas map[string]OASchema `json:"schemas"`
}

type CrudParameters

type CrudParameters struct {
	Create IndividualOperationInfo    `json:"create,omitempty"`
	Read   IndividualOperationInfo    `json:"read"`
	Update []*IndividualOperationInfo `json:"update"`
	Delete IndividualOperationInfo    `json:"delete"`
}

type DataSource

type DataSource struct {
	datasource.DataSource
	RefreshObjectName   string `json:"refresh_object_name"`
	ImportStateOverride string `json:"import_state_override"`
	Id                  string `json:"id"`
}

type IndividualOperationInfo

type IndividualOperationInfo struct {
	Parameters  []string             `json:"parameters,omitempty"`
	RequestBody *OptionalRequestBody `json:"request_body,omitempty"`
	Response    string               `json:"response,omitempty"`
	Method      string               `json:"method,omitempty"`
	Path        string               `json:"path,omitempty"`
}

type Info

type Info struct {
	Name string `json:"name"`
}

type Items

type Items struct {
	Type       string              `json:"type"`
	Properties map[string]Property `json:"properties"`
}

type ListAttributeElementType

type ListAttributeElementType struct {
	String interface{} `json:"string,omitempty"`
	Bool   interface{} `json:"bool,omitempty"`
	Int64  interface{} `json:"int64,omitempty"`
}

type ListAttributeType

type ListAttributeType struct {
	ComputedOptionalRequired string                   `json:"computed_optional_required"`
	ElementType              ListAttributeElementType `json:"element_type"`
}

type ListNestedAttributeType

type ListNestedAttributeType struct {
	ComputedOptionalRequired string           `json:"computed_optional_required"`
	NestedObject             NestedObjectType `json:"nested_object"`
}

type NcloudProvider

type NcloudProvider struct {
	provider.Provider
	Endpoint string `json:"endpoint,omitempty"`
}

type NcloudSpecification

type NcloudSpecification struct {
	spec.Specification
	Provider    *NcloudProvider `json:"provider"`
	Requests    []RequestInfo   `json:"requests"`
	Resources   []Resource      `json:"resources"`
	DataSources []DataSource    `json:"datasources"`
}

type NestedObjectType

type NestedObjectType struct {
	Attributes []resource.Attribute `json:"attributes"`
}

type OASchema

type OASchema struct {
	Properties map[string]Property `json:"properties"`
}

type OpenAPI

type OpenAPI struct {
	Paths      map[string]*PathItem `json:"paths"`
	Info       *Info                `json:"info"`
	Components *Components          `json:"components"`
}

type OptionalRequestBody

type OptionalRequestBody struct {
	Name     string                   `json:"name,omitempty"`
	Required []string                 `json:"required,omitempty"`
	Optional []*RequestParametersInfo `json:"optional,omitempty"`
}

type PathItem

type PathItem struct {
	Post *high.Operation `json:"post,omitempty"`
	Get  *high.Operation `json:"get,omitempty"`
}

type Paths

type Paths struct {
	AttributePath string
	ConfigPath    string
}

func InitializePaths

func InitializePaths(inputSpec, inputConfig, outputDir string) Paths

type Property

type Property struct {
	docs.SchemaProperty
	Type                     string              `json:"type"`
	Format                   string              `json:"format,omitempty"`
	ComputedOptionalRequired string              `json:"computed_optional_required,omitempty"`
	Items                    Items               `json:"items,omitempty"`
	Properties               map[string]Property `json:"properties"`
}

type RequestInfo

type RequestInfo struct {
	CrudParameters
	Name string `json:"name"`
	Id   string `json:"id"`
}

type RequestParametersInfo

type RequestParametersInfo struct {
	Name   string `json:"name,omitempty"`
	Type   string `json:"type,omitempty"`
	Format string `json:"format,omitempty"`
}

type Resource

type Resource struct {
	resource.Resource
	RefreshObjectName   string `json:"refresh_object_name"`
	ImportStateOverride string `json:"import_state_override"`
	Id                  string `json:"id"`
}

type Schema

type Schema struct {
	Attributes resource.Attributes `json:"attributes"`
}

type SingleNestedAttributeType

type SingleNestedAttributeType struct {
	ComputedOptionalRequired string               `json:"computed_optional_required"`
	Attributes               []resource.Attribute `json:"attributes"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL