Skip to content
This repository was archived by the owner on May 6, 2022. It is now read-only.

Commit 2ef16e7

Browse files
committed
support environment deployments
1 parent 21f65ea commit 2ef16e7

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed

client/env/env.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ func List() (respBody []byte, err error) {
4343
return respBody, err
4444
}
4545

46+
//GetDeployments
47+
func GetDeployments() (respBody []byte, err error) {
48+
u, _ := url.Parse(apiclient.BaseURL)
49+
u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "environments", apiclient.GetApigeeEnv(), "deployments")
50+
respBody, err = apiclient.HttpClient(apiclient.GetPrintOutput(), u.String())
51+
return respBody, err
52+
}
53+
4654
//SetEnvProperty is used to set env properties
4755
func SetEnvProperty(name string, value string) (err error) {
4856
//EnvProperty contains an individual org flag or property

cmd/env/deployments.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright 2020 Google LLC
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 env
16+
17+
import (
18+
"github.com/spf13/cobra"
19+
)
20+
21+
//DeployCmd to manage api deployments for an environment
22+
var DeployCmd = &cobra.Command{
23+
Use: "deployments",
24+
Short: "Manage deployments for the environment",
25+
Long: "Manage deployments for the environment",
26+
}
27+
28+
func init() {
29+
30+
DeployCmd.PersistentFlags().StringVarP(&environment, "env", "e",
31+
"", "Apigee environment name")
32+
33+
_ = DeployCmd.MarkPersistentFlagRequired("env")
34+
35+
DeployCmd.AddCommand(GetDeployCmd)
36+
}

cmd/env/env.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,5 @@ func init() {
4141
Cmd.AddCommand(DebugCmd)
4242
Cmd.AddCommand(ObCmd)
4343
Cmd.AddCommand(PropCmd)
44+
Cmd.AddCommand(DeployCmd)
4445
}

cmd/env/getdeployments.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2020 Google LLC
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 env
16+
17+
import (
18+
"github.com/spf13/cobra"
19+
"github.com/srinandan/apigeecli/apiclient"
20+
environments "github.com/srinandan/apigeecli/client/env"
21+
)
22+
23+
//DeployCmd to get deployed apis in an env
24+
var GetDeployCmd = &cobra.Command{
25+
Use: "get",
26+
Short: "Get deployments for an Environment",
27+
Long: "Get deployments for an Environment",
28+
Args: func(cmd *cobra.Command, args []string) (err error) {
29+
apiclient.SetApigeeOrg(org)
30+
apiclient.SetApigeeEnv(environment)
31+
return nil
32+
},
33+
RunE: func(cmd *cobra.Command, args []string) (err error) {
34+
_, err = environments.GetDeployments()
35+
return
36+
},
37+
}

0 commit comments

Comments
 (0)