forked from apigee/registry
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add generated CLI for provisioning service to the registry tool (apig…
…ee#570) * Add proto for provisioning service * Add generated code and CLI support for provisioning API.
- Loading branch information
Showing
62 changed files
with
2,322 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
cmd/registry/cmd/rpc/admin_service.go → ...gistry/cmd/rpc/generated/admin_service.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Code generated. DO NOT EDIT. | ||
|
||
package rpc | ||
package generated | ||
|
||
import ( | ||
"fmt" | ||
|
2 changes: 1 addition & 1 deletion
2
cmd/registry/cmd/rpc/apg.go → cmd/registry/cmd/rpc/generated/apg.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Code generated. DO NOT EDIT. | ||
|
||
package rpc | ||
package generated | ||
|
||
import ( | ||
"bytes" | ||
|
2 changes: 1 addition & 1 deletion
2
cmd/registry/cmd/rpc/completion.go → cmd/registry/cmd/rpc/generated/completion.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Code generated. DO NOT EDIT. | ||
|
||
package rpc | ||
package generated | ||
|
||
import ( | ||
"os" | ||
|
2 changes: 1 addition & 1 deletion
2
...registry/cmd/rpc/create-api-deployment.go → ...md/rpc/generated/create-api-deployment.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Code generated. DO NOT EDIT. | ||
|
||
package rpc | ||
package generated | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
2 changes: 1 addition & 1 deletion
2
cmd/registry/cmd/rpc/create-api-spec.go → ...stry/cmd/rpc/generated/create-api-spec.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Code generated. DO NOT EDIT. | ||
|
||
package rpc | ||
package generated | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
2 changes: 1 addition & 1 deletion
2
cmd/registry/cmd/rpc/create-api-version.go → ...y/cmd/rpc/generated/create-api-version.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Code generated. DO NOT EDIT. | ||
|
||
package rpc | ||
package generated | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
2 changes: 1 addition & 1 deletion
2
cmd/registry/cmd/rpc/create-api.go → cmd/registry/cmd/rpc/generated/create-api.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Code generated. DO NOT EDIT. | ||
|
||
package rpc | ||
package generated | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
2 changes: 1 addition & 1 deletion
2
cmd/registry/cmd/rpc/create-artifact.go → ...stry/cmd/rpc/generated/create-artifact.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Code generated. DO NOT EDIT. | ||
|
||
package rpc | ||
package generated | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
// Code generated. DO NOT EDIT. | ||
|
||
package generated | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
||
"fmt" | ||
|
||
"github.com/golang/protobuf/jsonpb" | ||
|
||
"os" | ||
|
||
rpcpb "github.com/apigee/registry/rpc" | ||
) | ||
|
||
var CreateInstanceInput rpcpb.CreateInstanceRequest | ||
|
||
var CreateInstanceFromFile string | ||
|
||
var CreateInstanceFollow bool | ||
|
||
var CreateInstancePollOperation string | ||
|
||
func init() { | ||
ProvisioningServiceCmd.AddCommand(CreateInstanceCmd) | ||
|
||
CreateInstanceInput.Instance = new(rpcpb.Instance) | ||
|
||
CreateInstanceInput.Instance.Config = new(rpcpb.Instance_Config) | ||
|
||
CreateInstanceCmd.Flags().StringVar(&CreateInstanceInput.Parent, "parent", "", "Required. Parent resource of the Instance, of the...") | ||
|
||
CreateInstanceCmd.Flags().StringVar(&CreateInstanceInput.InstanceId, "instance_id", "", "Required. Identifier to assign to the Instance....") | ||
|
||
CreateInstanceCmd.Flags().StringVar(&CreateInstanceInput.Instance.Name, "instance.name", "", "Format: `projects/*/locations/*/instance`. ...") | ||
|
||
CreateInstanceCmd.Flags().StringVar(&CreateInstanceInput.Instance.Config.CmekKeyName, "instance.config.cmek_key_name", "", "Required. The Customer Managed Encryption Key...") | ||
|
||
CreateInstanceCmd.Flags().StringVar(&CreateInstanceFromFile, "from_file", "", "Absolute path to JSON file containing request payload") | ||
|
||
CreateInstanceCmd.Flags().BoolVar(&CreateInstanceFollow, "follow", false, "Block until the long running operation completes") | ||
|
||
ProvisioningServiceCmd.AddCommand(CreateInstancePollCmd) | ||
|
||
CreateInstancePollCmd.Flags().BoolVar(&CreateInstanceFollow, "follow", false, "Block until the long running operation completes") | ||
|
||
CreateInstancePollCmd.Flags().StringVar(&CreateInstancePollOperation, "operation", "", "Required. Operation name to poll for") | ||
|
||
CreateInstancePollCmd.MarkFlagRequired("operation") | ||
|
||
} | ||
|
||
var CreateInstanceCmd = &cobra.Command{ | ||
Use: "create-instance", | ||
Short: "Provisions instance resources for the Registry.", | ||
Long: "Provisions instance resources for the Registry.", | ||
PreRun: func(cmd *cobra.Command, args []string) { | ||
|
||
if CreateInstanceFromFile == "" { | ||
|
||
cmd.MarkFlagRequired("parent") | ||
|
||
cmd.MarkFlagRequired("instance_id") | ||
|
||
cmd.MarkFlagRequired("instance.config.cmek_key_name") | ||
|
||
} | ||
|
||
}, | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
|
||
in := os.Stdin | ||
if CreateInstanceFromFile != "" { | ||
in, err = os.Open(CreateInstanceFromFile) | ||
if err != nil { | ||
return err | ||
} | ||
defer in.Close() | ||
|
||
err = jsonpb.Unmarshal(in, &CreateInstanceInput) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
} | ||
|
||
if Verbose { | ||
printVerboseInput("Provisioning", "CreateInstance", &CreateInstanceInput) | ||
} | ||
resp, err := ProvisioningClient.CreateInstance(ctx, &CreateInstanceInput) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if !CreateInstanceFollow { | ||
var s interface{} | ||
s = resp.Name() | ||
|
||
if OutputJSON { | ||
d := make(map[string]string) | ||
d["operation"] = resp.Name() | ||
s = d | ||
} | ||
|
||
printMessage(s) | ||
return err | ||
} | ||
|
||
result, err := resp.Wait(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if Verbose { | ||
fmt.Print("Output: ") | ||
} | ||
printMessage(result) | ||
|
||
return err | ||
}, | ||
} | ||
|
||
var CreateInstancePollCmd = &cobra.Command{ | ||
Use: "poll-create-instance", | ||
Short: "Poll the status of a CreateInstanceOperation by name", | ||
RunE: func(cmd *cobra.Command, args []string) (err error) { | ||
op := ProvisioningClient.CreateInstanceOperation(CreateInstancePollOperation) | ||
|
||
if CreateInstanceFollow { | ||
resp, err := op.Wait(ctx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if Verbose { | ||
fmt.Print("Output: ") | ||
} | ||
printMessage(resp) | ||
return err | ||
} | ||
|
||
resp, err := op.Poll(ctx) | ||
if err != nil { | ||
return err | ||
} else if resp != nil { | ||
if Verbose { | ||
fmt.Print("Output: ") | ||
} | ||
|
||
printMessage(resp) | ||
return | ||
} | ||
|
||
if op.Done() { | ||
fmt.Println(fmt.Sprintf("Operation %s is done", op.Name())) | ||
} else { | ||
fmt.Println(fmt.Sprintf("Operation %s not done", op.Name())) | ||
} | ||
|
||
return err | ||
}, | ||
} |
2 changes: 1 addition & 1 deletion
2
cmd/registry/cmd/rpc/create-project.go → ...istry/cmd/rpc/generated/create-project.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Code generated. DO NOT EDIT. | ||
|
||
package rpc | ||
package generated | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
2 changes: 1 addition & 1 deletion
2
...cmd/rpc/delete-api-deployment-revision.go → ...nerated/delete-api-deployment-revision.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Code generated. DO NOT EDIT. | ||
|
||
package rpc | ||
package generated | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
2 changes: 1 addition & 1 deletion
2
...registry/cmd/rpc/delete-api-deployment.go → ...md/rpc/generated/delete-api-deployment.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Code generated. DO NOT EDIT. | ||
|
||
package rpc | ||
package generated | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
2 changes: 1 addition & 1 deletion
2
...istry/cmd/rpc/delete-api-spec-revision.go → ...rpc/generated/delete-api-spec-revision.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Code generated. DO NOT EDIT. | ||
|
||
package rpc | ||
package generated | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
2 changes: 1 addition & 1 deletion
2
cmd/registry/cmd/rpc/delete-api-spec.go → ...stry/cmd/rpc/generated/delete-api-spec.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Code generated. DO NOT EDIT. | ||
|
||
package rpc | ||
package generated | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
2 changes: 1 addition & 1 deletion
2
cmd/registry/cmd/rpc/delete-api-version.go → ...y/cmd/rpc/generated/delete-api-version.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Code generated. DO NOT EDIT. | ||
|
||
package rpc | ||
package generated | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
2 changes: 1 addition & 1 deletion
2
cmd/registry/cmd/rpc/delete-api.go → cmd/registry/cmd/rpc/generated/delete-api.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Code generated. DO NOT EDIT. | ||
|
||
package rpc | ||
package generated | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
2 changes: 1 addition & 1 deletion
2
cmd/registry/cmd/rpc/delete-artifact.go → ...stry/cmd/rpc/generated/delete-artifact.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// Code generated. DO NOT EDIT. | ||
|
||
package rpc | ||
package generated | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
|
Oops, something went wrong.