|
| 1 | +// Licensed to Elasticsearch B.V. under one or more contributor |
| 2 | +// license agreements. See the NOTICE file distributed with |
| 3 | +// this work for additional information regarding copyright |
| 4 | +// ownership. Elasticsearch B.V. licenses this file to you under |
| 5 | +// the Apache License, Version 2.0 (the "License"); you may |
| 6 | +// not use this file except in compliance with the License. |
| 7 | +// You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +package cmdappsearch |
| 19 | + |
| 20 | +import ( |
| 21 | + "github.com/elastic/cloud-sdk-go/pkg/util/cmdutil" |
| 22 | + "github.com/spf13/cobra" |
| 23 | + |
| 24 | + "github.com/elastic/ecctl/pkg/deployment" |
| 25 | + "github.com/elastic/ecctl/pkg/deployment/deputil" |
| 26 | + "github.com/elastic/ecctl/pkg/ecctl" |
| 27 | +) |
| 28 | + |
| 29 | +var showAppSearchCmd = &cobra.Command{ |
| 30 | + Use: "show <deployment id>", |
| 31 | + Short: "Shows the specified AppSearch deployment", |
| 32 | + PreRunE: cmdutil.MinimumNArgsAndUUID(1), |
| 33 | + RunE: func(cmd *cobra.Command, args []string) error { |
| 34 | + refID, _ := cmd.Flags().GetString("ref-id") |
| 35 | + planLogs, _ := cmd.Flags().GetBool("plan-logs") |
| 36 | + planDefaults, _ := cmd.Flags().GetBool("plan-defaults") |
| 37 | + metadata, _ := cmd.Flags().GetBool("metadata") |
| 38 | + settings, _ := cmd.Flags().GetBool("settings") |
| 39 | + plans, _ := cmd.Flags().GetBool("plans") |
| 40 | + var showPlans bool |
| 41 | + if planLogs || planDefaults || plans { |
| 42 | + showPlans = true |
| 43 | + } |
| 44 | + res, err := deployment.GetResource(deployment.GetResourceParams{ |
| 45 | + Type: "appsearch", |
| 46 | + GetParams: deployment.GetParams{ |
| 47 | + API: ecctl.Get().API, |
| 48 | + DeploymentID: args[0], |
| 49 | + RefID: refID, |
| 50 | + QueryParams: deputil.QueryParams{ |
| 51 | + ShowPlans: showPlans, |
| 52 | + ShowPlanLogs: planLogs, |
| 53 | + ShowPlanDefaults: planDefaults, |
| 54 | + ShowMetadata: metadata, |
| 55 | + ShowSettings: settings, |
| 56 | + }, |
| 57 | + }, |
| 58 | + }) |
| 59 | + if err != nil { |
| 60 | + return err |
| 61 | + } |
| 62 | + return ecctl.Get().Formatter.Format("", res) |
| 63 | + }, |
| 64 | +} |
| 65 | + |
| 66 | +func init() { |
| 67 | + showAppSearchCmd.Flags().String("ref-id", "", "Optional RefId, auto-discovered if not specified") |
| 68 | + showAppSearchCmd.Flags().Bool("plans", false, "Shows the deployment plans") |
| 69 | + showAppSearchCmd.Flags().Bool("plan-logs", false, "Shows the deployment plan logs") |
| 70 | + showAppSearchCmd.Flags().Bool("plan-defaults", false, "Shows the deployment plan defaults") |
| 71 | + showAppSearchCmd.Flags().BoolP("metadata", "m", false, "Shows the deployment metadata") |
| 72 | + showAppSearchCmd.Flags().BoolP("settings", "s", false, "Shows the deployment settings") |
| 73 | +} |
0 commit comments