yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/azure/shell/app_service_plan.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 shell
    16  
    17  import (
    18  	"fmt"
    19  
    20  	"yunion.io/x/jsonutils"
    21  
    22  	"yunion.io/x/cloudmux/pkg/multicloud/azure"
    23  	"yunion.io/x/onecloud/pkg/util/shellutils"
    24  )
    25  
    26  func init() {
    27  	type AppServicePlanListOptions struct {
    28  	}
    29  	shellutils.R(&AppServicePlanListOptions{}, "app-service-plan-list", "List app service plan", func(cli *azure.SRegion, args *AppServicePlanListOptions) error {
    30  		appServicePlans, err := cli.GetAppServicePlans()
    31  		if err != nil {
    32  			return err
    33  		}
    34  		fmt.Printf("sku: %s\n", jsonutils.Marshal(appServicePlans[0].Sku))
    35  		printList(appServicePlans, len(appServicePlans), 0, 0, []string{})
    36  		return nil
    37  	})
    38  	type AppServicePlanShowOptions struct {
    39  		ID string
    40  	}
    41  	shellutils.R(&AppServicePlanShowOptions{}, "app-service-plan-show", "Show app service plan", func(cli *azure.SRegion, args *AppServicePlanShowOptions) error {
    42  		appServicePlan, err := cli.GetAppServicePlan(args.ID)
    43  		if err != nil {
    44  			return err
    45  		}
    46  		printObject(appServicePlan)
    47  		return nil
    48  	})
    49  	shellutils.R(&AppServicePlanListOptions{}, "autoscale-setting-list", "List autoscale setting in app service plan", func(cli *azure.SRegion, args *AppServicePlanListOptions) error {
    50  		appServicePlans, err := cli.GetAutoscaleSettingResources()
    51  		if err != nil {
    52  			return err
    53  		}
    54  		printList(appServicePlans, len(appServicePlans), 0, 0, []string{})
    55  		return nil
    56  	})
    57  	shellutils.R(&AppServicePlanShowOptions{}, "app-service-sku-list", "List sku usable in app service plan", func(cli *azure.SRegion, args *AppServicePlanShowOptions) error {
    58  		appServicePlan, err := cli.GetAppServicePlan(args.ID)
    59  		if err != nil {
    60  			return err
    61  		}
    62  		skus, err := appServicePlan.GetSkus()
    63  		if err != nil {
    64  			return err
    65  		}
    66  		printList(skus, len(skus), 0, 0, []string{})
    67  		return nil
    68  	})
    69  	shellutils.R(&AppServicePlanShowOptions{}, "app-service-network-list", "List network connected with app service plan", func(cli *azure.SRegion, args *AppServicePlanShowOptions) error {
    70  		appServicePlan, err := cli.GetAppServicePlan(args.ID)
    71  		if err != nil {
    72  			return err
    73  		}
    74  		networks, err := appServicePlan.GetNetworks()
    75  		if err != nil {
    76  			return err
    77  		}
    78  		printList(networks, len(networks), 0, 0, []string{})
    79  		return nil
    80  	})
    81  }