// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.

package graphql

import (
	"fmt"
	"io"
	"strconv"
)

type AttributeFilterInput struct {
	Path string      `json:"path"`
	Rule *FilterRule `json:"rule"`
	// If not provided, any revision of the Attribute applies to this filter
	Revision *string `json:"revision"`
}

type AttributeReference struct {
	Path     string `json:"path"`
	Revision string `json:"revision"`
}

type AttributeReferenceInput struct {
	Path     string `json:"path"`
	Revision string `json:"revision"`
}

type CreateTypeInstanceInput struct {
	// Used to define the relationships, between the created TypeInstances
	Alias      *string                         `json:"alias"`
	CreatedBy  *string                         `json:"createdBy"`
	TypeRef    *TypeInstanceTypeReferenceInput `json:"typeRef"`
	Attributes []*AttributeReferenceInput      `json:"attributes"`
	Value      interface{}                     `json:"value"`
	// If not provided, TypeInstance value is stored as static value in Local Hub core storage.
	Backend *TypeInstanceBackendInput `json:"backend"`
}

type CreateTypeInstanceOutput struct {
	ID    string `json:"id"`
	Alias string `json:"alias"`
}

type CreateTypeInstancesInput struct {
	TypeInstances []*CreateTypeInstanceInput       `json:"typeInstances"`
	UsesRelations []*TypeInstanceUsesRelationInput `json:"usesRelations"`
}

type LockTypeInstancesInput struct {
	Ids     []string `json:"ids"`
	OwnerID string   `json:"ownerID"`
}

type TypeInstance struct {
	ID        string  `json:"id"`
	CreatedAt *string `json:"createdAt"`
	LockedBy  *string `json:"lockedBy"`
	// Common properties for all TypeInstances which cannot be changed
	TypeRef *TypeInstanceTypeReference `json:"typeRef"`
	// Returns TypeInstances that are used. List is sorted by TypeInstance's TypeRef path in ascending order, and then by revision in descending order (newest revision are first).
	// If both TypeRef path and revision are same, then it's additionally sorted by TypeInstance createdAt field (newly created are first).
	Uses []*TypeInstance `json:"uses"`
	// Returns TypeInstances that uses this TypeInstance. List is sorted by TypeInstance's TypeRef path in ascending order, and then by revision in descending order (newest revision are first).
	// If both TypeRef path and revision are same, then it's additionally sorted by TypeInstance createdAt field (newly created are first).
	UsedBy                  []*TypeInstance                `json:"usedBy"`
	Backend                 *TypeInstanceBackendReference  `json:"backend"`
	LatestResourceVersion   *TypeInstanceResourceVersion   `json:"latestResourceVersion"`
	FirstResourceVersion    *TypeInstanceResourceVersion   `json:"firstResourceVersion"`
	PreviousResourceVersion *TypeInstanceResourceVersion   `json:"previousResourceVersion"`
	ResourceVersion         *TypeInstanceResourceVersion   `json:"resourceVersion"`
	ResourceVersions        []*TypeInstanceResourceVersion `json:"resourceVersions"`
}

type TypeInstanceBackendInput struct {
	ID      string      `json:"id"`
	Context interface{} `json:"context"`
}

type TypeInstanceBackendReference struct {
	ID       string `json:"id"`
	Abstract bool   `json:"abstract"`
}

type TypeInstanceFilter struct {
	Attributes []*AttributeFilterInput `json:"attributes"`
	TypeRef    *TypeRefFilterInput     `json:"typeRef"`
	CreatedBy  *string                 `json:"createdBy"`
}

// CURRENTLY NOT IMPLEMENTED
type TypeInstanceInstrumentation struct {
	Metrics *TypeInstanceInstrumentationMetrics `json:"metrics"`
	Health  *TypeInstanceInstrumentationHealth  `json:"health"`
}

// CURRENTLY NOT IMPLEMENTED
type TypeInstanceInstrumentationHealth struct {
	URL    *string                                  `json:"url"`
	Method *HTTPRequestMethod                       `json:"method"`
	Status *TypeInstanceInstrumentationHealthStatus `json:"status"`
}

// CURRENTLY NOT IMPLEMENTED
type TypeInstanceInstrumentationMetrics struct {
	Endpoint   *string                                        `json:"endpoint"`
	Regex      *string                                        `json:"regex"`
	Dashboards []*TypeInstanceInstrumentationMetricsDashboard `json:"dashboards"`
}

// CURRENTLY NOT IMPLEMENTED
type TypeInstanceInstrumentationMetricsDashboard struct {
	URL string `json:"url"`
}

type TypeInstanceResourceVersion struct {
	ResourceVersion int                                  `json:"resourceVersion"`
	CreatedBy       *string                              `json:"createdBy"`
	Metadata        *TypeInstanceResourceVersionMetadata `json:"metadata"`
	Spec            *TypeInstanceResourceVersionSpec     `json:"spec"`
}

type TypeInstanceResourceVersionMetadata struct {
	Attributes []*AttributeReference `json:"attributes"`
}

type TypeInstanceResourceVersionSpec struct {
	Value   interface{}                             `json:"value"`
	Backend *TypeInstanceResourceVersionSpecBackend `json:"backend"`
	// CURRENTLY NOT IMPLEMENTED
	Instrumentation *TypeInstanceInstrumentation `json:"instrumentation"`
}

type TypeInstanceResourceVersionSpecBackend struct {
	Context interface{} `json:"context"`
}

type TypeInstanceTypeReference struct {
	Path     string `json:"path"`
	Revision string `json:"revision"`
}

type TypeInstanceTypeReferenceInput struct {
	Path     string `json:"path"`
	Revision string `json:"revision"`
}

type TypeInstanceUsesRelationInput struct {
	// Can be existing TypeInstance ID or alias of a TypeInstance from typeInstances list
	From string `json:"from"`
	// Can be existing TypeInstance ID or alias of a TypeInstance from typeInstances list
	To string `json:"to"`
}

type TypeRefFilterInput struct {
	Path string `json:"path"`
	// If not provided, it returns TypeInstances for all revisions of given Type
	Revision *string `json:"revision"`
}

type UnlockTypeInstancesInput struct {
	Ids     []string `json:"ids"`
	OwnerID string   `json:"ownerID"`
}

type UpdateTypeInstanceBackendInput struct {
	Context interface{} `json:"context"`
}

type FilterRule string

const (
	FilterRuleInclude FilterRule = "INCLUDE"
	FilterRuleExclude FilterRule = "EXCLUDE"
)

var AllFilterRule = []FilterRule{
	FilterRuleInclude,
	FilterRuleExclude,
}

func (e FilterRule) IsValid() bool {
	switch e {
	case FilterRuleInclude, FilterRuleExclude:
		return true
	}
	return false
}

func (e FilterRule) String() string {
	return string(e)
}

func (e *FilterRule) UnmarshalGQL(v interface{}) error {
	str, ok := v.(string)
	if !ok {
		return fmt.Errorf("enums must be strings")
	}

	*e = FilterRule(str)
	if !e.IsValid() {
		return fmt.Errorf("%s is not a valid FilterRule", str)
	}
	return nil
}

func (e FilterRule) MarshalGQL(w io.Writer) {
	fmt.Fprint(w, strconv.Quote(e.String()))
}

type HTTPRequestMethod string

const (
	HTTPRequestMethodGet  HTTPRequestMethod = "GET"
	HTTPRequestMethodPost HTTPRequestMethod = "POST"
)

var AllHTTPRequestMethod = []HTTPRequestMethod{
	HTTPRequestMethodGet,
	HTTPRequestMethodPost,
}

func (e HTTPRequestMethod) IsValid() bool {
	switch e {
	case HTTPRequestMethodGet, HTTPRequestMethodPost:
		return true
	}
	return false
}

func (e HTTPRequestMethod) String() string {
	return string(e)
}

func (e *HTTPRequestMethod) UnmarshalGQL(v interface{}) error {
	str, ok := v.(string)
	if !ok {
		return fmt.Errorf("enums must be strings")
	}

	*e = HTTPRequestMethod(str)
	if !e.IsValid() {
		return fmt.Errorf("%s is not a valid HTTPRequestMethod", str)
	}
	return nil
}

func (e HTTPRequestMethod) MarshalGQL(w io.Writer) {
	fmt.Fprint(w, strconv.Quote(e.String()))
}

// CURRENTLY NOT IMPLEMENTED
type TypeInstanceInstrumentationHealthStatus string

const (
	TypeInstanceInstrumentationHealthStatusUnknown TypeInstanceInstrumentationHealthStatus = "UNKNOWN"
	TypeInstanceInstrumentationHealthStatusReady   TypeInstanceInstrumentationHealthStatus = "READY"
	TypeInstanceInstrumentationHealthStatusFailing TypeInstanceInstrumentationHealthStatus = "FAILING"
)

var AllTypeInstanceInstrumentationHealthStatus = []TypeInstanceInstrumentationHealthStatus{
	TypeInstanceInstrumentationHealthStatusUnknown,
	TypeInstanceInstrumentationHealthStatusReady,
	TypeInstanceInstrumentationHealthStatusFailing,
}

func (e TypeInstanceInstrumentationHealthStatus) IsValid() bool {
	switch e {
	case TypeInstanceInstrumentationHealthStatusUnknown, TypeInstanceInstrumentationHealthStatusReady, TypeInstanceInstrumentationHealthStatusFailing:
		return true
	}
	return false
}

func (e TypeInstanceInstrumentationHealthStatus) String() string {
	return string(e)
}

func (e *TypeInstanceInstrumentationHealthStatus) UnmarshalGQL(v interface{}) error {
	str, ok := v.(string)
	if !ok {
		return fmt.Errorf("enums must be strings")
	}

	*e = TypeInstanceInstrumentationHealthStatus(str)
	if !e.IsValid() {
		return fmt.Errorf("%s is not a valid TypeInstanceInstrumentationHealthStatus", str)
	}
	return nil
}

func (e TypeInstanceInstrumentationHealthStatus) MarshalGQL(w io.Writer) {
	fmt.Fprint(w, strconv.Quote(e.String()))
}
