github.com/sacloud/iaas-api-go@v1.12.0/internal/define/conditions.go (about) 1 // Copyright 2022-2023 The sacloud/iaas-api-go Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package define 16 17 import ( 18 "github.com/sacloud/iaas-api-go/internal/dsl" 19 "github.com/sacloud/iaas-api-go/internal/dsl/meta" 20 "github.com/sacloud/iaas-api-go/search" 21 ) 22 23 var monitorParameter = &dsl.Model{ 24 Name: "MonitorCondition", 25 Fields: []*dsl.FieldDesc{ 26 { 27 Name: "Start", 28 Type: meta.TypeTime, 29 Tags: &dsl.FieldTags{ 30 JSON: ",omitempty", 31 }, 32 DefaultValue: `time.Now().Truncate(time.Second).Add(-time.Hour)`, 33 }, 34 { 35 Name: "End", 36 Type: meta.TypeTime, 37 Tags: &dsl.FieldTags{ 38 JSON: ",omitempty", 39 }, 40 DefaultValue: `time.Now().Truncate(time.Second)`, 41 }, 42 }, 43 } 44 45 var findParameter = &dsl.Model{ 46 Name: "FindCondition", 47 Fields: []*dsl.FieldDesc{ 48 conditions.Count(), 49 conditions.From(), 50 conditions.Sort(), 51 conditions.Filter(), 52 conditions.Include(), 53 conditions.Exclude(), 54 }, 55 Methods: []*dsl.MethodDesc{ 56 { 57 Name: "ClearFilter", 58 Description: "フィルタのクリア", 59 }, 60 }, 61 } 62 63 type findCondtionsDef struct{} 64 65 var conditions = &findCondtionsDef{} 66 67 func (f *findCondtionsDef) From() *dsl.FieldDesc { 68 return &dsl.FieldDesc{ 69 Name: "From", 70 Type: meta.Static(int(0)), 71 Tags: &dsl.FieldTags{ 72 MapConv: ",omitempty", 73 }, 74 } 75 } 76 77 func (f *findCondtionsDef) Count() *dsl.FieldDesc { 78 return &dsl.FieldDesc{ 79 Name: "Count", 80 Type: meta.Static(int(0)), 81 Tags: &dsl.FieldTags{ 82 MapConv: ",omitempty", 83 }, 84 } 85 } 86 87 func (f *findCondtionsDef) Sort() *dsl.FieldDesc { 88 return &dsl.FieldDesc{ 89 Name: "Sort", 90 Type: meta.Static(search.SortKeys{}), 91 Tags: &dsl.FieldTags{ 92 MapConv: ",omitempty", 93 JSON: ",omitempty", 94 }, 95 } 96 } 97 98 func (f *findCondtionsDef) Filter() *dsl.FieldDesc { 99 return &dsl.FieldDesc{ 100 Name: "Filter", 101 Type: meta.Static(search.Filter{}), 102 Tags: &dsl.FieldTags{ 103 MapConv: ",omitempty", 104 JSON: ",omitempty", 105 }, 106 } 107 } 108 109 func (f *findCondtionsDef) Include() *dsl.FieldDesc { 110 return &dsl.FieldDesc{ 111 Name: "Include", 112 Type: meta.Static([]string{}), 113 Tags: &dsl.FieldTags{ 114 MapConv: ",omitempty", 115 JSON: ",omitempty", 116 }, 117 } 118 } 119 120 func (f *findCondtionsDef) Exclude() *dsl.FieldDesc { 121 return &dsl.FieldDesc{ 122 Name: "Exclude", 123 Type: meta.Static([]string{}), 124 Tags: &dsl.FieldTags{ 125 MapConv: ",omitempty", 126 JSON: ",omitempty", 127 }, 128 } 129 }