Documentation
¶
Index ¶
- Constants
- func Sanitize(document string) (string, error)
- type Handler
- type HandlerSchema
- type MetaJsonSchema
- type Property
- type PropertyJsonPointer
- type PropertyJsonPointers
- type PropertyRelationshipRef
- type PropertySubschema
- type PropertyTransform
- type Reference
- type Resource
- func (r *Resource) Expand() error
- func (r *Resource) IsCreateOnlyPropertyPath(path string) bool
- func (r *Resource) IsReadOnleyPropertyPath(path string) bool
- func (r *Resource) IsRequired(name string) bool
- func (r *Resource) ResolveProperties(properties map[string]*Property) error
- func (r *Resource) ResolveProperty(property *Property) (bool, error)
- func (r *Resource) ResolveReference(ref Reference) (*Property, error)
- func (r *Resource) UnwrapOneOfProperties(property *Property) error
- type ResourceJsonSchema
- type ResourceLink
- type Tagging
- type Type
Constants ¶
const ( HandlerTypeCreate = "create" HandlerTypeDelete = "delete" HandlerTypeList = "list" HandlerTypeRead = "read" HandlerTypeUpdate = "update" )
const ( PropertyArrayTypeAttributeList = "AttributeList" PropertyArrayTypeStandard = "Standard" )
const ( PropertyFormatDate = "date" PropertyFormatDateTime = "date-time" PropertyFormatEmail = "email" PropertyFormatHostname = "hostname" PropertyFormatIdnEmail = "idn-email" PropertyFormatIdnHostname = "idn-hostname" PropertyFormatIpv4 = "ipv4" PropertyFormatIpv6 = "ipv6" PropertyFormatIri = "iri" PropertyFormatIriReference = "iri-reference" PropertyFormatJsonPointer = "json-pointer" PropertyFormatRegex = "regex" PropertyFormatRelativeJsonPointer = "relative-json-pointer" PropertyFormatTime = "time" PropertyFormatUri = "uri" PropertyFormatUriReference = "uri-reference" PropertyFormatUriTemplate = "uri-templates" )
const ( PropertyTypeArray = "array" PropertyTypeBoolean = "boolean" PropertyTypeInteger = "integer" PropertyTypeNull = "null" PropertyTypeNumber = "number" PropertyTypeObject = "object" PropertyTypeString = "string" )
const ( JsonPointerReferenceTokenSeparator = "/" PropertiesJsonPointerReferenceToken = "properties" PropertiesJsonPointerPrefix = JsonPointerReferenceTokenSeparator + PropertiesJsonPointerReferenceToken )
const ( ReferenceAnchor = "#" ReferenceSeparator = "/" ReferenceTypeDefinitions = "definitions" ReferenceTypeProperties = "properties" )
const ( ReplacementStrategyCreateThenDelete = "create_then_delete" ReplacementStrategyDeleteThenCreate = "delete_then_create" )
Variables ¶
This section is empty.
Functions ¶
func Sanitize ¶
Sanitize returns a sanitized copy of the specified JSON Schema document. The sanitized copy works around any problems with JSON Schema regex validation by
- Rewriting all patternProperty regexes to the empty string (the regex is never used anyway)
- Rewriting all unsupported (valid for ECMA-262 but not for Go) pattern regexes to the empty string
Types ¶
type Handler ¶
type Handler struct {
HandlerSchema *HandlerSchema `json:"handlerSchema,omitempty"`
Permissions []string `json:"permissions,omitempty"`
TimeoutInMinutes int `json:"timeoutInMinutes,omitempty"`
}
type HandlerSchema ¶
type HandlerSchema struct {
AllOf []*PropertySubschema `json:"allOf,omitempty"`
AnyOf []*PropertySubschema `json:"anyOf,omitempty"`
OneOf []*PropertySubschema `json:"oneOf,omitempty"`
Properties map[string]*Property `json:"properties,omitempty"`
Required []string `json:"required,omitempty"`
}
type MetaJsonSchema ¶
type MetaJsonSchema struct {
// contains filtered or unexported fields
}
MetaJsonSchema represents the meta-schema for resource schemas
func NewMetaJsonSchemaDocument ¶
func NewMetaJsonSchemaDocument(document string) (*MetaJsonSchema, error)
NewMetaJsonSchemaDocument returns a MetaJsonSchema or any errors from the provided document.
func NewMetaJsonSchemaPath ¶
func NewMetaJsonSchemaPath(path string) (*MetaJsonSchema, error)
NewMetaJsonSchemaPath returns a MetaJsonSchema or any errors from the provided document at the file path.
func (*MetaJsonSchema) ValidateResourceDocument ¶
func (s *MetaJsonSchema) ValidateResourceDocument(document string) error
ValidateResourceDocument validates the provided document against the meta-schema.
func (*MetaJsonSchema) ValidateResourceJsonSchema ¶
func (s *MetaJsonSchema) ValidateResourceJsonSchema(resourceJsonSchema *ResourceJsonSchema) error
ValidateResourceJsonSchema validates the provided ResourceJsonSchema against the meta-schema.
func (*MetaJsonSchema) ValidateResourcePath ¶
func (s *MetaJsonSchema) ValidateResourcePath(path string) error
ValidateResourcePath validates the provided document at the file path against the meta-schema.
type Property ¶
type Property struct {
AdditionalProperties *bool `json:"additionalProperties,omitempty"`
AllOf []*PropertySubschema `json:"allOf,omitempty"`
AnyOf []*PropertySubschema `json:"anyOf,omitempty"`
ArrayType *string `json:"arrayType,omitempty"`
Comment *string `json:"$comment,omitempty"`
Default interface{} `json:"default,omitempty"`
Description *string `json:"description,omitempty"`
Enum []interface{} `json:"enum,omitempty"`
Examples []interface{} `json:"examples,omitempty"`
Format *string `json:"format,omitempty"`
InsertionOrder *bool `json:"insertionOrder,omitempty"`
Items *Property `json:"items,omitempty"`
Maximum *json.Number `json:"maximum,omitempty"`
MaxItems *int `json:"maxItems,omitempty"`
MaxLength *int `json:"maxLength,omitempty"`
Minimum *json.Number `json:"minimum,omitempty"`
MinItems *int `json:"minItems,omitempty"`
MinLength *int `json:"minLength,omitempty"`
OneOf []*PropertySubschema `json:"oneOf,omitempty"`
Pattern *string `json:"pattern,omitempty"`
PatternProperties map[string]*Property `json:"patternProperties,omitempty"`
Properties map[string]*Property `json:"properties,omitempty"`
Ref *Reference `json:"$ref,omitempty"`
RelationshipRef *PropertyRelationshipRef `json:"relationshipRef,omitempty"`
Required []string `json:"required,omitempty"`
Type *Type `json:"type,omitempty"`
UniqueItems *bool `json:"uniqueItems,omitempty"`
}
Property represents the Cloud Control Resource Schema customization for Definitions and Properties.
func (*Property) IsRequired ¶
type PropertyJsonPointer ¶
type PropertyJsonPointer string
PropertyJsonPointer is a simplistic RFC 6901 handler for properties JSON Pointers.
func (*PropertyJsonPointer) EqualsPath ¶
func (p *PropertyJsonPointer) EqualsPath(other []string) bool
EqualsPath returns true if all path parts match.
This automatically handles stripping the /properties prefix.
func (*PropertyJsonPointer) EqualsStringPath ¶
func (p *PropertyJsonPointer) EqualsStringPath(path string) bool
EqualsStringPath returns true if the path string matches.
This automatically handles stripping the /properties prefix.
func (*PropertyJsonPointer) Path ¶
func (p *PropertyJsonPointer) Path() []string
Path returns the path parts.
This automatically handles stripping the /properties path part.
func (*PropertyJsonPointer) String ¶
func (p *PropertyJsonPointer) String() string
String returns a string representation of the PropertyJsonPointer.
type PropertyJsonPointers ¶
type PropertyJsonPointers []PropertyJsonPointer
PropertyJsonPointers is a list of PropertyJsonPointer.
func (PropertyJsonPointers) ContainsPath ¶
func (ptrs PropertyJsonPointers) ContainsPath(path []string) bool
ContainsPath returns true if an element matches the path.
type PropertyRelationshipRef ¶
type PropertyRelationshipRef struct {
PropertyPath *PropertyJsonPointer `json:"propertyPath,omitempty"`
TypeName *string `json:"typeName,omitempty"`
}
type PropertySubschema ¶
type PropertySubschema struct {
AllOf []*PropertySubschema `json:"allOf,omitempty"`
AnyOf []*PropertySubschema `json:"anyOf,omitempty"`
OneOf []*PropertySubschema `json:"oneOf,omitempty"`
Properties map[string]*Property `json:"properties,omitempty"`
Required []string `json:"required,omitempty"`
}
type PropertyTransform ¶
PropertyTransform represents property transform values.
type Reference ¶
type Reference string
Reference is an internal implementation for RFC 6901 JSON Pointer values.
type Resource ¶
type Resource struct {
AdditionalIdentifiers []PropertyJsonPointers `json:"additionalIdentifiers,omitempty"`
AdditionalProperties *bool `json:"additionalProperties,omitempty"`
AllOf []*PropertySubschema `json:"allOf,omitempty"`
AnyOf []*PropertySubschema `json:"anyOf,omitempty"`
ConditionalCreateOnlyProperties PropertyJsonPointers `json:"conditionalCreateOnlyProperties,omitempty"`
CreateOnlyProperties PropertyJsonPointers `json:"createOnlyProperties,omitempty"`
Definitions map[string]*Property `json:"definitions,omitempty"`
DeprecatedProperties PropertyJsonPointers `json:"deprecatedProperties,omitempty"`
Description *string `json:"description,omitempty"`
Handlers map[string]*Handler `json:"handlers,omitempty"`
NonPublicDefinitions PropertyJsonPointers `json:"nonPublicDefinitions,omitempty"`
NonPublicProperties PropertyJsonPointers `json:"nonPublicProperties,omitempty"`
OneOf []*PropertySubschema `json:"oneOf,omitempty"`
PrimaryIdentifier PropertyJsonPointers `json:"primaryIdentifier,omitempty"`
Properties map[string]*Property `json:"properties,omitempty"`
PropertyTransform PropertyTransform `json:"propertyTransform,omitempty"`
ReadOnlyProperties PropertyJsonPointers `json:"readOnlyProperties,omitempty"`
ReplacementStrategy *string `json:"replacementStrategy,omitempty"`
Required []string `json:"required,omitempty"`
ResourceLink *ResourceLink `json:"resourceLink,omitempty"`
SourceURL *string `json:"sourceUrl,omitempty"`
Taggable *bool `json:"taggable,omitempty"`
Tagging *Tagging `json:"tagging,omitempty"`
TypeName *string `json:"typeName,omitempty"`
WriteOnlyProperties PropertyJsonPointers `json:"writeOnlyProperties,omitempty"`
}
func (*Resource) Expand ¶
Expand replaces all Definition and Property JSON Pointer references with their content. This functionality removes the need for recursive logic when accessing Definitions and Properties. In unresolved form nested properties are not allowed, instead nested properties use a '$ref' JSON Pointer to reference a definition.
func (*Resource) IsCreateOnlyPropertyPath ¶
func (*Resource) IsReadOnleyPropertyPath ¶
func (*Resource) IsRequired ¶
func (*Resource) ResolveProperties ¶
ResolveProperties resolves all References in a top-level name-to-property map. In theory unresolved form nested properties are not allowed but in practice they do occur, so support arbitrarily deeply nested references.
func (*Resource) ResolveProperty ¶
ResolveProperty resolves any Reference (JSON Pointer) in a Property. Returns whether a Reference was resolved.
func (*Resource) ResolveReference ¶
ResolveReference resolves a Reference (JSON Pointer) into a Property.
func (*Resource) UnwrapOneOfProperties ¶
UnwrapOneOfProperties unwraps a set of properties nested in a oneOf element.
type ResourceJsonSchema ¶
type ResourceJsonSchema struct {
// contains filtered or unexported fields
}
ResourceJsonSchema represents the resource schema.
func NewResourceJsonSchemaDocument ¶
func NewResourceJsonSchemaDocument(document string) (*ResourceJsonSchema, error)
NewResourceJsonSchemaDocument returns a ResourceJsonSchema or any errors from the provided document.
func NewResourceJsonSchemaPath ¶
func NewResourceJsonSchemaPath(path string) (*ResourceJsonSchema, error)
NewResourceJsonSchemaPath returns a ResourceJsonSchema or any errors from the provided document at the file path.
func (*ResourceJsonSchema) Resource ¶
func (s *ResourceJsonSchema) Resource() (*Resource, error)
Resource parses the JSON Schema and returns Resource or an error.
func (*ResourceJsonSchema) ValidateConfigurationDocument ¶
func (s *ResourceJsonSchema) ValidateConfigurationDocument(document string) error
ValidateConfigurationDocument validates the provided document against the resource schema.
func (*ResourceJsonSchema) ValidateConfigurationPath ¶
func (s *ResourceJsonSchema) ValidateConfigurationPath(path string) error
ValidateConfigurationPath validates the provided document at the file path against the resource schema.
type ResourceLink ¶
Source Files
¶
- doc.go
- handler.go
- handler_schema.go
- json_schema.go
- meta_json_schema.go
- property.go
- property_json_pointer.go
- property_json_pointers.go
- property_relationship_ref.go
- property_subschema.go
- property_transform.go
- reference.go
- replacement_strategy.go
- resource.go
- resource_expand.go
- resource_json_schema.go
- resource_link.go
- sanitize.go
- tagging.go
- type.go