yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/google/regionstorage.go (about) 1 // Copyright 2019 Yunion 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 google 16 17 import ( 18 "fmt" 19 "time" 20 ) 21 22 type SRegionStorage struct { 23 region *SRegion 24 25 CreationTimestamp time.Time 26 Name string 27 Description string 28 ValidDiskSize string 29 Zone string 30 SelfLink string 31 DefaultDiskSizeGb string 32 Kind string 33 } 34 35 func (region *SRegion) GetRegionStorages(maxResults int, pageToken string) ([]SRegionStorage, error) { 36 storages := []SRegionStorage{} 37 resource := fmt.Sprintf("regions/%s/diskTypes", region.Name) 38 params := map[string]string{} 39 return storages, region.List(resource, params, maxResults, pageToken, &storages) 40 } 41 42 func (region *SRegion) GetRegionStorage(id string) (*SRegionStorage, error) { 43 storage := &SRegionStorage{region: region} 44 return storage, region.GetBySelfId(id, storage) 45 }