2017-06-25 21:45:22 +00:00
|
|
|
// +-------------------------------------------------------------------------
|
|
|
|
// | Copyright (C) 2016 Yunify, Inc.
|
|
|
|
// +-------------------------------------------------------------------------
|
|
|
|
// | Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// | you may not use this work except in compliance with the License.
|
|
|
|
// | You may obtain a copy of the License in the LICENSE file, or at:
|
|
|
|
// |
|
|
|
|
// | http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
// |
|
|
|
|
// | Unless required by applicable law or agreed to in writing, software
|
|
|
|
// | distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// | See the License for the specific language governing permissions and
|
|
|
|
// | limitations under the License.
|
|
|
|
// +-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
{{$service := .Data.Service}}
|
|
|
|
{{$subService := index .Data.SubServices .CurrentSubServiceID}}
|
|
|
|
|
|
|
|
package service
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"io"
|
2017-08-08 09:18:33 +00:00
|
|
|
"net/http"
|
2017-09-30 14:27:27 +00:00
|
|
|
"strings"
|
2017-06-25 21:45:22 +00:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/yunify/qingstor-sdk-go/config"
|
|
|
|
"github.com/yunify/qingstor-sdk-go/request"
|
|
|
|
"github.com/yunify/qingstor-sdk-go/request/data"
|
|
|
|
"github.com/yunify/qingstor-sdk-go/request/errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ fmt.State
|
|
|
|
var _ io.Reader
|
2017-08-08 09:18:33 +00:00
|
|
|
var _ http.Header
|
2017-09-30 14:27:27 +00:00
|
|
|
var _ strings.Reader
|
2017-06-25 21:45:22 +00:00
|
|
|
var _ time.Time
|
|
|
|
var _ config.Config
|
|
|
|
|
|
|
|
{{if ne $subService.Name "Object"}}
|
|
|
|
// {{$subService.ID | camelCase}} presents {{$subService.ID | snakeCase}}.
|
|
|
|
type {{$subService.ID | camelCase}} struct {
|
|
|
|
Config *config.Config
|
|
|
|
Properties *Properties
|
|
|
|
}
|
|
|
|
|
|
|
|
// {{$subService.ID | camelCase}} initializes a new {{$subService.ID | snakeCase}}.
|
|
|
|
func (s *Service) {{$subService.ID | camelCase}}(
|
|
|
|
{{- template "SubServiceInitParams" passThrough $subService.Properties true -}}
|
|
|
|
) (*{{$subService.ID | camelCase}}, error) {
|
2017-09-30 14:27:27 +00:00
|
|
|
{{- range $_, $property := $subService.Properties.Properties -}}
|
|
|
|
{{if eq $property.ID "zone"}}
|
|
|
|
{{$property.ID}} = strings.ToLower({{$property.ID}})
|
|
|
|
{{end}}
|
|
|
|
{{- end -}}
|
2017-06-25 21:45:22 +00:00
|
|
|
properties := &Properties{
|
|
|
|
{{range $_, $property := $subService.Properties.Properties -}}
|
|
|
|
{{$property.ID | upperFirst}}: &{{$property.ID}},
|
|
|
|
{{end -}}
|
|
|
|
}
|
|
|
|
|
|
|
|
return &{{$subService.ID | camelCase}}{Config: s.Config, Properties: properties}, nil
|
|
|
|
}
|
|
|
|
{{end}}
|
|
|
|
|
|
|
|
{{range $_, $operation := $subService.Operations}}
|
|
|
|
{{template "RenderOperation" passThrough $subService $operation}}
|
|
|
|
{{end}}
|