1 // Copyright 2022-2025 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 search
16 17 import "fmt"
18 19 // FilterKey 検索条件(Filter)のキー
20 type FilterKey struct {
21 // フィールド名
22 Field string
23 // 演算子
24 Op ComparisonOperator
25 }
26 27 // String Keyの文字列表現
28 func (k *FilterKey) String() string {
29 return fmt.Sprintf("%s%s", k.Field, k.Op)
30 }
31 32 // Key キーの作成
33 func Key(field string) FilterKey {
34 return FilterKey{Field: field}
35 }
36 37 // KeyWithOp 演算子を指定してキーを作成
38 func KeyWithOp(field string, op ComparisonOperator) FilterKey {
39 return FilterKey{Field: field, Op: op}
40 }
41