go.ligato.io/vpp-agent/v3@v3.5.0/client/client_api.go (about) 1 // Copyright (c) 2019 Cisco and/or its affiliates. 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 client 16 17 import ( 18 "context" 19 20 "google.golang.org/protobuf/proto" 21 22 "go.ligato.io/vpp-agent/v3/pkg/models" 23 "go.ligato.io/vpp-agent/v3/proto/ligato/generic" 24 ) 25 26 // ModelInfo is just retyped models.ModelInfo for backward compatibility purpose 27 // Deprecated: use models.ModelInfo instead 28 type ModelInfo = models.ModelInfo 29 30 type StateItem = generic.StateItem 31 type ConfigItem = generic.ConfigItem 32 33 type UpdateItem struct { 34 Message proto.Message 35 Labels map[string]string 36 } 37 38 type UpdateResult struct { 39 Key string 40 Status *generic.ItemStatus 41 } 42 43 // If (Ids|Labels) is nil that means no filtering for (Ids|Labels) 44 // But if both are not nil then an error is returned 45 // (because of ambiguity in what should the result be filtered by). 46 // If for a given label key the corresponding value is "" then items are 47 // only matched using the key. 48 type Filter struct { 49 Ids []*generic.Item_ID 50 Labels map[string]string 51 } 52 53 // ConfigClient ... 54 // Deprecated: use GenericClient instead 55 type ConfigClient = GenericClient 56 57 // GenericClient is the client-side interface for generic handler. 58 type GenericClient interface { 59 // KnownModels retrieves list of known modules. 60 KnownModels(class string) ([]*ModelInfo, error) 61 62 // ChangeRequest returns transaction for changing config. 63 ChangeRequest() ChangeRequest 64 65 // ResyncConfig overwrites existing config. 66 ResyncConfig(items ...proto.Message) error 67 68 // GetConfig retrieves current config into dsts. 69 // TODO: return as list of config items 70 GetConfig(dsts ...interface{}) error 71 72 // GetFilteredConfig retrieves current config into dsts according to the provided filter. 73 GetFilteredConfig(filter Filter, dsts ...interface{}) error 74 75 // GetItems returns list of all current ConfigItems. 76 GetItems(ctx context.Context) ([]*ConfigItem, error) 77 78 UpdateItems(ctx context.Context, items []UpdateItem, resync bool) ([]*UpdateResult, error) 79 80 DeleteItems(ctx context.Context, items []UpdateItem) ([]*UpdateResult, error) 81 82 // DumpState dumps actual running state. 83 DumpState() ([]*StateItem, error) 84 } 85 86 // ChangeRequest is interface for config change request. 87 type ChangeRequest interface { 88 // Update appends updates for given items to the request. 89 Update(items ...proto.Message) ChangeRequest 90 91 // Delete appends deletes for given items to the request. 92 Delete(items ...proto.Message) ChangeRequest 93 94 // Send sends the request. 95 Send(ctx context.Context) error 96 }