package apibuilderspec /** * Generated by API Builder - https://www.apibuilder.io * Service version: 0.16.26 * User agent: apibuilder app.apibuilder.io/apicollective/apibuilder-spec/0.16.26/go_1_5_client */ import ( "bytes" "encoding/json" "io" "strings" ) const UserAgent = "apibuilder app.apibuilder.io/apicollective/apibuilder-spec/0.16.26/go_1_5_client" const Version = "0.16.26" const VersionMajor = 0 type Method string const ( MethodGet Method = "GET" MethodPost = "POST" MethodPut = "PUT" MethodPatch = "PATCH" MethodDelete = "DELETE" MethodHead = "HEAD" MethodConnect = "CONNECT" MethodOptions = "OPTIONS" MethodTrace = "TRACE" MethodUNDEFINED = "UNDEFINED" ) func MethodFromString(value string) Method { switch strings.TrimSpace(strings.ToLower(value)) { case "get": return MethodGet case "post": return MethodPost case "put": return MethodPut case "patch": return MethodPatch case "delete": return MethodDelete case "head": return MethodHead case "connect": return MethodConnect case "options": return MethodOptions case "trace": return MethodTrace default: return MethodUNDEFINED } } type ParameterLocation string const ( ParameterLocationPath ParameterLocation = "Path" ParameterLocationQuery = "Query" ParameterLocationForm = "Form" ParameterLocationHeader = "Header" ParameterLocationUNDEFINED = "UNDEFINED" ) func ParameterLocationFromString(value string) ParameterLocation { switch strings.TrimSpace(strings.ToLower(value)) { case "path": return ParameterLocationPath case "query": return ParameterLocationQuery case "form": return ParameterLocationForm case "header": return ParameterLocationHeader default: return ParameterLocationUNDEFINED } } type ResponseCodeOption string const ( ResponseCodeOptionDefault ResponseCodeOption = "Default" ResponseCodeOptionUNDEFINED = "UNDEFINED" ) func ResponseCodeOptionFromString(value string) ResponseCodeOption { switch strings.TrimSpace(strings.ToLower(value)) { case "default": return ResponseCodeOptionDefault default: return ResponseCodeOptionUNDEFINED } } /** * Used to indicate an API concern for a field that is specific to the field's * usage but not necessarily its data type. For example, you might use annotations * to mark that certain fields contain PII or PCI data and thus should not be * stored once processing is complete. Annotations communicate meaning to consumers * of an API and may also be used within an implementation or tooling; for example, * using static analysis tools to detect logging of sensitive data. */ type Annotation struct { Name string `json:"name"` Description string `json:"description,omitempty"` Deprecation Deprecation `json:"deprecation,omitempty"` } func AnnotationFromMap(data interface{}) Annotation { b, err := json.Marshal(data) if err == nil { return AnnotationFromJson(bytes.NewReader(b)) } else { panic(err) } } func AnnotationFromJson(bytes io.Reader) Annotation { var annotation Annotation json.NewDecoder(bytes).Decode(&annotation) return annotation } type Apidoc struct { Version string `json:"version"` } func ApidocFromMap(data interface{}) Apidoc { b, err := json.Marshal(data) if err == nil { return ApidocFromJson(bytes.NewReader(b)) } else { panic(err) } } func ApidocFromJson(bytes io.Reader) Apidoc { var apidoc Apidoc json.NewDecoder(bytes).Decode(&apidoc) return apidoc } type Application struct { Key string `json:"key"` } func ApplicationFromMap(data interface{}) Application { b, err := json.Marshal(data) if err == nil { return ApplicationFromJson(bytes.NewReader(b)) } else { panic(err) } } func ApplicationFromJson(bytes io.Reader) Application { var application Application json.NewDecoder(bytes).Decode(&application) return application } /** * Represents an additional attribute that is attached to one of the objects in * apibuilder. The main use case is to capture additional metadata that doesn't * necessarily define the API but aids in code generation. Examples would be hints * for certain code generators about classes to extend, interfaces to implement, * annotations to add, names to assign to certain methods, etc. The specific * attributes will be applicable only in the context of the specific code * generators usings them. */ type Attribute struct { Name string `json:"name"` Value map[string]interface{} `json:"value"` Description string `json:"description,omitempty"` Deprecation Deprecation `json:"deprecation,omitempty"` } func AttributeFromMap(data interface{}) Attribute { b, err := json.Marshal(data) if err == nil { return AttributeFromJson(bytes.NewReader(b)) } else { panic(err) } } func AttributeFromJson(bytes io.Reader) Attribute { var attribute Attribute json.NewDecoder(bytes).Decode(&attribute) return attribute } type Body struct { Type string `json:"type"` Description string `json:"description,omitempty"` Deprecation Deprecation `json:"deprecation,omitempty"` Attributes []Attribute `json:"attributes"` } func BodyFromMap(data interface{}) Body { b, err := json.Marshal(data) if err == nil { return BodyFromJson(bytes.NewReader(b)) } else { panic(err) } } func BodyFromJson(bytes io.Reader) Body { var body Body json.NewDecoder(bytes).Decode(&body) return body } /** * Describes the primary contact for this service */ type Contact struct { Name string `json:"name,omitempty"` Url string `json:"url,omitempty"` Email string `json:"email,omitempty"` } func ContactFromMap(data interface{}) Contact { b, err := json.Marshal(data) if err == nil { return ContactFromJson(bytes.NewReader(b)) } else { panic(err) } } func ContactFromJson(bytes io.Reader) Contact { var contact Contact json.NewDecoder(bytes).Decode(&contact) return contact } /** * Indicates that this particular element is considered deprecated in the API. See * the description for details */ type Deprecation struct { Description string `json:"description,omitempty"` } func DeprecationFromMap(data interface{}) Deprecation { b, err := json.Marshal(data) if err == nil { return DeprecationFromJson(bytes.NewReader(b)) } else { panic(err) } } func DeprecationFromJson(bytes io.Reader) Deprecation { var deprecation Deprecation json.NewDecoder(bytes).Decode(&deprecation) return deprecation } type Enum struct { Name string `json:"name"` Plural string `json:"plural"` Description string `json:"description,omitempty"` Deprecation Deprecation `json:"deprecation,omitempty"` Values []EnumValue `json:"values"` Attributes []Attribute `json:"attributes"` } func EnumFromMap(data interface{}) Enum { b, err := json.Marshal(data) if err == nil { return EnumFromJson(bytes.NewReader(b)) } else { panic(err) } } func EnumFromJson(bytes io.Reader) Enum { var enum Enum json.NewDecoder(bytes).Decode(&enum) return enum } type EnumValue struct { Name string `json:"name"` Description string `json:"description,omitempty"` Deprecation Deprecation `json:"deprecation,omitempty"` Attributes []Attribute `json:"attributes"` Value string `json:"value,omitempty"` } func EnumValueFromMap(data interface{}) EnumValue { b, err := json.Marshal(data) if err == nil { return EnumValueFromJson(bytes.NewReader(b)) } else { panic(err) } } func EnumValueFromJson(bytes io.Reader) EnumValue { var enumValue EnumValue json.NewDecoder(bytes).Decode(&enumValue) return enumValue } type Field struct { Name string `json:"name"` Type string `json:"type"` Description string `json:"description,omitempty"` Deprecation Deprecation `json:"deprecation,omitempty"` Default string `json:"default,omitempty"` Required string `json:"required"` Minimum int64 `json:"minimum,omitempty"` Maximum int64 `json:"maximum,omitempty"` Example string `json:"example,omitempty"` Attributes []Attribute `json:"attributes"` Annotations []string `json:"annotations,omitempty"` } func FieldFromMap(data interface{}) Field { b, err := json.Marshal(data) if err == nil { return FieldFromJson(bytes.NewReader(b)) } else { panic(err) } } func FieldFromJson(bytes io.Reader) Field { var field Field json.NewDecoder(bytes).Decode(&field) return field } type Header struct { Name string `json:"name"` Type string `json:"type"` Description string `json:"description,omitempty"` Deprecation Deprecation `json:"deprecation,omitempty"` Required string `json:"required"` Default string `json:"default,omitempty"` Attributes []Attribute `json:"attributes"` } func HeaderFromMap(data interface{}) Header { b, err := json.Marshal(data) if err == nil { return HeaderFromJson(bytes.NewReader(b)) } else { panic(err) } } func HeaderFromJson(bytes io.Reader) Header { var header Header json.NewDecoder(bytes).Decode(&header) return header } /** * An import is used to declare a dependency on another application. This allows * you to reference the models and or enums from that application in your own app. */ type Import struct { Uri string `json:"uri"` Namespace string `json:"namespace"` Organization Organization `json:"organization"` Application Application `json:"application"` Version string `json:"version"` Enums []string `json:"enums"` Interfaces []string `json:"interfaces,omitempty"` Unions []string `json:"unions"` Models []string `json:"models"` Annotations []Annotation `json:"annotations,omitempty"` } func ImportFromMap(data interface{}) Import { b, err := json.Marshal(data) if err == nil { return ImportFromJson(bytes.NewReader(b)) } else { panic(err) } } func ImportFromJson(bytes io.Reader) Import { var import_ Import json.NewDecoder(bytes).Decode(&import_) return import_ } /** * General metadata about this service */ type Info struct { License License `json:"license,omitempty"` Contact Contact `json:"contact,omitempty"` } func InfoFromMap(data interface{}) Info { b, err := json.Marshal(data) if err == nil { return InfoFromJson(bytes.NewReader(b)) } else { panic(err) } } func InfoFromJson(bytes io.Reader) Info { var info Info json.NewDecoder(bytes).Decode(&info) return info } type Interface struct { Name string `json:"name"` Plural string `json:"plural"` Description string `json:"description,omitempty"` Deprecation Deprecation `json:"deprecation,omitempty"` Fields []Field `json:"fields"` Attributes []Attribute `json:"attributes"` } func InterfaceFromMap(data interface{}) Interface { b, err := json.Marshal(data) if err == nil { return InterfaceFromJson(bytes.NewReader(b)) } else { panic(err) } } func InterfaceFromJson(bytes io.Reader) Interface { var interface_ Interface json.NewDecoder(bytes).Decode(&interface_) return interface_ } /** * Describes the software license contact for this service */ type License struct { Name string `json:"name"` Url string `json:"url,omitempty"` } func LicenseFromMap(data interface{}) License { b, err := json.Marshal(data) if err == nil { return LicenseFromJson(bytes.NewReader(b)) } else { panic(err) } } func LicenseFromJson(bytes io.Reader) License { var license License json.NewDecoder(bytes).Decode(&license) return license } type Model struct { Name string `json:"name"` Plural string `json:"plural"` Description string `json:"description,omitempty"` Deprecation Deprecation `json:"deprecation,omitempty"` Fields []Field `json:"fields"` Attributes []Attribute `json:"attributes"` Interfaces []string `json:"interfaces,omitempty"` } func ModelFromMap(data interface{}) Model { b, err := json.Marshal(data) if err == nil { return ModelFromJson(bytes.NewReader(b)) } else { panic(err) } } func ModelFromJson(bytes io.Reader) Model { var model Model json.NewDecoder(bytes).Decode(&model) return model } type Operation struct { Method Method `json:"method"` Path string `json:"path"` Description string `json:"description,omitempty"` Deprecation Deprecation `json:"deprecation,omitempty"` Body Body `json:"body,omitempty"` Parameters []Parameter `json:"parameters"` Responses []Response `json:"responses"` Attributes []Attribute `json:"attributes"` } func OperationFromMap(data interface{}) Operation { b, err := json.Marshal(data) if err == nil { return OperationFromJson(bytes.NewReader(b)) } else { panic(err) } } func OperationFromJson(bytes io.Reader) Operation { var operation Operation json.NewDecoder(bytes).Decode(&operation) return operation } type Organization struct { Key string `json:"key"` } func OrganizationFromMap(data interface{}) Organization { b, err := json.Marshal(data) if err == nil { return OrganizationFromJson(bytes.NewReader(b)) } else { panic(err) } } func OrganizationFromJson(bytes io.Reader) Organization { var organization Organization json.NewDecoder(bytes).Decode(&organization) return organization } type Parameter struct { Name string `json:"name"` Type string `json:"type"` Location ParameterLocation `json:"location"` Description string `json:"description,omitempty"` Deprecation Deprecation `json:"deprecation,omitempty"` Required string `json:"required"` Default string `json:"default,omitempty"` Minimum int64 `json:"minimum,omitempty"` Maximum int64 `json:"maximum,omitempty"` Example string `json:"example,omitempty"` Attributes []Attribute `json:"attributes,omitempty"` } func ParameterFromMap(data interface{}) Parameter { b, err := json.Marshal(data) if err == nil { return ParameterFromJson(bytes.NewReader(b)) } else { panic(err) } } func ParameterFromJson(bytes io.Reader) Parameter { var parameter Parameter json.NewDecoder(bytes).Decode(¶meter) return parameter } type Resource struct { Type string `json:"type"` Plural string `json:"plural"` Path string `json:"path,omitempty"` Description string `json:"description,omitempty"` Deprecation Deprecation `json:"deprecation,omitempty"` Operations []Operation `json:"operations"` Attributes []Attribute `json:"attributes"` } func ResourceFromMap(data interface{}) Resource { b, err := json.Marshal(data) if err == nil { return ResourceFromJson(bytes.NewReader(b)) } else { panic(err) } } func ResourceFromJson(bytes io.Reader) Resource { var resource Resource json.NewDecoder(bytes).Decode(&resource) return resource } type Response struct { Code ResponseCode `json:"code"` Type string `json:"type"` Headers []Header `json:"headers,omitempty"` Description string `json:"description,omitempty"` Deprecation Deprecation `json:"deprecation,omitempty"` Attributes []Attribute `json:"attributes,omitempty"` } func ResponseFromMap(data interface{}) Response { b, err := json.Marshal(data) if err == nil { return ResponseFromJson(bytes.NewReader(b)) } else { panic(err) } } func ResponseFromJson(bytes io.Reader) Response { var response Response json.NewDecoder(bytes).Decode(&response) return response } type Service struct { Apidoc Apidoc `json:"apidoc,omitempty"` Name string `json:"name"` Organization Organization `json:"organization"` Application Application `json:"application"` Namespace string `json:"namespace"` Version string `json:"version"` BaseUrl string `json:"base_url,omitempty"` Description string `json:"description,omitempty"` Info Info `json:"info"` Headers []Header `json:"headers"` Imports []Import `json:"imports"` Enums []Enum `json:"enums"` Interfaces []Interface `json:"interfaces,omitempty"` Unions []Union `json:"unions"` Models []Model `json:"models"` Resources []Resource `json:"resources"` Attributes []Attribute `json:"attributes"` Annotations []Annotation `json:"annotations,omitempty"` } func ServiceFromMap(data interface{}) Service { b, err := json.Marshal(data) if err == nil { return ServiceFromJson(bytes.NewReader(b)) } else { panic(err) } } func ServiceFromJson(bytes io.Reader) Service { var service Service json.NewDecoder(bytes).Decode(&service) return service } type Union struct { Name string `json:"name"` Plural string `json:"plural"` Discriminator string `json:"discriminator,omitempty"` Description string `json:"description,omitempty"` Deprecation Deprecation `json:"deprecation,omitempty"` Types []UnionType `json:"types"` Attributes []Attribute `json:"attributes"` Interfaces []string `json:"interfaces,omitempty"` } func UnionFromMap(data interface{}) Union { b, err := json.Marshal(data) if err == nil { return UnionFromJson(bytes.NewReader(b)) } else { panic(err) } } func UnionFromJson(bytes io.Reader) Union { var union Union json.NewDecoder(bytes).Decode(&union) return union } /** * Metadata about one of the types that is part of a union type */ type UnionType struct { Type string `json:"type"` Description string `json:"description,omitempty"` Deprecation Deprecation `json:"deprecation,omitempty"` Attributes []Attribute `json:"attributes"` Default string `json:"default,omitempty"` DiscriminatorValue string `json:"discriminator_value,omitempty"` } func UnionTypeFromMap(data interface{}) UnionType { b, err := json.Marshal(data) if err == nil { return UnionTypeFromJson(bytes.NewReader(b)) } else { panic(err) } } func UnionTypeFromJson(bytes io.Reader) UnionType { var unionType UnionType json.NewDecoder(bytes).Decode(&unionType) return unionType } type ResponseCode struct { Integer int32 ResponseCodeOption ResponseCodeOption Undefined string } func ResponseCodeFromMap(data interface{}) ResponseCode { b, err := json.Marshal(data) if err == nil { return ResponseCodeFromJson(bytes.NewReader(b)) } else { panic(err) } } func ResponseCodeFromJson(bytes io.Reader) ResponseCode { // TODO: Not yet supported }