yunion.io/x/cloudmux@v0.3.10-0-alpha.1/pkg/multicloud/aws/dnstrafficpolicy.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 aws
    16  
    17  import (
    18  	"github.com/aws/aws-sdk-go/service/route53"
    19  
    20  	"yunion.io/x/pkg/errors"
    21  )
    22  
    23  type STrafficPolicy struct {
    24  	client   *SAwsClient
    25  	Comment  string `json:"Comment"`
    26  	Document string `json:"Document"` //require decode
    27  	Id       string `json:"Id"`
    28  	Name     string `json:"Name"`
    29  	DNSType  string `json:"Type"`
    30  	Version  int64  `json:"Version"`
    31  }
    32  
    33  func (client *SAwsClient) GetSTrafficPolicyById(TrafficPolicyInstanceId string) (*STrafficPolicy, error) {
    34  	s, err := client.getAwsRoute53Session()
    35  	if err != nil {
    36  		return nil, errors.Wrap(err, "region.getAwsRoute53Session()")
    37  	}
    38  	route53Client := route53.New(s)
    39  	params := route53.GetTrafficPolicyInput{}
    40  	params.Id = &TrafficPolicyInstanceId
    41  	var Version int64 = 1
    42  	params.Version = &Version
    43  	ret, err := route53Client.GetTrafficPolicy(&params)
    44  	if err != nil {
    45  		return nil, errors.Wrap(err, "route53Client.GetTrafficPolicy")
    46  	}
    47  	result := STrafficPolicy{}
    48  	err = unmarshalAwsOutput(ret, "TrafficPolicy", &result)
    49  	if err != nil {
    50  		return nil, errors.Wrap(err, "unmarshalAwsOutput(TrafficPolicy)")
    51  	}
    52  	return &result, nil
    53  }