-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Onboard new APIs to apigeecli #335
Conversation
I'm working on it... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested portal apis, see comments in line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few more issues --name on update commands, should be --id
--categoryIds not parsing comma separated list
payload for documentation is incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably easier to review the changes I made to get things working using git diff output
git diff
diff --git a/cmd/apidocs/update.go b/cmd/apidocs/update.go
index 6f6faed5..6c37fe3e 100644
--- a/cmd/apidocs/update.go
+++ b/cmd/apidocs/update.go
@@ -55,7 +55,7 @@ var UpdateCmd = &cobra.Command{
}
func init() {
- UpdateCmd.Flags().StringVarP(&name, "id", "i",
+ UpdateCmd.Flags().StringVarP(&id, "id", "i",
"", "Catalog UUID")
UpdateCmd.Flags().StringVarP(&title, "title", "l",
"", "The user-facing name of the catalog item")
diff --git a/cmd/apidocs/updatedocs.go b/cmd/apidocs/updatedocs.go
index 80d4f005..4ed6716e 100644
--- a/cmd/apidocs/updatedocs.go
+++ b/cmd/apidocs/updatedocs.go
@@ -37,6 +37,9 @@ var UpdateDocCmd = &cobra.Command{
if openAPIPath != "" && graphQLPath != "" {
return fmt.Errorf("The flags openapi and grapql cannot both be set")
}
+ if graphQLPath != "" && endpointUri == "" {
+ return fmt.Errorf("The flags graphQLPath and endpointUri must be set together")
+ }
return apiclient.SetApigeeOrg(org)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
@@ -64,12 +67,13 @@ var UpdateDocCmd = &cobra.Command{
graphQL = string(graphQLDoc)
}
- _, err = apidocs.UpdateDocumentation(siteid, id, name, openAPI, graphQL)
+ _, err = apidocs.UpdateDocumentation(siteid, id, name, openAPI, graphQL, endpointUri)
return
},
}
var openAPIPath, graphQLPath string
+var endpointUri string
func init() {
UpdateDocCmd.Flags().StringVarP(&id, "id", "i",
@@ -80,6 +84,9 @@ func init() {
"", "Path to a file containing OpenAPI Specification documentation")
UpdateDocCmd.Flags().StringVarP(&graphQLPath, "graphql", "q",
"", "Path to a file containing GraphQL documentation")
+ UpdateDocCmd.Flags().StringVarP(&endpointUri, "endpointUri", "e",
+ "", "URI for the GraphQL proxy")
_ = UpdateDocCmd.MarkFlagRequired("id")
+ _ = UpdateDocCmd.MarkFlagRequired("name")
}
diff --git a/internal/client/apidocs/apidocs.go b/internal/client/apidocs/apidocs.go
index 28b589e2..8fc15c77 100644
--- a/internal/client/apidocs/apidocs.go
+++ b/internal/client/apidocs/apidocs.go
@@ -129,17 +129,18 @@ func Delete(siteid string, id string) (respBody []byte, err error) {
}
// UpdateDocumentation
-func UpdateDocumentation(siteid string, id string, displayName string, openAPIDoc string, graphQLDoc string) (respBody []byte, err error) {
+func UpdateDocumentation(siteid string, id string, displayName string, openAPIDoc string, graphQLDoc string, endpointUri string) (respBody []byte, err error) {
var payload string
if openAPIDoc != "" {
- payload = "{\"oasDocumentation\":\"spec\":{" + "\"displayName\":" +
- displayName + "," + "\"contents\":" + openAPIDoc + "}}"
+ payload = "{\"oasDocumentation\":{\"spec\":{\"displayName\":\"" +
+ displayName + "\",\"contents\":" + openAPIDoc + "}}}"
}
if graphQLDoc != "" {
- payload = "{\"graphqlDocumentation\":\"spec\":{" + "\"displayName\":" +
- displayName + "," + "\"contents\":" + openAPIDoc + "}}"
+ payload = "{\"graphqlDocumentation\":{\"endpointUri\":\"" + endpointUri +
+ "\",\"schema\":{\"displayName\":\"" + displayName +
+ "\",\"contents\":" + graphQLDoc + "}}}"
}
u, _ := url.Parse(apiclient.BaseURL)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List Datastores API does not filter results by targetType, API issue.
Missing analytics export, which is second step after creating datastores.
Made numerous changes and pushed to "newapis" branch.
git diff
diff --git a/cmd/datastores/list.go b/cmd/datastores/list.go
index 23b877c1..8b33cdfc 100644
--- a/cmd/datastores/list.go
+++ b/cmd/datastores/list.go
@@ -36,6 +36,6 @@ var ListCmd = &cobra.Command{
}
func init() {
- ListCmd.Flags().StringVarP(&targetType, "name", "n",
+ ListCmd.Flags().StringVarP(&targetType, "targettype", "",
"", "TargetType is used to fetch datastores of matching type; default is fetch all")
}
diff --git a/cmd/datastores/test.go b/cmd/datastores/test.go
index bd9d0d06..7ff56305 100644
--- a/cmd/datastores/test.go
+++ b/cmd/datastores/test.go
@@ -43,8 +43,6 @@ var TestCmd = &cobra.Command{
var id string
func init() {
- TestCmd.Flags().StringVarP(&id, "id", "i",
- "", "Data store id")
TestCmd.Flags().StringVarP(&name, "name", "n",
"", "Display name for the data store")
TestCmd.Flags().StringVarP(&targetType, "target", "",
diff --git a/cmd/securityprofiles/attach.go b/cmd/securityprofiles/attach.go
index 99527a82..225fb801 100644
--- a/cmd/securityprofiles/attach.go
+++ b/cmd/securityprofiles/attach.go
@@ -45,4 +45,7 @@ func init() {
"", "Apigee environment name")
AttachCmd.Flags().StringVarP(&revision, "rev", "r",
"", "Security Profile revision id")
+ _ = AttachCmd.MarkFlagRequired("name")
+ _ = AttachCmd.MarkFlagRequired("env")
+ _ = AttachCmd.MarkFlagRequired("rev")
}
diff --git a/cmd/securityprofiles/create.go b/cmd/securityprofiles/create.go
index 1571ec7e..c9c80320 100644
--- a/cmd/securityprofiles/create.go
+++ b/cmd/securityprofiles/create.go
@@ -44,7 +44,7 @@ var securityActionFile string
func init() {
CreateCmd.Flags().StringVarP(&name, "name", "n",
- "", "Security Action name")
+ "", "Name of the security profile")
CreateCmd.Flags().StringVarP(&securityActionFile, "file", "f",
"", "Path to a file containing Security Profile content")
_ = CreateCmd.MarkFlagRequired("name")
diff --git a/cmd/securityprofiles/delete.go b/cmd/securityprofiles/delete.go
index af379624..37d7b1ca 100644
--- a/cmd/securityprofiles/delete.go
+++ b/cmd/securityprofiles/delete.go
@@ -38,4 +38,5 @@ var DeleteCmd = &cobra.Command{
func init() {
DeleteCmd.Flags().StringVarP(&name, "name", "n",
"", "Name of the security profile")
+ _ = DeleteCmd.MarkFlagRequired("name")
}
diff --git a/cmd/securityprofiles/detach.go b/cmd/securityprofiles/detach.go
index 7b0dbba9..ace61c77 100644
--- a/cmd/securityprofiles/detach.go
+++ b/cmd/securityprofiles/detach.go
@@ -23,9 +23,9 @@ import (
// DetachCmd to list catalog items
var DetachCmd = &cobra.Command{
- Use: "get",
- Short: "Returns a security profile by name",
- Long: "Returns a security profile by name",
+ Use: "detach",
+ Short: "Detach a security profile from an environment",
+ Long: "Detach a security profile from an environment",
Args: func(cmd *cobra.Command, args []string) (err error) {
apiclient.SetApigeeEnv(environment)
return apiclient.SetApigeeOrg(org)
@@ -41,4 +41,6 @@ func init() {
"", "Name of the security profile")
DetachCmd.Flags().StringVarP(&environment, "env", "e",
"", "Apigee environment name")
+ _ = DetachCmd.MarkFlagRequired("name")
+ _ = DetachCmd.MarkFlagRequired("env")
}
diff --git a/cmd/securityprofiles/get.go b/cmd/securityprofiles/get.go
index 6d172b15..4b3fc4cd 100644
--- a/cmd/securityprofiles/get.go
+++ b/cmd/securityprofiles/get.go
@@ -40,4 +40,5 @@ var name string
func init() {
GetCmd.Flags().StringVarP(&name, "name", "n",
"", "Name of the security profile")
+ _ = GetCmd.MarkFlagRequired("name")
}
diff --git a/cmd/securityprofiles/listrevisions.go b/cmd/securityprofiles/listrevisions.go
index 39c22d03..bf00283c 100644
--- a/cmd/securityprofiles/listrevisions.go
+++ b/cmd/securityprofiles/listrevisions.go
@@ -23,14 +23,14 @@ import (
// ListRevisionsCmd to list catalog items
var ListRevisionsCmd = &cobra.Command{
- Use: "listversions",
+ Use: "listrevisions",
Short: "Returns the revisions of a security profile",
Long: "Returns the revisions of a security profile",
Args: func(cmd *cobra.Command, args []string) (err error) {
return apiclient.SetApigeeOrg(org)
},
RunE: func(cmd *cobra.Command, args []string) (err error) {
- _, err = securityprofiles.ListVersions(name)
+ _, err = securityprofiles.ListRevisions(name)
return
},
}
@@ -38,4 +38,5 @@ var ListRevisionsCmd = &cobra.Command{
func init() {
ListRevisionsCmd.Flags().StringVarP(&name, "name", "n",
"", "Name of the security profile")
+ _ = ListRevisionsCmd.MarkFlagRequired("name")
}
diff --git a/cmd/securityprofiles/securityprofiles.go b/cmd/securityprofiles/securityprofiles.go
index 05b7bb97..f0d358d9 100644
--- a/cmd/securityprofiles/securityprofiles.go
+++ b/cmd/securityprofiles/securityprofiles.go
@@ -38,6 +38,7 @@ func init() {
Cmd.AddCommand(AttachCmd)
Cmd.AddCommand(DetachCmd)
Cmd.AddCommand(CreateCmd)
+ Cmd.AddCommand(ListRevisionsCmd)
_ = Cmd.MarkFlagRequired("org")
}
diff --git a/internal/client/datastores/datastores.go b/internal/client/datastores/datastores.go
index fe56c458..57218f71 100644
--- a/internal/client/datastores/datastores.go
+++ b/internal/client/datastores/datastores.go
@@ -202,7 +202,7 @@ func GetVersion(name string) (version string, err error) {
func List(targetType string) (respBody []byte, err error) {
u, _ := url.Parse(apiclient.BaseURL)
u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "analytics", "datastores")
- if (targetType != "") && (targetType != "gcs" || targetType != "bigquery") {
+ if (targetType != "") && (targetType != "gcs" && targetType != "bigquery") {
return nil, fmt.Errorf("invalid targetType. Must be gcs or bigquery")
}
q := u.Query()
diff --git a/internal/client/securityprofiles/securityprofiles.go b/internal/client/securityprofiles/securityprofiles.go
index fe1d3ab6..03290cfb 100644
--- a/internal/client/securityprofiles/securityprofiles.go
+++ b/internal/client/securityprofiles/securityprofiles.go
@@ -104,7 +104,7 @@ func Get(name string) (respBody []byte, err error) {
}
// ListVersions
-func ListVersions(name string) (respBody []byte, err error) {
+func ListRevisions(name string) (respBody []byte, err error) {
u, _ := url.Parse(apiclient.BaseURL)
u.Path = path.Join(u.Path, apiclient.GetApigeeOrg(), "securityProfiles", name+":listRevisions")
respBody, err = apiclient.HttpClient(u.String())
No description provided.