1/* Copyright 2017 WALLIX
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7    http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14*/
15
16package awsspec
17
18import (
19	awssdk "github.com/aws/aws-sdk-go/aws"
20	"github.com/aws/aws-sdk-go/service/ecs"
21	"github.com/aws/aws-sdk-go/service/ecs/ecsiface"
22	"github.com/wallix/awless/cloud"
23	"github.com/wallix/awless/logger"
24	"github.com/wallix/awless/template/params"
25)
26
27type CreateContainercluster struct {
28	_      string `action:"create" entity:"containercluster" awsAPI:"ecs" awsCall:"CreateCluster" awsInput:"ecs.CreateClusterInput" awsOutput:"ecs.CreateClusterOutput"`
29	logger *logger.Logger
30	graph  cloud.GraphAPI
31	api    ecsiface.ECSAPI
32	Name   *string `awsName:"ClusterName" awsType:"awsstr" templateName:"name"`
33}
34
35func (cmd *CreateContainercluster) ParamsSpec() params.Spec {
36	return params.NewSpec(params.AllOf(params.Key("name")))
37}
38
39func (cmd *CreateContainercluster) ExtractResult(i interface{}) string {
40	return awssdk.StringValue(i.(*ecs.CreateClusterOutput).Cluster.ClusterArn)
41}
42
43type DeleteContainercluster struct {
44	_      string `action:"delete" entity:"containercluster" awsAPI:"ecs" awsCall:"DeleteCluster" awsInput:"ecs.DeleteClusterInput" awsOutput:"ecs.DeleteClusterOutput"`
45	logger *logger.Logger
46	graph  cloud.GraphAPI
47	api    ecsiface.ECSAPI
48	Id     *string `awsName:"Cluster" awsType:"awsstr" templateName:"id"`
49}
50
51func (cmd *DeleteContainercluster) ParamsSpec() params.Spec {
52	return params.NewSpec(params.AllOf(params.Key("id")))
53}
54