-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopencti_vocabulary.go
96 lines (74 loc) · 2.86 KB
/
opencti_vocabulary.go
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
// Code generated by '/tools/gocti_type_generator' for OpenCTI version 6.5.2 - DO NOT EDIT.
package entity
import (
"fmt"
"time"
"github.com/weisshorn-cyd/gocti/graphql"
_ "embed"
)
type Vocabulary struct {
graphql.Vocabulary `gocti:",squash"`
}
//go:embed default_properties/vocabulary_default_properties.txt
var vocabularyDefaultProperties string
func (v Vocabulary) DefaultProperties() string {
return vocabularyDefaultProperties
}
// Implementing the [api.ListableEntity] interface.
//go:embed list_queries/vocabulary_list_query.txt
var vocabularyListQueryString string
func (v Vocabulary) ListQueryString(customAttributes string) string {
return fmt.Sprintf(
vocabularyListQueryString,
customAttributes,
)
}
func (v Vocabulary) ListResponseField() string { return "vocabularies" }
// Implementing the [api.ReadableEntity] interface.
func (v Vocabulary) ReadQueryString(customAttributes string) string {
return fmt.Sprintf(
`query ($id: String!) {
vocabulary (id: $id) {%s}
}`,
customAttributes,
)
}
func (v Vocabulary) ReadResponseField() string { return "vocabulary" }
// Implementing the [api.CreatableEntity] interface.
func (v Vocabulary) CreateQueryString(customAttributes string) string {
return fmt.Sprintf(
`mutation ($input: VocabularyAddInput!) {
vocabularyAdd (input: $input) {%s}
}`,
customAttributes,
)
}
func (v Vocabulary) CreateResponseField() string { return "vocabularyAdd" }
// VocabularyAddInput represents a GraphQL INPUT_OBJECT
// Some fields from the OpenCTI schema may be missing
// (See the examples for ways to expand an existing type).
type VocabularyAddInput struct {
// VocabularyAddInput
StixID string `gocti:"stix_id" json:"stix_id,omitempty"`
XOpenctiStixIDs []string `gocti:"x_opencti_stix_ids" json:"x_opencti_stix_ids,omitempty"`
Name string `gocti:"name" json:"name,omitempty"`
Description string `gocti:"description" json:"description,omitempty"`
Category string `gocti:"category" json:"category,omitempty"`
Order int `gocti:"order" json:"order,omitempty"`
Created *time.Time `gocti:"created" json:"created,omitempty"`
Modified *time.Time `gocti:"modified" json:"modified,omitempty"`
Aliases []string `gocti:"aliases" json:"aliases,omitempty"`
Update bool `gocti:"update" json:"update,omitempty"`
}
func (input VocabularyAddInput) Input() (map[string]any, error) {
return map[string]any{
"input": input,
}, nil
}
// Implementing the [api.DeletableEntity] interface.
func (v Vocabulary) DeleteQueryString() string {
return `mutation ($id: ID!) {
vocabularyDelete (id: $id)
}`
}
func (v Vocabulary) DeleteResponseField() string { return "vocabularyDelete" }