yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/azure/resourcesku.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 azure
    16  
    17  /*
    18  {
    19  	"capabilities":[
    20  		{"name":"MaxResourceVolumeMB","value":"286720"},
    21  		{"name":"OSVhdSizeMB","value":"1047552"},
    22  		{"name":"vCPUs","value":"20"},
    23  		{"name":"MemoryGB","value":"140"},
    24  		{"name":"MaxDataDiskCount","value":"64"},
    25  		{"name":"LowPriorityCapable","value":"True"},
    26  		{"name":"PremiumIO","value":"True"},
    27  		{"name":"EphemeralOSDiskSupported","value":"True"}
    28  	],
    29  	"family":"standardDSv2Family",
    30  	"locations":["CentralUSEUAP"],
    31  	"name":"Standard_DS15_v2",
    32  	"resourceType":"virtualMachines",
    33  	"restrictions":[],
    34  	"size":"DS15_v2",
    35  	"tier":"Standard"
    36  }
    37  */
    38  
    39  type SResourceSkuCapability struct {
    40  	Name  string
    41  	Value string
    42  }
    43  
    44  type TResourceSkuCapacityScaleType string
    45  
    46  const (
    47  	ResourceSkuCapacityScaleTypeAutomatic = TResourceSkuCapacityScaleType("Automatic")
    48  	ResourceSkuCapacityScaleTypeManual    = TResourceSkuCapacityScaleType("Manual")
    49  	ResourceSkuCapacityScaleTypeNone      = TResourceSkuCapacityScaleType("None")
    50  )
    51  
    52  type SResourceSkuCapacity struct {
    53  	Default   int
    54  	Maximum   int
    55  	Minimum   int
    56  	ScaleType TResourceSkuCapacityScaleType
    57  }
    58  
    59  type SResourceSkuLocationInfo struct {
    60  	Location string
    61  	Zones    []string
    62  }
    63  
    64  type TResourceSkuRestrictionsType string
    65  
    66  const (
    67  	ResourceSkuRestrictionsTypeLocation = TResourceSkuRestrictionsType("Location")
    68  	ResourceSkuRestrictionsTypeZone     = TResourceSkuRestrictionsType("Zone")
    69  )
    70  
    71  type TResourceSkuRestrictionsReasonCode string
    72  
    73  const (
    74  	ResourceSkuRestrictionsReasonCodeNotAvailable = TResourceSkuRestrictionsReasonCode("NotAvailableForSubscription")
    75  	ResourceSkuRestrictionsReasonCodeQuotaId      = TResourceSkuRestrictionsReasonCode("QuotaId")
    76  )
    77  
    78  type SResourceSkuRestrictionInfo struct {
    79  	Locations []string
    80  	Zones     []string
    81  }
    82  
    83  type SResourceSkuRestrictions struct {
    84  	ReasonCode      TResourceSkuRestrictionsReasonCode
    85  	RestrictionInfo SResourceSkuRestrictionInfo
    86  	Type            TResourceSkuRestrictionsType
    87  	Values          []string
    88  }
    89  
    90  type SResourceSku struct {
    91  	Capabilities []SResourceSkuCapability
    92  	Capacity     *SResourceSkuCapacity
    93  	Family       string
    94  	Kind         string
    95  	LocationInfo []SResourceSkuLocationInfo
    96  	Locations    []string
    97  	Name         string
    98  	ResourceType string
    99  	Restrictions []SResourceSkuRestrictions
   100  	Size         string
   101  	Tier         string
   102  }
   103  
   104  type SResourceSkusResult struct {
   105  	NextLink string
   106  	Value    []SResourceSku
   107  }
   108  
   109  func (self *SAzureClient) ListResourceSkus() ([]SResourceSku, error) {
   110  	skus := []SResourceSku{}
   111  	resource := "Microsoft.Compute/skus"
   112  	return skus, self.list(resource, nil, &skus)
   113  }