From 531ccab1c77043cf948daf9625845c4446c27c79 Mon Sep 17 00:00:00 2001 From: Srinandan Sridhar <13950006+srinandan@users.noreply.github.com> Date: Thu, 27 Jun 2024 08:14:38 -0700 Subject: [PATCH] feat: adds support to envgrp import #470 (#486) * feat: adds support to envgrp import #470 * feat: adds import command #470 --- internal/cmd/envgroup/envgroup.go | 1 + internal/cmd/envgroup/import.go | 51 +++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 internal/cmd/envgroup/import.go diff --git a/internal/cmd/envgroup/envgroup.go b/internal/cmd/envgroup/envgroup.go index a4fae1cfa..4bdf13b07 100644 --- a/internal/cmd/envgroup/envgroup.go +++ b/internal/cmd/envgroup/envgroup.go @@ -44,4 +44,5 @@ func init() { Cmd.AddCommand(DetachCmd) Cmd.AddCommand(UpdateCmd) Cmd.AddCommand(DelCmd) + Cmd.AddCommand(ImpCmd) } diff --git a/internal/cmd/envgroup/import.go b/internal/cmd/envgroup/import.go new file mode 100644 index 000000000..a629481f4 --- /dev/null +++ b/internal/cmd/envgroup/import.go @@ -0,0 +1,51 @@ +// 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 envgroup + +import ( + "internal/apiclient" + + "internal/client/envgroups" + + "github.com/spf13/cobra" +) + +// ImpCmd to list products +var ImpCmd = &cobra.Command{ + Use: "import", + Short: "Import a file containing environment group definitions", + Long: "Import a file containing environment group definitions", + Args: func(cmd *cobra.Command, args []string) (err error) { + apiclient.SetRegion(region) + return apiclient.SetApigeeOrg(org) + }, + RunE: func(cmd *cobra.Command, args []string) (err error) { + cmd.SilenceUsage = true + + err = envgroups.Import(envGrpFile) + return + }, +} + +var envGrpFile string + +func init() { + ImpCmd.Flags().StringVarP(&org, "org", "o", + "", "Apigee organization name") + ImpCmd.Flags().StringVarP(&envGrpFile, "file", "f", + "", "File containing environment group definitions") + + _ = ImpCmd.MarkFlagRequired("file") +}