yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/azure/dbinstance_configuration.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  import (
    18  	"fmt"
    19  	"net/url"
    20  	"strings"
    21  
    22  	"yunion.io/x/pkg/errors"
    23  )
    24  
    25  type SDBInstanceConfiguration struct {
    26  	Properties SDBInstanceConfigurationProperties `json:"properties"`
    27  	ID         string                             `json:"id"`
    28  	Name       string                             `json:"name"`
    29  	Type       string                             `json:"type"`
    30  }
    31  
    32  type SDBInstanceConfigurationProperties struct {
    33  	Value         string `json:"value"`
    34  	Description   string `json:"description"`
    35  	DefaultValue  string `json:"defaultValue"`
    36  	DataType      string `json:"dataType"`
    37  	AllowedValues string `json:"allowedValues"`
    38  	Source        string `json:"source"`
    39  }
    40  
    41  func (self *SRegion) ListDBInstanceConfiguration(Id string) ([]SDBInstanceConfiguration, error) {
    42  	type configs struct {
    43  		Value []SDBInstanceConfiguration
    44  	}
    45  	result := configs{}
    46  	err := self.get(fmt.Sprintf("%s/configurations", Id), url.Values{}, &result)
    47  	if err != nil {
    48  		return nil, errors.Wrapf(err, "get(%s/configurations)", Id)
    49  	}
    50  	return result.Value, nil
    51  }
    52  
    53  func (param *SDBInstanceConfiguration) GetGlobalId() string {
    54  	return strings.ToLower(param.ID)
    55  }
    56  
    57  func (param *SDBInstanceConfiguration) GetKey() string {
    58  	return strings.ToLower(param.Name)
    59  }
    60  
    61  func (param *SDBInstanceConfiguration) GetValue() string {
    62  	return param.Properties.Value
    63  }
    64  
    65  func (param *SDBInstanceConfiguration) GetDescription() string {
    66  	return param.Properties.Description
    67  }