diff --git a/client/env/env.go b/client/env/env.go index cf62d46f..b1d98dbd 100644 --- a/client/env/env.go +++ b/client/env/env.go @@ -43,6 +43,14 @@ func List() (respBody []byte, err error) { return respBody, err } +//GetDeployments +func GetDeployments() (respBody []byte, err error) { + u, _ := url.Parse(apiclient.BaseURL) + u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "environments", apiclient.GetApigeeEnv(), "deployments") + respBody, err = apiclient.HttpClient(apiclient.GetPrintOutput(), u.String()) + return respBody, err +} + //SetEnvProperty is used to set env properties func SetEnvProperty(name string, value string) (err error) { //EnvProperty contains an individual org flag or property diff --git a/cmd/env/deployments.go b/cmd/env/deployments.go new file mode 100644 index 00000000..a05d3795 --- /dev/null +++ b/cmd/env/deployments.go @@ -0,0 +1,36 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License 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. + +package env + +import ( + "github.com/spf13/cobra" +) + +//DeployCmd to manage api deployments for an environment +var DeployCmd = &cobra.Command{ + Use: "deployments", + Short: "Manage deployments for the environment", + Long: "Manage deployments for the environment", +} + +func init() { + + DeployCmd.PersistentFlags().StringVarP(&environment, "env", "e", + "", "Apigee environment name") + + _ = DeployCmd.MarkPersistentFlagRequired("env") + + DeployCmd.AddCommand(GetDeployCmd) +} diff --git a/cmd/env/env.go b/cmd/env/env.go index 8070676d..7ff7da98 100644 --- a/cmd/env/env.go +++ b/cmd/env/env.go @@ -41,4 +41,5 @@ func init() { Cmd.AddCommand(DebugCmd) Cmd.AddCommand(ObCmd) Cmd.AddCommand(PropCmd) + Cmd.AddCommand(DeployCmd) } diff --git a/cmd/env/getdeployments.go b/cmd/env/getdeployments.go new file mode 100644 index 00000000..b427714d --- /dev/null +++ b/cmd/env/getdeployments.go @@ -0,0 +1,37 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License 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. + +package env + +import ( + "github.com/spf13/cobra" + "github.com/srinandan/apigeecli/apiclient" + environments "github.com/srinandan/apigeecli/client/env" +) + +//DeployCmd to get deployed apis in an env +var GetDeployCmd = &cobra.Command{ + Use: "get", + Short: "Get deployments for an Environment", + Long: "Get deployments for an Environment", + Args: func(cmd *cobra.Command, args []string) (err error) { + apiclient.SetApigeeOrg(org) + apiclient.SetApigeeEnv(environment) + return nil + }, + RunE: func(cmd *cobra.Command, args []string) (err error) { + _, err = environments.GetDeployments() + return + }, +}