forked from linuxfoundation/lfx-v2-query-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
125 lines (110 loc) · 4.05 KB
/
types.go
File metadata and controls
125 lines (110 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// Copyright The Linux Foundation and each contributor to LFX.
// SPDX-License-Identifier: MIT
package design
import (
"goa.design/goa/v3/dsl"
)
var SortValues = []any{
"name_asc",
"name_desc",
// Note, "created_at" sorting is not currently possible, because we only
// include it on the "created" trasaction, to better distinguish it from an
// "updated" transaction. Adding it would slow down the indexing service
// (perhaps it could be asyncronously added by the janitor?) since
// propogating attributes from earlier revisions is not currently supported.
"updated_asc",
"updated_desc",
}
var Sortable = dsl.Type("Sortable", func() {
dsl.Attribute("sort", dsl.String, "Sort order for results", func() {
dsl.Enum(SortValues...)
dsl.Default("name_asc")
dsl.Example("updated_desc")
})
dsl.Attribute("page_token", dsl.String, "Opaque token for pagination", func() {
dsl.Example("****")
})
})
var Resource = dsl.Type("Resource", func() {
dsl.Description("A resource is a universal representation of an LFX API resource for indexing.")
dsl.Attribute("type", dsl.String, "Resource type", func() {
dsl.Example("committee")
})
dsl.Attribute("id", dsl.String, "Resource ID (within its resource collection)", func() {
dsl.Example("123")
})
dsl.Attribute("data", dsl.Any, "Resource data snapshot", func() {
dsl.Example(CommitteeExampleStub{
ID: "123",
Name: "My committee",
Description: "a committee",
})
})
})
// BadRequestError is the DSL type for a bad request error.
var BadRequestError = dsl.Type("BadRequestError", func() {
dsl.Attribute("message", dsl.String, "Error message", func() {
dsl.Example("The request was invalid.")
})
dsl.Required("message")
})
// NotFoundError is the DSL type for a not found error.
var NotFoundError = dsl.Type("NotFoundError", func() {
dsl.Attribute("message", dsl.String, "Error message", func() {
dsl.Example("The requested resource was not found.")
})
dsl.Required("message")
})
// InternalServerError is the DSL type for an internal server error.
var InternalServerError = dsl.Type("InternalServerError", func() {
dsl.Attribute("message", dsl.String, "Error message", func() {
dsl.Example("An internal server error occurred.")
})
dsl.Required("message")
})
// ServiceUnavailableError is the DSL type for a service unavailable error.
var ServiceUnavailableError = dsl.Type("ServiceUnavailableError", func() {
dsl.Attribute("message", dsl.String, "Error message", func() {
dsl.Example("The service is unavailable.")
})
dsl.Required("message")
})
var Organization = dsl.Type("Organization", func() {
dsl.Description("An organization is a universal representation of an LFX API organization.")
dsl.Attribute("name", dsl.String, "Organization name", func() {
dsl.Example("Linux Foundation")
})
dsl.Attribute("domain", dsl.String, "Organization domain", func() {
dsl.Example("linuxfoundation.org")
})
dsl.Attribute("industry", dsl.String, "Organization industry classification", func() {
dsl.Example("Non-Profit")
})
dsl.Attribute("sector", dsl.String, "Business sector classification", func() {
dsl.Example("Technology")
})
dsl.Attribute("employees", dsl.String, "Employee count or range", func() {
dsl.Example("100-499")
})
})
var OrganizationSuggestion = dsl.Type("OrganizationSuggestion", func() {
dsl.Description("An organization suggestion for the search.")
dsl.Attribute("name", dsl.String, "Organization name", func() {
dsl.Example("Linux Foundation")
})
dsl.Attribute("domain", dsl.String, "Organization domain", func() {
dsl.Example("linuxfoundation.org")
})
dsl.Attribute("logo", dsl.String, "Organization logo URL", func() {
dsl.Example("https://example.com/logo.png")
})
dsl.Required("name", "domain")
})
// Define an example cached LFX resource for the nested "data" attribute for
// resource searches. This example happens to be a committee to match the
// example value of "committee" for the "type" attribute of Resource.
type CommitteeExampleStub struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
}