|
| 1 | +/* |
| 2 | +Copyright © LiquidWeb |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | +package cmd |
| 17 | + |
| 18 | +import ( |
| 19 | + "fmt" |
| 20 | + |
| 21 | + "github.com/spf13/cobra" |
| 22 | + |
| 23 | + "github.com/liquidweb/liquidweb-cli/instance" |
| 24 | +) |
| 25 | + |
| 26 | +var cloudTemplateRestoreCmd = &cobra.Command{ |
| 27 | + Use: "restore", |
| 28 | + Short: "Restore a Cloud Template on a Cloud Server", |
| 29 | + Long: `Restore a Cloud Template on a Cloud Server.`, |
| 30 | + Run: func(cmd *cobra.Command, args []string) { |
| 31 | + params := &instance.CloudTemplateRestoreParams{} |
| 32 | + |
| 33 | + params.UniqId, _ = cmd.Flags().GetString("uniq-id") |
| 34 | + params.Template, _ = cmd.Flags().GetString("template") |
| 35 | + |
| 36 | + result, err := lwCliInst.CloudTemplateRestore(params) |
| 37 | + if err != nil { |
| 38 | + lwCliInst.Die(err) |
| 39 | + } |
| 40 | + |
| 41 | + fmt.Printf("Restoring template! %s\n", result) |
| 42 | + fmt.Printf("\tcheck progress with 'cloud server status --uniq-id %s'\n", params.UniqId) |
| 43 | + }, |
| 44 | +} |
| 45 | + |
| 46 | +func init() { |
| 47 | + cloudTemplateCmd.AddCommand(cloudTemplateRestoreCmd) |
| 48 | + |
| 49 | + cloudTemplateRestoreCmd.Flags().String("uniq-id", "", "uniq-id of Cloud Server") |
| 50 | + cloudTemplateRestoreCmd.Flags().String("template", "", "name of template to restore") |
| 51 | + |
| 52 | + cloudTemplateRestoreCmd.MarkFlagRequired("uniq-id") |
| 53 | + cloudTemplateRestoreCmd.MarkFlagRequired("template") |
| 54 | +} |
0 commit comments