github.com/sacloud/libsacloud/v2@v2.32.3/helper/service/localrouter/create_request.go (about) 1 // Copyright 2016-2022 The Libsacloud 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 localrouter 16 17 import ( 18 "github.com/sacloud/libsacloud/v2/helper/validate" 19 "github.com/sacloud/libsacloud/v2/sacloud" 20 "github.com/sacloud/libsacloud/v2/sacloud/types" 21 ) 22 23 type CreateRequest struct { 24 Name string `validate:"required"` 25 Description string `validate:"min=0,max=512"` 26 Tags types.Tags 27 IconID types.ID 28 Switch *sacloud.LocalRouterSwitch `request:",omitempty" validate:"required_with=Interface"` 29 Interface *sacloud.LocalRouterInterface `request:",omitempty" validate:"required_with=Switch"` 30 Peers []*sacloud.LocalRouterPeer 31 StaticRoutes []*sacloud.LocalRouterStaticRoute 32 } 33 34 func (req *CreateRequest) Validate() error { 35 return validate.Struct(req) 36 } 37 38 func (req *CreateRequest) Builder(caller sacloud.APICaller) *Builder { 39 return &Builder{ 40 Name: req.Name, 41 Description: req.Description, 42 Tags: req.Tags, 43 IconID: req.IconID, 44 Switch: req.Switch, 45 Interface: req.Interface, 46 Peers: req.Peers, 47 StaticRoutes: req.StaticRoutes, 48 SettingsHash: "", 49 Caller: caller, 50 } 51 }