From 81d952d9043804da5f63ec63d0d0278b69b7e279 Mon Sep 17 00:00:00 2001 From: srinandan <13950006+srinandan@users.noreply.github.com> Date: Wed, 15 May 2024 10:36:10 -0700 Subject: [PATCH] chore: remove Apigee API Registry APIs #459 --- internal/client/registry/apis/apis.go | 113 ----------- internal/client/registry/apis/apis_test.go | 87 --------- internal/client/registry/apis/artifacts.go | 94 ---------- .../client/registry/apis/artifacts_test.go | 62 ------ internal/client/registry/apis/deployments.go | 176 ------------------ .../registry/apis/deployments/artifacts.go | 95 ---------- internal/client/registry/apis/versions.go | 115 ------------ .../registry/apis/versions/artifacts.go | 95 ---------- .../registry/apis/versions/specartifacts.go | 100 ---------- .../client/registry/apis/versions/specs.go | 164 ---------------- .../client/registry/artifacts/artifacts.go | 94 ---------- .../registry/artifacts/artifacts_test.go | 132 ------------- internal/client/registry/common/common.go | 74 -------- .../client/registry/instances/instances.go | 63 ------- internal/cmd/registry/apis/apis.go | 45 ----- .../cmd/registry/apis/artifacts/artifacts.go | 33 ---- .../registry/apis/artifacts/crtartifact.go | 71 ------- .../registry/apis/artifacts/delartifact.go | 52 ------ .../registry/apis/artifacts/getartifact.go | 58 ------ .../registry/apis/artifacts/listartifacts.go | 59 ------ internal/cmd/registry/apis/crtapis.go | 68 ------- internal/cmd/registry/apis/delapis.go | 46 ----- .../registry/apis/deployments/crtdeploy.go | 76 -------- .../registry/apis/deployments/deldeploy.go | 61 ------ .../registry/apis/deployments/deployments.go | 35 ---- .../registry/apis/deployments/getdeploy.go | 50 ----- .../registry/apis/deployments/listdeploy.go | 65 ------- .../apis/deployments/rollbackdeploy.go | 56 ------ .../registry/apis/deployments/tagdeploy.go | 56 ------ internal/cmd/registry/apis/getapis.go | 46 ----- internal/cmd/registry/apis/listapis.go | 55 ------ .../apis/versions/artifacts/artifacts.go | 35 ---- .../apis/versions/artifacts/crtartifact.go | 71 ------- .../apis/versions/artifacts/delartifact.go | 54 ------ .../apis/versions/artifacts/getartifact.go | 60 ------ .../apis/versions/artifacts/listartifacts.go | 62 ------ .../cmd/registry/apis/versions/crtversion.go | 67 ------- .../registry/apis/versions/deleteversion.go | 55 ------ .../cmd/registry/apis/versions/getversion.go | 53 ------ .../cmd/registry/apis/versions/listversion.go | 59 ------ .../versions/specs/artifacts/artifacts.go | 35 ---- .../versions/specs/artifacts/crtartifact.go | 76 -------- .../versions/specs/artifacts/delartifact.go | 57 ------ .../versions/specs/artifacts/getartifact.go | 57 ------ .../versions/specs/artifacts/listartifacts.go | 65 ------- .../registry/apis/versions/specs/crtspec.go | 82 -------- .../registry/apis/versions/specs/delspec.go | 54 ------ .../registry/apis/versions/specs/getspec.go | 65 ------- .../registry/apis/versions/specs/listspecs.go | 62 ------ .../cmd/registry/apis/versions/specs/specs.go | 36 ---- .../cmd/registry/apis/versions/versions.go | 38 ---- internal/cmd/registry/artifacts/artifacts.go | 35 ---- .../cmd/registry/artifacts/crtartifact.go | 66 ------- .../cmd/registry/artifacts/delartifact.go | 46 ----- .../cmd/registry/artifacts/getartifact.go | 53 ------ .../cmd/registry/artifacts/listartifact.go | 55 ------ .../cmd/registry/instances/crtinstance.go | 49 ----- .../cmd/registry/instances/delinstance.go | 44 ----- .../cmd/registry/instances/getinstance.go | 44 ----- internal/cmd/registry/instances/instances.go | 32 ---- internal/cmd/registry/registry.go | 44 ----- internal/cmd/root.go | 2 - 62 files changed, 4009 deletions(-) delete mode 100644 internal/client/registry/apis/apis.go delete mode 100644 internal/client/registry/apis/apis_test.go delete mode 100644 internal/client/registry/apis/artifacts.go delete mode 100644 internal/client/registry/apis/artifacts_test.go delete mode 100644 internal/client/registry/apis/deployments.go delete mode 100644 internal/client/registry/apis/deployments/artifacts.go delete mode 100644 internal/client/registry/apis/versions.go delete mode 100644 internal/client/registry/apis/versions/artifacts.go delete mode 100644 internal/client/registry/apis/versions/specartifacts.go delete mode 100644 internal/client/registry/apis/versions/specs.go delete mode 100644 internal/client/registry/artifacts/artifacts.go delete mode 100644 internal/client/registry/artifacts/artifacts_test.go delete mode 100644 internal/client/registry/common/common.go delete mode 100644 internal/client/registry/instances/instances.go delete mode 100644 internal/cmd/registry/apis/apis.go delete mode 100644 internal/cmd/registry/apis/artifacts/artifacts.go delete mode 100644 internal/cmd/registry/apis/artifacts/crtartifact.go delete mode 100644 internal/cmd/registry/apis/artifacts/delartifact.go delete mode 100644 internal/cmd/registry/apis/artifacts/getartifact.go delete mode 100644 internal/cmd/registry/apis/artifacts/listartifacts.go delete mode 100644 internal/cmd/registry/apis/crtapis.go delete mode 100644 internal/cmd/registry/apis/delapis.go delete mode 100644 internal/cmd/registry/apis/deployments/crtdeploy.go delete mode 100644 internal/cmd/registry/apis/deployments/deldeploy.go delete mode 100644 internal/cmd/registry/apis/deployments/deployments.go delete mode 100644 internal/cmd/registry/apis/deployments/getdeploy.go delete mode 100644 internal/cmd/registry/apis/deployments/listdeploy.go delete mode 100644 internal/cmd/registry/apis/deployments/rollbackdeploy.go delete mode 100644 internal/cmd/registry/apis/deployments/tagdeploy.go delete mode 100644 internal/cmd/registry/apis/getapis.go delete mode 100644 internal/cmd/registry/apis/listapis.go delete mode 100644 internal/cmd/registry/apis/versions/artifacts/artifacts.go delete mode 100644 internal/cmd/registry/apis/versions/artifacts/crtartifact.go delete mode 100644 internal/cmd/registry/apis/versions/artifacts/delartifact.go delete mode 100644 internal/cmd/registry/apis/versions/artifacts/getartifact.go delete mode 100644 internal/cmd/registry/apis/versions/artifacts/listartifacts.go delete mode 100644 internal/cmd/registry/apis/versions/crtversion.go delete mode 100644 internal/cmd/registry/apis/versions/deleteversion.go delete mode 100644 internal/cmd/registry/apis/versions/getversion.go delete mode 100644 internal/cmd/registry/apis/versions/listversion.go delete mode 100644 internal/cmd/registry/apis/versions/specs/artifacts/artifacts.go delete mode 100644 internal/cmd/registry/apis/versions/specs/artifacts/crtartifact.go delete mode 100644 internal/cmd/registry/apis/versions/specs/artifacts/delartifact.go delete mode 100644 internal/cmd/registry/apis/versions/specs/artifacts/getartifact.go delete mode 100644 internal/cmd/registry/apis/versions/specs/artifacts/listartifacts.go delete mode 100644 internal/cmd/registry/apis/versions/specs/crtspec.go delete mode 100644 internal/cmd/registry/apis/versions/specs/delspec.go delete mode 100644 internal/cmd/registry/apis/versions/specs/getspec.go delete mode 100644 internal/cmd/registry/apis/versions/specs/listspecs.go delete mode 100644 internal/cmd/registry/apis/versions/specs/specs.go delete mode 100644 internal/cmd/registry/apis/versions/versions.go delete mode 100644 internal/cmd/registry/artifacts/artifacts.go delete mode 100644 internal/cmd/registry/artifacts/crtartifact.go delete mode 100644 internal/cmd/registry/artifacts/delartifact.go delete mode 100644 internal/cmd/registry/artifacts/getartifact.go delete mode 100644 internal/cmd/registry/artifacts/listartifact.go delete mode 100644 internal/cmd/registry/instances/crtinstance.go delete mode 100644 internal/cmd/registry/instances/delinstance.go delete mode 100644 internal/cmd/registry/instances/getinstance.go delete mode 100644 internal/cmd/registry/instances/instances.go delete mode 100644 internal/cmd/registry/registry.go diff --git a/internal/client/registry/apis/apis.go b/internal/client/registry/apis/apis.go deleted file mode 100644 index 07b1ada31..000000000 --- a/internal/client/registry/apis/apis.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2023 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 apis - -import ( - "net/url" - "path" - "strconv" - "strings" - - "internal/apiclient" -) - -// Create -func Create(apiID string, name string, displayName string, description string, - availability string, recommendedVersion string, recommendedDeployment string, - labels map[string]string, annotations map[string]string, -) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis") - q := u.Query() - q.Set("apiId", apiID) - u.RawQuery = q.Encode() - - apiContent := []string{} - apiContent = append(apiContent, "\"name\":"+"\""+name+"\"") - if displayName != "" { - apiContent = append(apiContent, "\"displayName\":"+"\""+displayName+"\"") - } - if description != "" { - apiContent = append(apiContent, "\"description\":"+"\""+description+"\"") - } - if availability != "" { - apiContent = append(apiContent, "\"availability\":"+"\""+availability+"\"") - } - if recommendedVersion != "" { - apiContent = append(apiContent, "\"recommendedVersion\":"+"\""+recommendedVersion+"\"") - } - if recommendedDeployment != "" { - apiContent = append(apiContent, "\"recommendedDeployment\":"+"\""+recommendedDeployment+"\"") - } - if len(labels) > 0 { - l := []string{} - for key, value := range labels { - l = append(l, "\""+key+"\":\""+value+"\"") - } - labelStr := "\"labels\":{" + strings.Join(l, ",") + "}" - apiContent = append(apiContent, labelStr) - } - - if len(annotations) > 0 { - a := []string{} - for key, value := range annotations { - a = append(a, "\""+key+"\":\""+value+"\"") - } - annotationStr := "\"annotations\":{" + strings.Join(a, ",") + "}" - apiContent = append(apiContent, annotationStr) - } - payload := "{" + strings.Join(apiContent, ",") + "}" - respBody, err = apiclient.HttpClient(u.String(), payload) - return respBody, err -} - -// Get -func Get(name string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", name) - respBody, err = apiclient.HttpClient(u.String()) - return respBody, err -} - -// Delete -func Delete(name string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", name) - respBody, err = apiclient.HttpClient(u.String(), "", "DELETE") - return respBody, err -} - -// List -func List(pageSize int, pageToken string, filter string, orderBy string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis") - q := u.Query() - if pageSize != -1 { - q.Set("pageSize", strconv.Itoa(pageSize)) - } - if pageToken != "" { - q.Set("pageToken", pageToken) - } - if filter != "" { - q.Set("filter", filter) - } - if orderBy != "" { - q.Set("orderBy", orderBy) - } - - u.RawQuery = q.Encode() - respBody, err = apiclient.HttpClient(u.String()) - return respBody, err -} diff --git a/internal/client/registry/apis/apis_test.go b/internal/client/registry/apis/apis_test.go deleted file mode 100644 index 9494eabb1..000000000 --- a/internal/client/registry/apis/apis_test.go +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2024 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 apis - -import ( - "testing" - - "internal/apiclient" - "internal/client/clienttest" -) - -func TestCreate(t *testing.T) { - name := "test" - displayName := "test" - description := "description" - recommendedVersion := "projects/my-project/locations/us-west1/apis/test/versions/1" - recommendedDeployment := "projects/my-project/locations/us-west1/apis/test/deployments/1" - labels := map[string]string{ - "key1": "value1", - } - annotations := map[string]string{ - "key1": "value1", - } - - if err := clienttest.TestSetup(clienttest.ENV_NOT_REQD, - clienttest.SITEID_NOT_REQD, clienttest.CLIPATH_NOT_REQD); err != nil { - t.Fatalf("%v", err) - } - if apiclient.GetRegion() == "" { - t.Fatalf("APIGEE_REGION not set") - } - if _, err := Create("id123", name, displayName, description, - "NONE", recommendedVersion, recommendedDeployment, labels, annotations); err != nil { - t.Fatalf("%v", err) - } -} - -func TestGet(t *testing.T) { - if err := clienttest.TestSetup(clienttest.ENV_NOT_REQD, - clienttest.SITEID_NOT_REQD, clienttest.CLIPATH_NOT_REQD); err != nil { - t.Fatalf("%v", err) - } - if apiclient.GetRegion() == "" { - t.Fatalf("APIGEE_REGION not set") - } - if _, err := Get("id123"); err != nil { - t.Fatalf("%v", err) - } -} - -func TestList(t *testing.T) { - if err := clienttest.TestSetup(clienttest.ENV_NOT_REQD, - clienttest.SITEID_NOT_REQD, clienttest.CLIPATH_NOT_REQD); err != nil { - t.Fatalf("%v", err) - } - if apiclient.GetRegion() == "" { - t.Fatalf("APIGEE_REGION not set") - } - if _, err := List(-1, "", "", ""); err != nil { - t.Fatalf("%v", err) - } -} - -func TestDelete(t *testing.T) { - if err := clienttest.TestSetup(clienttest.ENV_NOT_REQD, - clienttest.SITEID_NOT_REQD, clienttest.CLIPATH_NOT_REQD); err != nil { - t.Fatalf("%v", err) - } - if apiclient.GetRegion() == "" { - t.Fatalf("APIGEE_REGION not set") - } - if _, err := Delete("id123"); err != nil { - t.Fatalf("%v", err) - } -} diff --git a/internal/client/registry/apis/artifacts.go b/internal/client/registry/apis/artifacts.go deleted file mode 100644 index a2a0be47e..000000000 --- a/internal/client/registry/apis/artifacts.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2023 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 apis - -import ( - "net/url" - "path" - - "internal/apiclient" - "internal/client/registry/common" -) - -type Action uint8 - -const ( - CREATE Action = iota - UPDATE -) - -// CreateArtifact -func CreateArtifact(apiName string, artifactID string, name string, contents string, - labels map[string]string, annotations map[string]string, -) (respBody []byte, err error) { - return createOrReplace(apiName, artifactID, name, contents, labels, annotations, CREATE) -} - -// ReplaceArtifact -func ReplaceArtifact(apiName string, artifactID string, name string, contents string, - labels map[string]string, annotations map[string]string, -) (respBody []byte, err error) { - return createOrReplace(apiName, artifactID, name, contents, labels, annotations, UPDATE) -} - -// DeleteArtifact -func DeleteArtifact(apiName string, name string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "artifacts", name) - respBody, err = apiclient.HttpClient(u.String(), "", "DELETE") - return respBody, err -} - -// GetArtifact -func GetArtifact(apiName string, name string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "artifacts", name) - respBody, err = apiclient.HttpClient(u.String()) - return respBody, err -} - -// GetArtifactContents -func GetArtifactContents(apiName string, name string) (err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "artifacts", name+":getContents") - return apiclient.DownloadResource(u.String(), name+".txt", "", true) -} - -// ListArtifacts -func ListArtifacts(name string, pageSize int, pageToken string, filter string, orderBy string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", name, "artifacts") - return common.ListArtifacts(u, pageSize, pageToken, filter, orderBy) -} - -// createOrReplace -func createOrReplace(apiName string, artifactID string, name string, contents string, - labels map[string]string, annotations map[string]string, action Action, -) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - payload := common.GetArtifactPayload(name, contents, labels, annotations) - - if action == CREATE { - u.Path = path.Join(u.Path, "apis", apiName, "artifacts") - q := u.Query() - q.Set("artifactId", artifactID) - u.RawQuery = q.Encode() - respBody, err = apiclient.HttpClient(u.String(), payload) - } else { - u.Path = path.Join(u.Path, "apis", apiName, "artifacts", artifactID) - respBody, err = apiclient.HttpClient(u.String(), payload, "PUT") - } - return respBody, err -} diff --git a/internal/client/registry/apis/artifacts_test.go b/internal/client/registry/apis/artifacts_test.go deleted file mode 100644 index 1f269bc05..000000000 --- a/internal/client/registry/apis/artifacts_test.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2024 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 apis - -import ( - "encoding/base64" - "os" - "path" - "testing" - - "internal/apiclient" - "internal/client/clienttest" - "internal/cmd/utils" -) - -var cliPath = os.Getenv("APIGEECLI_PATH") - -func TestCreateArtifact(t *testing.T) { - name := "test" - displayName := "test" - description := "description" - recommendedVersion := "projects/my-project/locations/us-west1/apis/test/versions/1" - recommendedDeployment := "projects/my-project/locations/us-west1/apis/test/deployments/1" - labels := map[string]string{ - "key1": "value1", - } - annotations := map[string]string{ - "key1": "value1", - } - payload, err := utils.ReadFile(path.Join(cliPath, "test", "openapi.json")) - if err != nil { - t.Fatalf("%v", err) - } - contents := base64.StdEncoding.EncodeToString(payload) - - if err := clienttest.TestSetup(clienttest.ENV_NOT_REQD, - clienttest.SITEID_NOT_REQD, clienttest.CLIPATH_NOT_REQD); err != nil { - t.Fatalf("%v", err) - } - if apiclient.GetRegion() == "" { - t.Fatalf("APIGEE_REGION not set") - } - if _, err := Create("id123", name, displayName, description, - "NONE", recommendedVersion, recommendedDeployment, labels, annotations); err != nil { - t.Fatalf("%v", err) - } - if _, err := CreateArtifact(name, "id123", name, contents, labels, annotations); err != nil { - t.Fatalf("%v", err) - } -} diff --git a/internal/client/registry/apis/deployments.go b/internal/client/registry/apis/deployments.go deleted file mode 100644 index d228ca681..000000000 --- a/internal/client/registry/apis/deployments.go +++ /dev/null @@ -1,176 +0,0 @@ -// Copyright 2023 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 apis - -import ( - "net/url" - "path" - "strconv" - "strings" - - "internal/apiclient" -) - -// CreateDeployment -func CreateDeployment(apiDeploymentID string, name string, displayName string, description string, - apiSpecRevision string, endpointURI string, externalChannelURI string, intendedAudience string, - accessGuidance string, labels map[string]string, annotations map[string]string, -) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiDeploymentID, "deployments") - q := u.Query() - q.Set("apiDeploymentId", name) - u.RawQuery = q.Encode() - apiDeployment := []string{} - apiDeployment = append(apiDeployment, "\"name\":"+"\""+name+"\"") - if displayName != "" { - apiDeployment = append(apiDeployment, "\"displayName\":"+"\""+displayName+"\"") - } - if description != "" { - apiDeployment = append(apiDeployment, "\"description\":"+"\""+description+"\"") - } - if apiSpecRevision != "" { - apiDeployment = append(apiDeployment, "\"apiSpecRevision\":"+"\""+apiSpecRevision+"\"") - } - if endpointURI != "" { - apiDeployment = append(apiDeployment, "\"endpointUri\":"+"\""+endpointURI+"\"") - } - if externalChannelURI != "" { - apiDeployment = append(apiDeployment, "\"externalChannelUri\":"+"\""+externalChannelURI+"\"") - } - if intendedAudience != "" { - apiDeployment = append(apiDeployment, "\"intendedAudience\":"+"\""+intendedAudience+"\"") - } - if accessGuidance != "" { - apiDeployment = append(apiDeployment, "\"accessGuidance\":"+"\""+accessGuidance+"\"") - } - if len(labels) > 0 { - l := []string{} - for key, value := range labels { - l = append(l, "\""+key+"\":\""+value+"\"") - } - labelStr := "\"labels\":{" + strings.Join(l, ",") + "}" - apiDeployment = append(apiDeployment, labelStr) - } - - if len(annotations) > 0 { - a := []string{} - for key, value := range annotations { - a = append(a, "\""+key+"\":\""+value+"\"") - } - annotationStr := "\"annotations\":{" + strings.Join(a, ",") + "}" - apiDeployment = append(apiDeployment, annotationStr) - } - payload := "{" + strings.Join(apiDeployment, ",") + "}" - respBody, err = apiclient.HttpClient(u.String(), payload) - return respBody, err -} - -// Tag -func Tag(name string, deployment string, tag string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", name, "deployments", deployment+":tagRevision") - payload := "{\"tag\":\"" + tag + "\"}" - respBody, err = apiclient.HttpClient(u.String(), payload) - return respBody, err -} - -// Rollback -func Rollback(name string, deployment string, revisionID string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", name, "deployments", deployment+":rollback") - payload := "{\"revisionId\":\"" + revisionID + "\"}" - respBody, err = apiclient.HttpClient(u.String(), payload) - return respBody, err -} - -// DeleteDeployment -func DeleteDeployment(name string, deployment string, force bool) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", name, "deployments", deployment) - if force { - q := u.Query() - q.Set("force", strconv.FormatBool(force)) - u.RawQuery = q.Encode() - } - respBody, err = apiclient.HttpClient(u.String(), "", "DELETE") - return respBody, err -} - -// DeleteDeploymentRevision -func DeleteDeploymentRevision(name string, deployment string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", name, "deployments", deployment+":deleteRevision") - respBody, err = apiclient.HttpClient(u.String(), "", "DELETE") - return respBody, err -} - -// GetDeployment -func GetDeployment(name string, deployment string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", name, "deployments", deployment) - respBody, err = apiclient.HttpClient(u.String()) - return respBody, err -} - -// ListDeploymentRevisions -func ListDeploymentRevisions(apiName string, name string, pageSize int, pageToken string, - filter string, orderBy string, -) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "deployments", name+":listRevisions") - q := u.Query() - if pageSize != -1 { - q.Set("pageSize", strconv.Itoa(pageSize)) - } - if pageToken != "" { - q.Set("pageToken", pageToken) - } - if filter != "" { - q.Set("filter", filter) - } - if orderBy != "" { - q.Set("orderBy", orderBy) - } - - u.RawQuery = q.Encode() - respBody, err = apiclient.HttpClient(u.String()) - return respBody, err -} - -// ListDeployments -func ListDeployments(name string, pageSize int, pageToken string, - filter string, orderBy string, -) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", name, "deployments") - q := u.Query() - if pageSize != -1 { - q.Set("pageSize", strconv.Itoa(pageSize)) - } - if pageToken != "" { - q.Set("pageToken", pageToken) - } - if filter != "" { - q.Set("filter", filter) - } - if orderBy != "" { - q.Set("orderBy", orderBy) - } - - u.RawQuery = q.Encode() - respBody, err = apiclient.HttpClient(u.String()) - return respBody, err -} diff --git a/internal/client/registry/apis/deployments/artifacts.go b/internal/client/registry/apis/deployments/artifacts.go deleted file mode 100644 index 30f580180..000000000 --- a/internal/client/registry/apis/deployments/artifacts.go +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2023 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 deployments - -import ( - "net/url" - "path" - - "internal/apiclient" - "internal/client/registry/common" -) - -type Action uint8 - -const ( - CREATE Action = iota - UPDATE -) - -// CreateArtifact -func CreateArtifact(apiName string, deploymentName string, artifactID string, name string, contents string, - labels map[string]string, annotations map[string]string, -) (respBody []byte, err error) { - createOrReplace(apiName, deploymentName, artifactID, name, contents, labels, annotations, CREATE) -} - -// ReplaceArtifact -func ReplaceArtifact(apiName string, deploymentName string, artifactID string, name string, contents string, - labels map[string]string, annotations map[string]string, -) (respBody []byte, err error) { - return createOrReplace(apiName, deploymentName, artifactID, name, contents, labels, annotations, UPDATE) -} - -// DeleteArtifact -func DeleteArtifact(apiName string, deploymentName string, name string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "deployments", deploymentName, "artifacts", name) - respBody, err = apiclient.HttpClient(u.String(), "", "DELETE") - return respBody, err -} - -// GetArtifact -func GetArtifact(apiName string, deploymentName string, name string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "deployments", deploymentName, "artifacts", name) - respBody, err = apiclient.HttpClient(u.String()) - return respBody, err -} - -// GetArtifactContents -func GetArtifactContents(apiName string, deploymentName string, name string) (err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "deployments", deploymentName, "artifacts", name+":getContents") - return apiclient.DownloadResource(u.String(), name+".txt", "", true) -} - -// ListArtifacts -func ListArtifacts(apiName string, deploymentName string, pageSize int, - pageToken string, filter string, orderBy string, -) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "deployments", deploymentName, "artifacts") - return common.ListArtifacts(u, pageSize, pageToken, filter, orderBy) -} - -func createOrReplace(apiName string, deploymentName string, artifactID string, name string, contents string, - labels map[string]string, annotations map[string]string, action Action, -) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - payload := common.GetArtifactPayload(name, contents, labels, annotations) - - if action == CREATE { - u.Path = path.Join(u.Path, "apis", apiName, "deployments", deploymentName, "artifacts") - q := u.Query() - q.Set("artifactId", artifactID) - u.RawQuery = q.Encode() - respBody, err = apiclient.HttpClient(u.String(), payload) - } else { - u.Path = path.Join(u.Path, "apis", apiName, "deployments", deploymentName, "artifacts", artifactID) - respBody, err = apiclient.HttpClient(u.String(), payload, "PUT") - } - return respBody, err -} diff --git a/internal/client/registry/apis/versions.go b/internal/client/registry/apis/versions.go deleted file mode 100644 index 5f285f511..000000000 --- a/internal/client/registry/apis/versions.go +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright 2023 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 apis - -import ( - "net/url" - "path" - "strconv" - "strings" - - "internal/apiclient" -) - -// CreateVersion -func CreateVersion(apiVersionId string, name string, displayName string, - description string, state string, labels map[string]string, - annotations map[string]string, primarySpec string, -) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", name, "versions") - apiVersionContent := []string{} - apiVersionContent = append(apiVersionContent, "\"name\":"+"\""+name+"\"") - if displayName != "" { - apiVersionContent = append(apiVersionContent, "\"displayName\":"+"\""+displayName+"\"") - } - if description != "" { - apiVersionContent = append(apiVersionContent, "\"description\":"+"\""+description+"\"") - } - if state != "" { - apiVersionContent = append(apiVersionContent, "\"state\":"+"\""+state+"\"") - } - if len(labels) > 0 { - l := []string{} - for key, value := range labels { - l = append(l, "\""+key+"\":\""+value+"\"") - } - labelStr := "\"labels\":{" + strings.Join(l, ",") + "}" - apiVersionContent = append(apiVersionContent, labelStr) - } - - if len(annotations) > 0 { - a := []string{} - for key, value := range annotations { - a = append(a, "\""+key+"\":\""+value+"\"") - } - annotationStr := "\"annotations\":{" + strings.Join(a, ",") + "}" - apiVersionContent = append(apiVersionContent, annotationStr) - } - payload := "{" + strings.Join(apiVersionContent, ",") + "}" - - q := u.Query() - q.Set("apiVersionId", apiVersionId) - u.RawQuery = q.Encode() - - respBody, err = apiclient.HttpClient(u.String(), payload) - return respBody, err -} - -// GetVersion -func GetVersion(name string, version string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", name, "versions", version) - respBody, err = apiclient.HttpClient(u.String()) - return respBody, err -} - -// DeleteVersion -func DeleteVersion(name string, version string, force bool) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", name, "versions", version) - if force { - q := u.Query() - q.Set("force", strconv.FormatBool(force)) - u.RawQuery = q.Encode() - } - respBody, err = apiclient.HttpClient(u.String(), "", "DELETE") - return respBody, err -} - -// ListVersions -func ListVersions(name string, pageSize int, pageToken string, - filter string, orderBy string, -) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", name, "versions") - q := u.Query() - if pageSize != -1 { - q.Set("pageSize", strconv.Itoa(pageSize)) - } - if pageToken != "" { - q.Set("pageToken", pageToken) - } - if filter != "" { - q.Set("filter", filter) - } - if orderBy != "" { - q.Set("orderBy", orderBy) - } - - u.RawQuery = q.Encode() - respBody, err = apiclient.HttpClient(u.String()) - return respBody, err -} diff --git a/internal/client/registry/apis/versions/artifacts.go b/internal/client/registry/apis/versions/artifacts.go deleted file mode 100644 index c73d8e419..000000000 --- a/internal/client/registry/apis/versions/artifacts.go +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2023 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 versions - -import ( - "net/url" - "path" - - "internal/apiclient" - "internal/client/registry/common" -) - -type Action uint8 - -const ( - CREATE Action = iota - UPDATE -) - -// CreateArtifact -func CreateArtifact(apiName string, apiVersion string, artifactID string, name string, contents string, - labels map[string]string, annotations map[string]string, -) (respBody []byte, err error) { - return createOrReplaceArtifact(apiName, apiVersion, artifactID, name, contents, labels, annotations, CREATE) -} - -// ReaplceArtifact -func ReplaceArtifact(apiName string, apiVersion string, artifactID string, name string, contents string, - labels map[string]string, annotations map[string]string, -) (respBody []byte, err error) { - return createOrReplaceArtifact(apiName, apiVersion, artifactID, name, contents, labels, annotations, UPDATE) -} - -// DeleteArtifact -func DeleteArtifact(apiName string, apiVersion string, name string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, "artifacts", name) - respBody, err = apiclient.HttpClient(u.String(), "", "DELETE") - return respBody, err -} - -// GetArtifact -func GetArtifact(apiName string, apiVersion string, name string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, "artifacts", name) - respBody, err = apiclient.HttpClient(u.String()) - return respBody, err -} - -// GetArtifactContents -func GetArtifactContents(apiName string, apiVersion string, name string) (err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, "artifacts", name+":getContents") - return apiclient.DownloadResource(u.String(), name+".txt", "", true) -} - -// ListArtifacts -func ListArtifacts(apiName string, apiVersion string, pageSize int, - pageToken string, filter string, orderBy string, -) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, "artifacts") - return common.ListArtifacts(u, pageSize, pageToken, filter, orderBy) -} - -func createOrReplaceArtifact(apiName, apiVersion, artifactID string, name string, contents string, - labels map[string]string, annotations map[string]string, action Action, -) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - payload := common.GetArtifactPayload(name, contents, labels, annotations) - - if action == CREATE { - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, "artifacts") - q := u.Query() - q.Set("artifactId", artifactID) - u.RawQuery = q.Encode() - respBody, err = apiclient.HttpClient(u.String(), payload) - } else { - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, "artifacts", artifactID) - respBody, err = apiclient.HttpClient(u.String(), payload, "PUT") - } - return respBody, err -} diff --git a/internal/client/registry/apis/versions/specartifacts.go b/internal/client/registry/apis/versions/specartifacts.go deleted file mode 100644 index 67ed4679b..000000000 --- a/internal/client/registry/apis/versions/specartifacts.go +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright 2023 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 versions - -import ( - "net/url" - "path" - - "internal/apiclient" - "internal/client/registry/common" -) - -// CreateSpecArtifact -func CreateSpecArtifact(apiName string, apiVersion string, specName string, artifactId string, - name string, contents string, labels map[string]string, - annotations map[string]string, -) (respBody []byte, err error) { - return createOrReplaceSpecArtifact(apiName, apiVersion, specName, artifactId, name, contents, labels, annotations, CREATE) -} - -// ReplaceSpecArtifact -func ReplaceSpecArtifact(apiName string, apiVersion string, specName string, artifactId string, - name string, contents string, labels map[string]string, - annotations map[string]string, -) (respBody []byte, err error) { - return createOrReplaceSpecArtifact(apiName, apiVersion, specName, artifactId, name, contents, labels, annotations, UPDATE) -} - -// DeleteSpecArtifact -func DeleteSpecArtifact(apiName string, apiVersion string, specName string, - name string, -) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, "specs", - specName, "artifacts", name) - respBody, err = apiclient.HttpClient(u.String(), "", "DELETE") - return respBody, err -} - -// GetSpecArtifact -func GetSpecArtifact(apiName string, apiVersion string, specName string, - name string, -) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, "specs", - specName, "artifacts", name) - respBody, err = apiclient.HttpClient(u.String()) - return respBody, err -} - -// GetSpecArtifactContents -func GetSpecArtifactContents(apiName string, apiVersion string, specName string, - name string, -) (err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, - "specs", specName, "artifacts", name+":getContents") - return apiclient.DownloadResource(u.String(), name+".txt", "", true) -} - -// ListSpecArtifacts -func ListSpecArtifacts(apiName string, apiVersion string, specName string, pageSize int, - pageToken string, filter string, orderBy string, -) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, "specs", - specName, "artifacts") - return common.ListArtifacts(u, pageSize, pageToken, filter, orderBy) -} - -func createOrReplaceSpecArtifact(apiName string, apiVersion string, specName string, artifactID string, - name string, contents string, labels map[string]string, - annotations map[string]string, action Action, -) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - payload := common.GetArtifactPayload(name, contents, labels, annotations) - if action == CREATE { - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, "specs", specName, "artifacts") - q := u.Query() - q.Set("artifactId", artifactID) - u.RawQuery = q.Encode() - respBody, err = apiclient.HttpClient(u.String(), payload) - } else { - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, "specs", specName, "artifacts", artifactID) - respBody, err = apiclient.HttpClient(u.String(), payload, "PUT") - } - return respBody, err -} diff --git a/internal/client/registry/apis/versions/specs.go b/internal/client/registry/apis/versions/specs.go deleted file mode 100644 index 9b234dd73..000000000 --- a/internal/client/registry/apis/versions/specs.go +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright 2023 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 versions - -import ( - "encoding/json" - "fmt" - "net/url" - "path" - "strconv" - "strings" - - "internal/apiclient" -) - -// CreateSpec -func CreateSpec(apiName string, apiVersion string, apiSpecId string, name string, fileName string, - description string, sourceURI string, contents string, labels map[string]string, - annotations map[string]string, -) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, "specs") - q := u.Query() - q.Set("apiSpecId", apiSpecId) - u.RawQuery = q.Encode() - - specContent := []string{} - specContent = append(specContent, "\"name\":"+"\""+name+"\"") - if description != "" { - specContent = append(specContent, "\"description\":"+"\""+description+"\"") - } - if fileName != "" { - specContent = append(specContent, "\"filename\":"+"\""+fileName+"\"") - } - if sourceURI != "" { - specContent = append(specContent, "\"sourceUri\":"+"\""+sourceURI+"\"") - } - if contents != "" { - specContent = append(specContent, "\"contents\":"+"\""+contents+"\"") - } - if len(labels) > 0 { - l := []string{} - for key, value := range labels { - l = append(l, "\""+key+"\":\""+value+"\"") - } - labelStr := "\"labels\":{" + strings.Join(l, ",") + "}" - specContent = append(specContent, labelStr) - } - - if len(annotations) > 0 { - a := []string{} - for key, value := range annotations { - a = append(a, "\""+key+"\":\""+value+"\"") - } - annotationStr := "\"annotations\":{" + strings.Join(a, ",") + "}" - specContent = append(specContent, annotationStr) - } - payload := "{" + strings.Join(specContent, ",") + "}" - respBody, err = apiclient.HttpClient(u.String(), payload) - return respBody, err -} - -// TagSpec -func TagSpec(apiName string, apiVersion string, name string, tag string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, "specs", name+":tagRevision") - payload := "{\"tag\":\"" + tag + "\"}" - respBody, err = apiclient.HttpClient(u.String(), payload) - return respBody, err -} - -// RollbackSpec -func RollbackSpec(apiName string, apiVersion string, name string, revisionID string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, "specs", name+":rollback") - payload := "{\"revisionId\":\"" + revisionID + "\"}" - respBody, err = apiclient.HttpClient(u.String(), payload) - return respBody, err -} - -// DeleteSpec -func DeleteSpec(apiName string, apiVersion string, name string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, "specs", name) - respBody, err = apiclient.HttpClient(u.String(), "", "DELETE") - return respBody, err -} - -// DeleteSpecRevision -func DeleteSpecRevision(apiName string, apiVersion string, name string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, "specs", name+":deleteRevision") - respBody, err = apiclient.HttpClient(u.String(), "", "DELETE") - return respBody, err -} - -// GetSpec -func GetSpec(apiName string, apiVersion string, name string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, "specs", name) - respBody, err = apiclient.HttpClient(u.String()) - return respBody, err -} - -// GetSpecContents -func GetSpecContents(apiName string, apiVersion string, name string) (err error) { - apiclient.ClientPrintHttpResponse.Set(false) - var specMap map[string]interface{} - var specFileName string - respBody, err := GetSpec(apiName, apiVersion, name) - if err != nil { - return err - } - err = json.Unmarshal(respBody, &specMap) - if err != nil { - return err - } - if specMap["filename"] != "" { - specFileName = fmt.Sprintf("%s", specMap["filename"]) - } else { - specFileName = name + ".txt" - } - apiclient.ClientPrintHttpResponse.Set(apiclient.GetCmdPrintHttpResponseSetting()) - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, "specs", name+":getContents") - return apiclient.DownloadResource(u.String(), specFileName, "", true) -} - -// ListSpecs -func ListSpecs(apiName string, apiVersion string, pageSize int, - pageToken string, filter string, orderBy string, -) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "apis", apiName, "versions", apiVersion, "specs") - q := u.Query() - if pageSize != -1 { - q.Set("pageSize", strconv.Itoa(pageSize)) - } - if pageToken != "" { - q.Set("pageToken", pageToken) - } - if filter != "" { - q.Set("filter", filter) - } - if orderBy != "" { - q.Set("orderBy", orderBy) - } - - u.RawQuery = q.Encode() - respBody, err = apiclient.HttpClient(u.String()) - return respBody, err -} diff --git a/internal/client/registry/artifacts/artifacts.go b/internal/client/registry/artifacts/artifacts.go deleted file mode 100644 index 23770d940..000000000 --- a/internal/client/registry/artifacts/artifacts.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "net/url" - "path" - - "internal/apiclient" - "internal/client/registry/common" -) - -type Action uint8 - -const ( - CREATE Action = iota - UPDATE -) - -// Create -func Create(artifactID string, name string, contents string, - labels map[string]string, annotations map[string]string, -) (respBody []byte, err error) { - return createOrReplace(artifactID, name, contents, labels, annotations, CREATE) -} - -// Delete -func Delete(name string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "artifacts", name) - respBody, err = apiclient.HttpClient(u.String(), "", "DELETE") - return respBody, err -} - -// Get -func Get(name string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "artifacts", name) - respBody, err = apiclient.HttpClient(u.String()) - return respBody, err -} - -// GetContents -func GetContents(name string) (err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "artifacts", name+":getContents") - return apiclient.DownloadResource(u.String(), name+".txt", "", true) -} - -// List -func List(pageSize int, pageToken string, filter string, orderBy string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "artifacts") - return common.ListArtifacts(u, pageSize, pageToken, filter, orderBy) -} - -// Replace -func Replace(artifactID string, name string, contents string, - labels map[string]string, annotations map[string]string, -) (respBody []byte, err error) { - return createOrReplace(artifactID, name, contents, labels, annotations, UPDATE) -} - -// createOrReplace -func createOrReplace(artifactID string, name string, contents string, - labels map[string]string, annotations map[string]string, action Action, -) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - payload := common.GetArtifactPayload(name, contents, labels, annotations) - - if action == CREATE { - u.Path = path.Join(u.Path, "artifacts") - q := u.Query() - q.Set("artifactId", artifactID) - u.RawQuery = q.Encode() - respBody, err = apiclient.HttpClient(u.String(), payload) - } else { - u.Path = path.Join(u.Path, "artifacts", artifactID) - respBody, err = apiclient.HttpClient(u.String(), payload, "PUT") - } - return respBody, err -} diff --git a/internal/client/registry/artifacts/artifacts_test.go b/internal/client/registry/artifacts/artifacts_test.go deleted file mode 100644 index 88e848eb3..000000000 --- a/internal/client/registry/artifacts/artifacts_test.go +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2024 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 artifacts - -import ( - "encoding/base64" - "os" - "path" - "testing" - - "internal/apiclient" - "internal/client/clienttest" - "internal/cmd/utils" -) - -var cliPath = os.Getenv("APIGEECLI_PATH") - -func TestCreate(t *testing.T) { - artifactID := "test" - name := "test" - if err := clienttest.TestSetup(clienttest.ENV_NOT_REQD, - clienttest.SITEID_NOT_REQD, clienttest.CLIPATH_REQD); err != nil { - t.Fatalf("%v", err) - } - if apiclient.GetRegion() == "" { - t.Fatalf("APIGEE_REGION not set") - } - payload, err := utils.ReadFile(path.Join(cliPath, "test", "openapi.json")) - if err != nil { - t.Fatalf("%v", err) - } - contents := base64.StdEncoding.EncodeToString(payload) - labels := map[string]string{ - "test": "test", - } - annotations := map[string]string{ - "test": "test", - } - if _, err := Create(artifactID, name, string(contents), labels, annotations); err != nil { - t.Fatalf("%v", err) - } -} - -func TestGet(t *testing.T) { - if err := clienttest.TestSetup(clienttest.ENV_NOT_REQD, - clienttest.SITEID_NOT_REQD, clienttest.CLIPATH_NOT_REQD); err != nil { - t.Fatalf("%v", err) - } - if apiclient.GetRegion() == "" { - t.Fatalf("APIGEE_REGION not set") - } - if _, err := Get("test"); err != nil { - t.Fatalf("%v", err) - } -} - -func TestGetContents(t *testing.T) { - if err := clienttest.TestSetup(clienttest.ENV_NOT_REQD, - clienttest.SITEID_NOT_REQD, clienttest.CLIPATH_NOT_REQD); err != nil { - t.Fatalf("%v", err) - } - if apiclient.GetRegion() == "" { - t.Fatalf("APIGEE_REGION not set") - } - if err := GetContents("test"); err != nil { - t.Fatalf("%v", err) - } -} - -func TestList(t *testing.T) { - if err := clienttest.TestSetup(clienttest.ENV_NOT_REQD, - clienttest.SITEID_NOT_REQD, clienttest.CLIPATH_NOT_REQD); err != nil { - t.Fatalf("%v", err) - } - if apiclient.GetRegion() == "" { - t.Fatalf("APIGEE_REGION not set") - } - if _, err := List(-1, "", "", ""); err != nil { - t.Fatalf("%v", err) - } -} - -func TestReplace(t *testing.T) { - artifactID := "test" - name := "test" - if err := clienttest.TestSetup(clienttest.ENV_NOT_REQD, - clienttest.SITEID_NOT_REQD, clienttest.CLIPATH_REQD); err != nil { - t.Fatalf("%v", err) - } - if apiclient.GetRegion() == "" { - t.Fatalf("APIGEE_REGION not set") - } - payload, err := utils.ReadFile(path.Join(cliPath, "test", "openapi.json")) - if err != nil { - t.Fatalf("%v", err) - } - contents := base64.StdEncoding.EncodeToString(payload) - labels := map[string]string{ - "test": "test", - } - annotations := map[string]string{ - "test": "test", - } - if _, err := Replace(artifactID, name, string(contents), labels, annotations); err != nil { - t.Fatalf("%v", err) - } -} - -func TestDelete(t *testing.T) { - if err := clienttest.TestSetup(clienttest.ENV_NOT_REQD, - clienttest.SITEID_NOT_REQD, clienttest.CLIPATH_NOT_REQD); err != nil { - t.Fatalf("%v", err) - } - if apiclient.GetRegion() == "" { - t.Fatalf("APIGEE_REGION not set") - } - if _, err := Delete("test"); err != nil { - t.Fatalf("%v", err) - } -} diff --git a/internal/client/registry/common/common.go b/internal/client/registry/common/common.go deleted file mode 100644 index 32e868744..000000000 --- a/internal/client/registry/common/common.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2023 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 common - -import ( - "net/url" - "strconv" - "strings" - - "internal/apiclient" -) - -// GetArtifactPayload -func GetArtifactPayload(name string, contents string, labels map[string]string, annotations map[string]string) string { - artifact := []string{} - artifact = append(artifact, "\"name\":"+"\""+name+"\"") - artifact = append(artifact, "\"contents\":"+"\""+contents+"\"") - - if len(labels) > 0 { - l := []string{} - for key, value := range labels { - l = append(l, "\""+key+"\":\""+value+"\"") - } - labelStr := "\"labels\":{" + strings.Join(l, ",") + "}" - artifact = append(artifact, labelStr) - } - - if len(annotations) > 0 { - a := []string{} - for key, value := range annotations { - a = append(a, "\""+key+"\":\""+value+"\"") - } - annotationStr := "\"annotations\":{" + strings.Join(a, ",") + "}" - artifact = append(artifact, annotationStr) - } - - payload := "{" + strings.Join(artifact, ",") + "}" - return payload -} - -// ListArtifacts -func ListArtifacts(u *url.URL, pageSize int, - pageToken string, filter string, orderBy string, -) (respBody []byte, err error) { - q := u.Query() - if pageSize != -1 { - q.Set("pageSize", strconv.Itoa(pageSize)) - } - if pageToken != "" { - q.Set("pageToken", pageToken) - } - if filter != "" { - q.Set("filter", filter) - } - if orderBy != "" { - q.Set("orderBy", orderBy) - } - - u.RawQuery = q.Encode() - respBody, err = apiclient.HttpClient(u.String()) - return respBody, err -} diff --git a/internal/client/registry/instances/instances.go b/internal/client/registry/instances/instances.go deleted file mode 100644 index 6ce42637b..000000000 --- a/internal/client/registry/instances/instances.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2023 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 instances - -import ( - "fmt" - "net/url" - "path" - "strings" - - "internal/apiclient" -) - -// Create -func Create(cmekName string) (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "instances") - q := u.Query() - q.Set("instanceId", "default") - u.RawQuery = q.Encode() - - instance := []string{} - config := []string{} - - name := fmt.Sprintf("projects/%s/locations/%s/instance", apiclient.GetProjectID(), apiclient.GetRegistryRegion()) - instance = append(instance, "\"name\":"+"\""+name+"\"") - - config = append(config, "\"cmekKeyName\":"+"\""+cmekName+"\"") - configJson := "{" + strings.Join(config, ",") + "}" - instance = append(instance, "\"config\":"+configJson) - - payload := "{" + strings.Join(instance, ",") + "}" - respBody, err = apiclient.HttpClient(u.String(), payload) - return respBody, err -} - -// Delete -func Delete() (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "instances", "default") - respBody, err = apiclient.HttpClient(u.String(), "", "DELETE") - return respBody, err -} - -// Get -func Get() (respBody []byte, err error) { - u, _ := url.Parse(apiclient.GetApigeeRegistryURL()) - u.Path = path.Join(u.Path, "instances", "default") - respBody, err = apiclient.HttpClient(u.String()) - return respBody, err -} diff --git a/internal/cmd/registry/apis/apis.go b/internal/cmd/registry/apis/apis.go deleted file mode 100644 index 4c94e42e3..000000000 --- a/internal/cmd/registry/apis/apis.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2023 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 apis - -import ( - "internal/cmd/registry/apis/artifacts" - "internal/cmd/registry/apis/deployments" - "internal/cmd/registry/apis/versions" - - "github.com/spf13/cobra" -) - -// APICmd to manage apis -var APICmd = &cobra.Command{ - Use: "apis", - Short: "Manage APIs in Apigee Registry", - Long: "Manage APIs in Apigee Registry", -} - -var ( - name string - labels, annotations map[string]string -) - -func init() { - APICmd.AddCommand(CreateAPICmd) - APICmd.AddCommand(GetAPICmd) - APICmd.AddCommand(DelAPICmd) - APICmd.AddCommand(ListAPICmd) - APICmd.AddCommand(deployments.APIDeploymentCmd) - APICmd.AddCommand(versions.APIVersionCmd) - APICmd.AddCommand(artifacts.APIArtifactCmd) -} diff --git a/internal/cmd/registry/apis/artifacts/artifacts.go b/internal/cmd/registry/apis/artifacts/artifacts.go deleted file mode 100644 index 676d905e6..000000000 --- a/internal/cmd/registry/apis/artifacts/artifacts.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "github.com/spf13/cobra" -) - -// APIArtifactCmd to manage apis -var APIArtifactCmd = &cobra.Command{ - Use: "artifacts", - Short: "Manage artifacts for an API", - Long: "Manage artifacts for an API in Apigee Registry", -} - -func init() { - APIArtifactCmd.AddCommand(ListAPIArtifactCmd) - APIArtifactCmd.AddCommand(CreateArtifactCmd) - APIArtifactCmd.AddCommand(DelArtifactCmd) - APIArtifactCmd.AddCommand(GetArtifactCmd) -} diff --git a/internal/cmd/registry/apis/artifacts/crtartifact.go b/internal/cmd/registry/apis/artifacts/crtartifact.go deleted file mode 100644 index ec97a9e07..000000000 --- a/internal/cmd/registry/apis/artifacts/crtartifact.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "encoding/base64" - - "internal/apiclient" - "internal/client/registry/apis" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// CreateArtifactCmd to create a new instance -var CreateArtifactCmd = &cobra.Command{ - Use: "create", - Short: "Create an artifact for an API", - Long: "Create an artifact for an API Apigee Registry Instance", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - var payload []byte - if payload, err = utils.ReadFile(contentsFile); err != nil { - return err - } - contents := base64.StdEncoding.EncodeToString(payload) - _, err = apis.CreateArtifact(apiName, artifactID, name, contents, labels, annotations) - return err - }, -} - -var ( - name, artifactID, contentsFile string - labels, annotations map[string]string -) - -func init() { - CreateArtifactCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "Apigee Registry API Name") - CreateArtifactCmd.Flags().StringVarP(&artifactID, "id", "i", - "", "Apigee Registry Artifact ID") - CreateArtifactCmd.Flags().StringVarP(&name, "name", "n", - "", "Name of the Artifact") - CreateArtifactCmd.Flags().StringVarP(&contentsFile, "file", "f", - "", "Path to a file containing Artifact Contents") - CreateArtifactCmd.Flags().StringToStringVar(&labels, "labels", - nil, "Labels attach identifying metadata to resources") - CreateArtifactCmd.Flags().StringToStringVar(&annotations, "annotations", - nil, "Annotations attach non-identifying metadata to resources") - - _ = CreateArtifactCmd.MarkFlagRequired("id") - _ = CreateArtifactCmd.MarkFlagRequired("name") - _ = CreateArtifactCmd.MarkFlagRequired("file") -} diff --git a/internal/cmd/registry/apis/artifacts/delartifact.go b/internal/cmd/registry/apis/artifacts/delartifact.go deleted file mode 100644 index 3ac1b9dc2..000000000 --- a/internal/cmd/registry/apis/artifacts/delartifact.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "internal/apiclient" - - "internal/client/registry/apis" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// DelArtifactCmd to get instance -var DelArtifactCmd = &cobra.Command{ - Use: "delete", - Short: "Delete artifact for an API from Apigee Registry", - Long: "Delete artifact for an API from Apigee Registry", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = apis.DeleteArtifact(apiName, name) - return - }, -} -var apiName string - -func init() { - DelArtifactCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "API Name") - DelArtifactCmd.Flags().StringVarP(&name, "name", "n", - "", "Artifact Name") - - _ = DelArtifactCmd.MarkFlagRequired("api-name") - _ = DelArtifactCmd.MarkFlagRequired("name") -} diff --git a/internal/cmd/registry/apis/artifacts/getartifact.go b/internal/cmd/registry/apis/artifacts/getartifact.go deleted file mode 100644 index 45fa183fc..000000000 --- a/internal/cmd/registry/apis/artifacts/getartifact.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "internal/apiclient" - - "internal/client/registry/apis" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// GetArtifactCmd to get instance -var GetArtifactCmd = &cobra.Command{ - Use: "get", - Short: "Get Artifact details for an API", - Long: "Get Artifact details for an API", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - if content { - return apis.GetArtifactContents(apiName, name) - } - _, err = apis.GetArtifact(apiName, name) - return - }, -} - -var content bool - -func init() { - GetArtifactCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "Apigee Registry API Name") - GetArtifactCmd.Flags().StringVarP(&name, "name", "n", - "", "Artifact Name") - GetArtifactCmd.Flags().BoolVarP(&content, "content", "c", - false, "If set to true, returns artifact contents") - - _ = GetArtifactCmd.MarkFlagRequired("api-name") - _ = GetArtifactCmd.MarkFlagRequired("name") -} diff --git a/internal/cmd/registry/apis/artifacts/listartifacts.go b/internal/cmd/registry/apis/artifacts/listartifacts.go deleted file mode 100644 index 1c3af98b1..000000000 --- a/internal/cmd/registry/apis/artifacts/listartifacts.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "internal/apiclient" - - "internal/client/registry/apis" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// ListAPIArtifactCmd to get instance -var ListAPIArtifactCmd = &cobra.Command{ - Use: "list", - Short: "List all artifacts for an API", - Long: "List all artifacts for an API in Apigee Registry", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = apis.ListArtifacts(apiName, pageSize, pageToken, filter, orderBy) - return - }, -} - -var ( - pageToken, filter, orderBy string - pageSize int -) - -func init() { - ListAPIArtifactCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "Apigee Registry API Name") - ListAPIArtifactCmd.Flags().StringVarP(&pageToken, "page-token", "", - "", "A page token, received from a previous list call") - ListAPIArtifactCmd.Flags().StringVarP(&filter, "filter", "", - "", "An expression that can be used to filter the list") - ListAPIArtifactCmd.Flags().StringVarP(&orderBy, "order-by", "", - "", "A comma-separated list of fields to be sorted; ex: foo desc") - - _ = ListAPIArtifactCmd.MarkFlagRequired("api-name") -} diff --git a/internal/cmd/registry/apis/crtapis.go b/internal/cmd/registry/apis/crtapis.go deleted file mode 100644 index 9a25a786e..000000000 --- a/internal/cmd/registry/apis/crtapis.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 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 apis - -import ( - "internal/apiclient" - "internal/client/registry/apis" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// CreateAPICmd to create a new instance -var CreateAPICmd = &cobra.Command{ - Use: "create", - Short: "Create an Apigee Registry API entity", - Long: "Create an Apigee Registry API entity", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = apis.Create(apiID, name, displayName, description, - availability, recommendedVersion, recommendedDeployment, - labels, annotations) - return err - }, -} - -var apiID, availability, recommendedDeployment, recommendedVersion, description, displayName string - -func init() { - CreateAPICmd.Flags().StringVarP(&apiID, "id", "i", - "", "Apigee Registry API ID") - CreateAPICmd.Flags().StringVarP(&name, "name", "n", - "", "Name of the API") - CreateAPICmd.Flags().StringVarP(&displayName, "display-name", "d", - "", "Human friendly display name of the API") - CreateAPICmd.Flags().StringVarP(&description, "desc", "", - "", "Description of the API") - CreateAPICmd.Flags().StringVarP(&recommendedVersion, "version", "v", - "", "The recommended version of the API; Format: projects/{project}/"+ - "locations/{location}/apis/{api}/versions/{version}") - CreateAPICmd.Flags().StringVarP(&recommendedDeployment, "deployment", "", - "", "The recommended deployment of the API; Format: projects/{project}/"+ - "locations/{location}/apis/{api}/deployments/{deployment}") - CreateAPICmd.Flags().StringToStringVar(&labels, "labels", - nil, "Labels attach identifying metadata to resources") - CreateAPICmd.Flags().StringToStringVar(&annotations, "annotations", - nil, "Annotations attach non-identifying metadata to resources") - - _ = CreateAPICmd.MarkFlagRequired("id") - _ = CreateAPICmd.MarkFlagRequired("name") -} diff --git a/internal/cmd/registry/apis/delapis.go b/internal/cmd/registry/apis/delapis.go deleted file mode 100644 index 15c91108a..000000000 --- a/internal/cmd/registry/apis/delapis.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2023 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 apis - -import ( - "internal/apiclient" - - "internal/client/registry/apis" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// DelAPICmd to get instance -var DelAPICmd = &cobra.Command{ - Use: "delete", - Short: "Delete Apigee Registry API", - Long: "Delete Apigee Registry API", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = apis.Delete(name) - return - }, -} - -func init() { - DelAPICmd.Flags().StringVarP(&name, "name", "n", - "", "Apigee Registry API Name") -} diff --git a/internal/cmd/registry/apis/deployments/crtdeploy.go b/internal/cmd/registry/apis/deployments/crtdeploy.go deleted file mode 100644 index 8d02e4fc4..000000000 --- a/internal/cmd/registry/apis/deployments/crtdeploy.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2023 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 deployments - -import ( - "internal/apiclient" - "internal/client/registry/apis" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// CreateDeployCmd to create a new instance -var CreateDeployCmd = &cobra.Command{ - Use: "create", - Short: "Create an Apigee Registry API entity", - Long: "Create an Apigee Registry API entity", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = apis.CreateDeployment(apiDeploymentID, name, displayName, description, - apiSpecRevision, endpointURI, externalChannelURI, intendedAudience, - accessGuidance, labels, annotations) - return err - }, -} - -var ( - apiDeploymentID, apiSpecRevision, endpointURI, externalChannelURI string - name, description, displayName, intendedAudience, accessGuidance string - labels, annotations map[string]string -) - -func init() { - CreateDeployCmd.Flags().StringVarP(&apiDeploymentID, "id", "i", - "", "Apigee Registry Deployment ID") - CreateDeployCmd.Flags().StringVarP(&name, "name", "n", - "", "Name of the Deployment") - CreateDeployCmd.Flags().StringVarP(&displayName, "display-name", "d", - "", "Human friendly display name of the Deployment") - CreateDeployCmd.Flags().StringVarP(&description, "desc", "", - "", "Description of the Deployment") - CreateDeployCmd.Flags().StringVarP(&apiSpecRevision, "spec-revision", "", - "", "API Spec Revision") - CreateDeployCmd.Flags().StringVarP(&endpointURI, "endpoint-uri", "", - "", "Endpoint URI for the API") - CreateDeployCmd.Flags().StringVarP(&externalChannelURI, "external-channel-uri", "", - "", "External Channle URI") - CreateDeployCmd.Flags().StringVarP(&intendedAudience, "intended-audience", "", - "", "Intended Audience for the API") - CreateDeployCmd.Flags().StringVarP(&accessGuidance, "access-guidance", "", - "", "Guidance for accessing the API") - CreateDeployCmd.Flags().StringToStringVar(&labels, "labels", - nil, "Labels attach identifying metadata to resources") - CreateDeployCmd.Flags().StringToStringVar(&annotations, "annotations", - nil, "Annotations attach non-identifying metadata to resources") - - _ = CreateDeployCmd.MarkFlagRequired("id") - _ = CreateDeployCmd.MarkFlagRequired("name") -} diff --git a/internal/cmd/registry/apis/deployments/deldeploy.go b/internal/cmd/registry/apis/deployments/deldeploy.go deleted file mode 100644 index c77c3d418..000000000 --- a/internal/cmd/registry/apis/deployments/deldeploy.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2023 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 deployments - -import ( - "internal/apiclient" - - "internal/client/registry/apis" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// DelDeployCmd to get instance -var DelDeployCmd = &cobra.Command{ - Use: "delete", - Short: "Delete deployment associated with an API", - Long: "Delete deployment associated with an API", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - if revision { - _, err = apis.DeleteDeploymentRevision(apiName, name) - return - } - _, err = apis.DeleteDeployment(apiName, name, force) - return - }, -} - -var force, revision bool - -func init() { - DelDeployCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "API Name") - DelDeployCmd.Flags().StringVarP(&name, "name", "n", - "", "Deployment name") - DelDeployCmd.Flags().BoolVarP(&force, "force", "f", - false, "Deployment name") - DelDeployCmd.Flags().BoolVarP(&revision, "revision", "v", - false, "Delete a revision") - - _ = DelDeployCmd.MarkFlagRequired("api-name") - _ = DelDeployCmd.MarkFlagRequired("name") -} diff --git a/internal/cmd/registry/apis/deployments/deployments.go b/internal/cmd/registry/apis/deployments/deployments.go deleted file mode 100644 index 34442569f..000000000 --- a/internal/cmd/registry/apis/deployments/deployments.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2023 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 deployments - -import ( - "github.com/spf13/cobra" -) - -// APIDeploymentCmd to manage apis -var APIDeploymentCmd = &cobra.Command{ - Use: "deployments", - Short: "Manage API Deployments in Apigee Registry", - Long: "Manage API Deployments in Apigee Registry", -} - -func init() { - APIDeploymentCmd.AddCommand(ListDeployCmd) - APIDeploymentCmd.AddCommand(CreateDeployCmd) - APIDeploymentCmd.AddCommand(GetDeployCmd) - APIDeploymentCmd.AddCommand(DelDeployCmd) - APIDeploymentCmd.AddCommand(TagDeployCmd) - APIDeploymentCmd.AddCommand(RollbackDeployCmd) -} diff --git a/internal/cmd/registry/apis/deployments/getdeploy.go b/internal/cmd/registry/apis/deployments/getdeploy.go deleted file mode 100644 index d1a1f7916..000000000 --- a/internal/cmd/registry/apis/deployments/getdeploy.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2023 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 deployments - -import ( - "internal/apiclient" - - "internal/client/registry/apis" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// GetDeployCmd to get instance -var GetDeployCmd = &cobra.Command{ - Use: "get", - Short: "Get deployment details for an API", - Long: "Get deployment details for an API", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = apis.GetDeployment(apiName, name) - return - }, -} - -func init() { - GetDeployCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "API Name") - GetDeployCmd.Flags().StringVarP(&name, "name", "n", - "", "Deployment name") - - _ = GetDeployCmd.MarkFlagRequired("api-name") -} diff --git a/internal/cmd/registry/apis/deployments/listdeploy.go b/internal/cmd/registry/apis/deployments/listdeploy.go deleted file mode 100644 index a4ea2ee21..000000000 --- a/internal/cmd/registry/apis/deployments/listdeploy.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2023 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 deployments - -import ( - "internal/apiclient" - - "internal/client/registry/apis" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// ListDeployCmd to get instance -var ListDeployCmd = &cobra.Command{ - Use: "list", - Short: "List deployments for an API in Apigee Registry", - Long: "List deployments for an API in Apigee Registry", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - if name != "" { - _, err = apis.ListDeploymentRevisions(apiName, name, pageSize, pageToken, filter, orderBy) - return err - } - _, err = apis.ListDeployments(apiName, pageSize, pageToken, filter, orderBy) - return - }, -} - -var ( - apiName, pageToken, filter, orderBy string - pageSize int -) - -func init() { - ListDeployCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "API Name") - ListDeployCmd.Flags().StringVarP(&name, "name", "n", - "", "Deployment Name") - ListDeployCmd.Flags().StringVarP(&pageToken, "page-token", "", - "", "A page token, received from a previous list call") - ListDeployCmd.Flags().StringVarP(&filter, "filter", "", - "", "An expression that can be used to filter the list") - ListDeployCmd.Flags().StringVarP(&orderBy, "order-by", "", - "", "A comma-separated list of fields to be sorted; ex: foo desc") - - _ = ListDeployCmd.MarkFlagRequired("api-name") -} diff --git a/internal/cmd/registry/apis/deployments/rollbackdeploy.go b/internal/cmd/registry/apis/deployments/rollbackdeploy.go deleted file mode 100644 index 29de210d5..000000000 --- a/internal/cmd/registry/apis/deployments/rollbackdeploy.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2023 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 deployments - -import ( - "internal/apiclient" - - "internal/client/registry/apis" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// RollbackDeployCmd to get instance -var RollbackDeployCmd = &cobra.Command{ - Use: "rollback", - Short: "Rollback deployment revision for an API", - Long: "Rollback deployment revision for an API", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = apis.Rollback(apiName, name, revisionID) - return - }, -} - -var revisionID string - -func init() { - RollbackDeployCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "API Name") - RollbackDeployCmd.Flags().StringVarP(&name, "name", "n", - "", "Deployment name") - RollbackDeployCmd.Flags().StringVarP(&revisionID, "revision-id", "", - "", "The tag to apply") - - _ = RollbackDeployCmd.MarkFlagRequired("api-name") - _ = RollbackDeployCmd.MarkFlagRequired("name") - _ = RollbackDeployCmd.MarkFlagRequired("revision-id") -} diff --git a/internal/cmd/registry/apis/deployments/tagdeploy.go b/internal/cmd/registry/apis/deployments/tagdeploy.go deleted file mode 100644 index baa9077f5..000000000 --- a/internal/cmd/registry/apis/deployments/tagdeploy.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2023 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 deployments - -import ( - "internal/apiclient" - - "internal/client/registry/apis" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// TagDeployCmd to get instance -var TagDeployCmd = &cobra.Command{ - Use: "tag", - Short: "Tag deployment revision for an API", - Long: "Tag deployment revision for an API", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = apis.Tag(apiName, name, tag) - return - }, -} - -var tag string - -func init() { - TagDeployCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "API Name") - TagDeployCmd.Flags().StringVarP(&name, "name", "n", - "", "Deployment name") - TagDeployCmd.Flags().StringVarP(&tag, "tag", "", - "", "The tag to apply") - - _ = TagDeployCmd.MarkFlagRequired("api-name") - _ = TagDeployCmd.MarkFlagRequired("name") - _ = TagDeployCmd.MarkFlagRequired("tag") -} diff --git a/internal/cmd/registry/apis/getapis.go b/internal/cmd/registry/apis/getapis.go deleted file mode 100644 index 0b3466170..000000000 --- a/internal/cmd/registry/apis/getapis.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2023 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 apis - -import ( - "internal/apiclient" - - "internal/client/registry/apis" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// GetAPICmd to get instance -var GetAPICmd = &cobra.Command{ - Use: "get", - Short: "Get Apigee Registry API details", - Long: "Get Apigee Registry API details", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = apis.Get(name) - return - }, -} - -func init() { - GetAPICmd.Flags().StringVarP(&name, "name", "n", - "", "Apigee Registry API Name") -} diff --git a/internal/cmd/registry/apis/listapis.go b/internal/cmd/registry/apis/listapis.go deleted file mode 100644 index a5a2ae6c5..000000000 --- a/internal/cmd/registry/apis/listapis.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 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 apis - -import ( - "internal/apiclient" - - "internal/client/registry/apis" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// ListAPICmd to get instance -var ListAPICmd = &cobra.Command{ - Use: "list", - Short: "List all APIs in Apigee Registry", - Long: "List all APIs in Apigee Registry", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = apis.List(pageSize, pageToken, filter, orderBy) - return - }, -} - -var ( - pageToken, filter, orderBy string - pageSize int -) - -func init() { - ListAPICmd.Flags().StringVarP(&pageToken, "page-token", "", - "", "A page token, received from a previous list call") - ListAPICmd.Flags().StringVarP(&filter, "filter", "", - "", "An expression that can be used to filter the list") - ListAPICmd.Flags().StringVarP(&orderBy, "order-by", "", - "", "A comma-separated list of fields to be sorted; ex: foo desc") -} diff --git a/internal/cmd/registry/apis/versions/artifacts/artifacts.go b/internal/cmd/registry/apis/versions/artifacts/artifacts.go deleted file mode 100644 index 4e5db0cea..000000000 --- a/internal/cmd/registry/apis/versions/artifacts/artifacts.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "github.com/spf13/cobra" -) - -// ArtifactCmd to manage apis -var ArtifactCmd = &cobra.Command{ - Use: "artifacts", - Short: "Manage artifacts for an API version", - Long: "Manage artifacts for an API version in Apigee Registry", -} - -var labels, annotations map[string]string - -func init() { - ArtifactCmd.AddCommand(CreateArtifactCmd) - ArtifactCmd.AddCommand(ListArtifactCmd) - ArtifactCmd.AddCommand(GetArtifactCmd) - ArtifactCmd.AddCommand(DelArtifactCmd) -} diff --git a/internal/cmd/registry/apis/versions/artifacts/crtartifact.go b/internal/cmd/registry/apis/versions/artifacts/crtartifact.go deleted file mode 100644 index a6acf4bd7..000000000 --- a/internal/cmd/registry/apis/versions/artifacts/crtartifact.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "encoding/base64" - - "internal/apiclient" - "internal/client/registry/apis/versions" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// CreateArtifactCmd to create a new instance -var CreateArtifactCmd = &cobra.Command{ - Use: "create", - Short: "Create an artifact for an API version", - Long: "Create an artifact for an API version", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - var payload []byte - if payload, err = utils.ReadFile(contentsFile); err != nil { - return err - } - contents := base64.StdEncoding.EncodeToString(payload) - _, err = versions.CreateArtifact(apiName, apiVersion, artifactID, name, contents, labels, annotations) - return err - }, -} - -var apiName, apiVersion, name, artifactID, contentsFile string - -func init() { - CreateArtifactCmd.Flags().StringVarP(&apiVersion, "api-version", "", - "", "API Version ID") - CreateArtifactCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "Name of the API") - CreateArtifactCmd.Flags().StringVarP(&artifactID, "id", "i", - "", "Apigee Registry Artifact ID") - CreateArtifactCmd.Flags().StringVarP(&name, "name", "n", - "", "Name of the Artifact") - CreateArtifactCmd.Flags().StringVarP(&contentsFile, "file", "f", - "", "Path to a file containing Artifact Contents") - CreateArtifactCmd.Flags().StringToStringVar(&labels, "labels", - nil, "Labels attach identifying metadata to resources") - CreateArtifactCmd.Flags().StringToStringVar(&annotations, "annotations", - nil, "Annotations attach non-identifying metadata to resources") - - _ = CreateArtifactCmd.MarkFlagRequired("id") - _ = CreateArtifactCmd.MarkFlagRequired("api-name") - _ = CreateArtifactCmd.MarkFlagRequired("api-version") - _ = CreateArtifactCmd.MarkFlagRequired("name") - _ = CreateArtifactCmd.MarkFlagRequired("file") -} diff --git a/internal/cmd/registry/apis/versions/artifacts/delartifact.go b/internal/cmd/registry/apis/versions/artifacts/delartifact.go deleted file mode 100644 index 609b73d58..000000000 --- a/internal/cmd/registry/apis/versions/artifacts/delartifact.go +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "internal/apiclient" - - "internal/client/registry/apis/versions" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// DelArtifactCmd to get instance -var DelArtifactCmd = &cobra.Command{ - Use: "delete", - Short: "Delete artifact for an API version", - Long: "Delete artifact for an API version", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = versions.DeleteArtifact(apiName, apiVersion, name) - return - }, -} - -func init() { - DelArtifactCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "API Name") - DelArtifactCmd.Flags().StringVarP(&apiVersion, "api-version", "", - "", "API Version") - DelArtifactCmd.Flags().StringVarP(&name, "name", "n", - "", "Artifact Name") - - _ = DelArtifactCmd.MarkFlagRequired("api-name") - _ = DelArtifactCmd.MarkFlagRequired("api-version") - _ = DelArtifactCmd.MarkFlagRequired("name") -} diff --git a/internal/cmd/registry/apis/versions/artifacts/getartifact.go b/internal/cmd/registry/apis/versions/artifacts/getartifact.go deleted file mode 100644 index 1f9871cfe..000000000 --- a/internal/cmd/registry/apis/versions/artifacts/getartifact.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "internal/apiclient" - - "internal/client/registry/apis/versions" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// GetArtifactCmd to get instance -var GetArtifactCmd = &cobra.Command{ - Use: "get", - Short: "Get Artifact details for an API version", - Long: "Get Artifact details for an API version", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - if content { - return versions.GetArtifactContents(apiName, apiVersion, name) - } - _, err = versions.GetArtifact(apiName, apiVersion, name) - return - }, -} - -var content bool - -func init() { - GetArtifactCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "API Name") - GetArtifactCmd.Flags().StringVarP(&apiVersion, "api-version", "", - "", "API Version") - GetArtifactCmd.Flags().StringVarP(&name, "name", "n", - "", "Artifact Name") - GetArtifactCmd.Flags().BoolVarP(&content, "content", "c", - false, "If set to true, returns artifact contents") - - _ = GetArtifactCmd.MarkFlagRequired("api-name") - _ = GetArtifactCmd.MarkFlagRequired("api-version") - _ = GetArtifactCmd.MarkFlagRequired("name") -} diff --git a/internal/cmd/registry/apis/versions/artifacts/listartifacts.go b/internal/cmd/registry/apis/versions/artifacts/listartifacts.go deleted file mode 100644 index 9af7ba355..000000000 --- a/internal/cmd/registry/apis/versions/artifacts/listartifacts.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "internal/apiclient" - - "internal/client/registry/apis/versions" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// ListArtifactCmd to get instance -var ListArtifactCmd = &cobra.Command{ - Use: "list", - Short: "List all artifacts in Apigee Registry", - Long: "List all artifacts in Apigee Registry", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = versions.ListArtifacts(apiName, apiVersion, pageSize, pageToken, filter, orderBy) - return - }, -} - -var ( - pageToken, filter, orderBy string - pageSize int -) - -func init() { - ListArtifactCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "API Name") - ListArtifactCmd.Flags().StringVarP(&apiVersion, "api-version", "", - "", "API Version") - ListArtifactCmd.Flags().StringVarP(&pageToken, "page-token", "", - "", "A page token, received from a previous list call") - ListArtifactCmd.Flags().StringVarP(&filter, "filter", "", - "", "An expression that can be used to filter the list") - ListArtifactCmd.Flags().StringVarP(&orderBy, "order-by", "", - "", "A comma-separated list of fields to be sorted; ex: foo desc") - - _ = ListArtifactCmd.MarkFlagRequired("api-name") - _ = ListArtifactCmd.MarkFlagRequired("api-version") -} diff --git a/internal/cmd/registry/apis/versions/crtversion.go b/internal/cmd/registry/apis/versions/crtversion.go deleted file mode 100644 index 60d3119cd..000000000 --- a/internal/cmd/registry/apis/versions/crtversion.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2023 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 versions - -import ( - "internal/apiclient" - "internal/client/registry/apis" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// CreateVersionCmd to create a new instance -var CreateVersionCmd = &cobra.Command{ - Use: "create", - Short: "Create a version for an API", - Long: "Create a version for an API Apigee Registry Instance", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = apis.CreateVersion(apiVersionID, name, displayName, - description, state, labels, annotations, primarySpec) - return err - }, -} - -var ( - apiVersionID, description, displayName, state, primarySpec string - labels, annotations map[string]string -) - -func init() { - CreateVersionCmd.Flags().StringVarP(&apiVersionID, "api-version", "", - "", "The ID to use for the version") - CreateVersionCmd.Flags().StringVarP(&name, "name", "n", - "", "Name of the version") - CreateVersionCmd.Flags().StringVarP(&displayName, "display-name", "", - "", "Human friendly display name of the version") - CreateVersionCmd.Flags().StringVarP(&description, "desc", "d", - "", "A detailed description") - CreateVersionCmd.Flags().StringVarP(&state, "state", "s", - "", "A user-definable description of the lifecycle phase of this API version") - CreateVersionCmd.Flags().StringVarP(&primarySpec, "primary-spec", "", - "", "The primary spec for this version; ex: projects/*/locations/*/apis/*/versions/*/specs/*") - CreateVersionCmd.Flags().StringToStringVar(&labels, "labels", - nil, "Labels attach identifying metadata to resources") - CreateVersionCmd.Flags().StringToStringVar(&annotations, "annotations", - nil, "Annotations attach non-identifying metadata to resources") - - _ = CreateVersionCmd.MarkFlagRequired("id") -} diff --git a/internal/cmd/registry/apis/versions/deleteversion.go b/internal/cmd/registry/apis/versions/deleteversion.go deleted file mode 100644 index 9aaaed0f3..000000000 --- a/internal/cmd/registry/apis/versions/deleteversion.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 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 versions - -import ( - "internal/apiclient" - - "internal/client/registry/apis" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// DelVersionCmd to get instance -var DelVersionCmd = &cobra.Command{ - Use: "delete", - Short: "Delete an API Version for an API", - Long: "Delete an API Version for an API in Apigee Registry", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = apis.DeleteVersion(name, version, force) - return - }, -} - -var force bool - -func init() { - DelVersionCmd.Flags().StringVarP(&name, "name", "n", - "", "Apigee Registry API Name") - DelVersionCmd.Flags().StringVarP(&version, "version", "v", - "", "API Version name") - DelVersionCmd.Flags().BoolVarP(&force, "force", "f", - false, "Deployment name") - - _ = DelVersionCmd.MarkFlagRequired("name") - _ = DelVersionCmd.MarkFlagRequired("version") -} diff --git a/internal/cmd/registry/apis/versions/getversion.go b/internal/cmd/registry/apis/versions/getversion.go deleted file mode 100644 index 65088d347..000000000 --- a/internal/cmd/registry/apis/versions/getversion.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2023 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 versions - -import ( - "internal/apiclient" - - "internal/client/registry/apis" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// GetVersionCmd to get instance -var GetVersionCmd = &cobra.Command{ - Use: "get", - Short: "Get API Version details for an API", - Long: "Get API Version details for an API in Apigee Registry", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = apis.GetVersion(name, version) - return - }, -} - -var version string - -func init() { - GetVersionCmd.Flags().StringVarP(&name, "name", "n", - "", "Apigee Registry API Name") - GetVersionCmd.Flags().StringVarP(&version, "version", "v", - "", "API Version name") - - _ = GetVersionCmd.MarkFlagRequired("name") - _ = GetVersionCmd.MarkFlagRequired("version") -} diff --git a/internal/cmd/registry/apis/versions/listversion.go b/internal/cmd/registry/apis/versions/listversion.go deleted file mode 100644 index 601a248ff..000000000 --- a/internal/cmd/registry/apis/versions/listversion.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2023 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 versions - -import ( - "internal/apiclient" - - "internal/client/registry/apis" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// ListVersionCmd to get instance -var ListVersionCmd = &cobra.Command{ - Use: "list", - Short: "List all API Versions for an API", - Long: "List all API Versions for an API in Apigee Registry", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = apis.ListVersions(name, pageSize, pageToken, filter, orderBy) - return - }, -} - -var ( - name, pageToken, filter, orderBy string - pageSize int -) - -func init() { - ListVersionCmd.Flags().StringVarP(&name, "name", "n", - "", "Apigee Registry API Name") - ListVersionCmd.Flags().StringVarP(&pageToken, "page-token", "", - "", "A page token, received from a previous list call") - ListVersionCmd.Flags().StringVarP(&filter, "filter", "", - "", "An expression that can be used to filter the list") - ListVersionCmd.Flags().StringVarP(&orderBy, "order-by", "", - "", "A comma-separated list of fields to be sorted; ex: foo desc") - - _ = ListVersionCmd.MarkFlagRequired("name") -} diff --git a/internal/cmd/registry/apis/versions/specs/artifacts/artifacts.go b/internal/cmd/registry/apis/versions/specs/artifacts/artifacts.go deleted file mode 100644 index 02d7b861d..000000000 --- a/internal/cmd/registry/apis/versions/specs/artifacts/artifacts.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "github.com/spf13/cobra" -) - -// ArtifactCmd to manage apis -var ArtifactCmd = &cobra.Command{ - Use: "artifacts", - Short: "Manage artifacts for an API version's spec", - Long: "Manage artifacts for an API version in Apigee Registry", -} - -var apiName, apiVersion, specName, name string - -func init() { - ArtifactCmd.AddCommand(DelArtifactCmd) - ArtifactCmd.AddCommand(GetArtifactCmd) - ArtifactCmd.AddCommand(ListArtifactCmd) - ArtifactCmd.AddCommand(CreateArtifactCmd) -} diff --git a/internal/cmd/registry/apis/versions/specs/artifacts/crtartifact.go b/internal/cmd/registry/apis/versions/specs/artifacts/crtartifact.go deleted file mode 100644 index 96baa5d39..000000000 --- a/internal/cmd/registry/apis/versions/specs/artifacts/crtartifact.go +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "encoding/base64" - - "internal/apiclient" - "internal/client/registry/apis/versions" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// CreateArtifactCmd to create a new instance -var CreateArtifactCmd = &cobra.Command{ - Use: "create", - Short: "Create an artifact for an API version", - Long: "Create an artifact for an API version", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - var payload []byte - if payload, err = utils.ReadFile(contentsFile); err != nil { - return err - } - contents := base64.StdEncoding.EncodeToString(payload) - _, err = versions.CreateSpecArtifact(apiName, apiVersion, specName, artifactID, name, contents, labels, annotations) - return err - }, -} - -var labels, annotations map[string]string - -var artifactID, contentsFile string - -func init() { - CreateArtifactCmd.Flags().StringVarP(&apiVersion, "api-version", "", - "", "API Version ID") - CreateArtifactCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "Name of the API") - CreateArtifactCmd.Flags().StringVarP(&artifactID, "id", "i", - "", "Apigee Registry Artifact ID") - CreateArtifactCmd.Flags().StringVarP(&specName, "spec-name", "", - "", "API Version Spec name") - CreateArtifactCmd.Flags().StringVarP(&name, "name", "n", - "", "Name of the Artifact") - CreateArtifactCmd.Flags().StringVarP(&contentsFile, "file", "f", - "", "Path to a file containing Artifact Contents") - CreateArtifactCmd.Flags().StringToStringVar(&labels, "labels", - nil, "Labels attach identifying metadata to resources") - CreateArtifactCmd.Flags().StringToStringVar(&annotations, "annotations", - nil, "Annotations attach non-identifying metadata to resources") - - _ = CreateArtifactCmd.MarkFlagRequired("id") - _ = CreateArtifactCmd.MarkFlagRequired("api-name") - _ = CreateArtifactCmd.MarkFlagRequired("api-version") - _ = CreateArtifactCmd.MarkFlagRequired("spec-name") - _ = CreateArtifactCmd.MarkFlagRequired("name") - _ = CreateArtifactCmd.MarkFlagRequired("file") -} diff --git a/internal/cmd/registry/apis/versions/specs/artifacts/delartifact.go b/internal/cmd/registry/apis/versions/specs/artifacts/delartifact.go deleted file mode 100644 index 9615a7483..000000000 --- a/internal/cmd/registry/apis/versions/specs/artifacts/delartifact.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "internal/apiclient" - - "internal/client/registry/apis/versions" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// DelArtifactCmd to get instance -var DelArtifactCmd = &cobra.Command{ - Use: "delete", - Short: "Delete artifact for a spec in an API version", - Long: "Delete artifact for a spec in an API version in Apigee Registry", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = versions.DeleteSpecArtifact(apiName, apiVersion, specName, name) - return - }, -} - -func init() { - DelArtifactCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "API Name") - DelArtifactCmd.Flags().StringVarP(&apiVersion, "api-version", "", - "", "API Version") - DelArtifactCmd.Flags().StringVarP(&specName, "spec-name", "", - "", "API Version Spec name") - DelArtifactCmd.Flags().StringVarP(&name, "name", "n", - "", "API Version Spec Artifact name") - - _ = DelArtifactCmd.MarkFlagRequired("api-name") - _ = DelArtifactCmd.MarkFlagRequired("api-version") - _ = DelArtifactCmd.MarkFlagRequired("spec-name") - _ = DelArtifactCmd.MarkFlagRequired("name") -} diff --git a/internal/cmd/registry/apis/versions/specs/artifacts/getartifact.go b/internal/cmd/registry/apis/versions/specs/artifacts/getartifact.go deleted file mode 100644 index f1f69ef71..000000000 --- a/internal/cmd/registry/apis/versions/specs/artifacts/getartifact.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "internal/apiclient" - - "internal/client/registry/apis/versions" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// GetArtifactCmd to get instance -var GetArtifactCmd = &cobra.Command{ - Use: "get", - Short: "Get artifact details for a spec in an API version", - Long: "Get artifact details for a spec in an API version in Apigee Registry", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = versions.GetSpecArtifact(apiName, apiVersion, specName, name) - return - }, -} - -func init() { - GetArtifactCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "API Name") - GetArtifactCmd.Flags().StringVarP(&apiVersion, "api-version", "", - "", "API Version") - GetArtifactCmd.Flags().StringVarP(&specName, "spec-name", "", - "", "API Version Spec name") - GetArtifactCmd.Flags().StringVarP(&name, "name", "n", - "", "API Version Spec Artifact name") - - _ = GetArtifactCmd.MarkFlagRequired("api-name") - _ = GetArtifactCmd.MarkFlagRequired("api-version") - _ = GetArtifactCmd.MarkFlagRequired("spec-name") - _ = GetArtifactCmd.MarkFlagRequired("name") -} diff --git a/internal/cmd/registry/apis/versions/specs/artifacts/listartifacts.go b/internal/cmd/registry/apis/versions/specs/artifacts/listartifacts.go deleted file mode 100644 index ffca1bdc9..000000000 --- a/internal/cmd/registry/apis/versions/specs/artifacts/listartifacts.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "internal/apiclient" - - "internal/client/registry/apis/versions" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// ListArtifactCmd to get instance -var ListArtifactCmd = &cobra.Command{ - Use: "list", - Short: "List all artifacts in Apigee Registry", - Long: "List all artifacts in Apigee Registry", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = versions.ListSpecArtifacts(apiName, apiVersion, specName, pageSize, pageToken, filter, orderBy) - return - }, -} - -var ( - pageToken, filter, orderBy string - pageSize int -) - -func init() { - ListArtifactCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "API Name") - ListArtifactCmd.Flags().StringVarP(&apiVersion, "api-version", "", - "", "API Version") - ListArtifactCmd.Flags().StringVarP(&specName, "spec-name", "", - "", "API Version Spec name") - ListArtifactCmd.Flags().StringVarP(&pageToken, "page-token", "", - "", "A page token, received from a previous list call") - ListArtifactCmd.Flags().StringVarP(&filter, "filter", "", - "", "An expression that can be used to filter the list") - ListArtifactCmd.Flags().StringVarP(&orderBy, "order-by", "", - "", "A comma-separated list of fields to be sorted; ex: foo desc") - - _ = ListArtifactCmd.MarkFlagRequired("api-name") - _ = ListArtifactCmd.MarkFlagRequired("api-version") - _ = ListArtifactCmd.MarkFlagRequired("spec-name") -} diff --git a/internal/cmd/registry/apis/versions/specs/crtspec.go b/internal/cmd/registry/apis/versions/specs/crtspec.go deleted file mode 100644 index 353099556..000000000 --- a/internal/cmd/registry/apis/versions/specs/crtspec.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2023 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 specs - -import ( - "encoding/base64" - "path/filepath" - - "internal/apiclient" - - "internal/client/registry/apis/versions" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// CreateSpecCmd to get instance -var CreateSpecCmd = &cobra.Command{ - Use: "create", - Short: "Create a spec associated with an API version", - Long: "Create a spec associated with an API version in Apigee Registry", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - fileContents, err := utils.ReadFile(filePath) - if err != nil { - return err - } - fileName := filepath.Base(filePath) - contents := base64.URLEncoding.EncodeToString(fileContents) - _, err = versions.CreateSpec(apiName, apiVersion, apiSpecID, - name, fileName, description, sourceURI, contents, labels, annotations) - return - }, -} - -var ( - labels, annotations map[string]string - apiSpecID, description, sourceURI, filePath string -) - -func init() { - CreateSpecCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "API Name") - CreateSpecCmd.Flags().StringVarP(&apiVersion, "api-version", "", - "", "API Version") - CreateSpecCmd.Flags().StringVarP(&apiSpecID, "api-specid", "", - "", "API Spec Id") - CreateSpecCmd.Flags().StringVarP(&name, "name", "n", - "", "API Version Spec name") - CreateSpecCmd.Flags().StringVarP(&description, "desc", "d", - "", "A detailed description for the spec") - CreateSpecCmd.Flags().StringVarP(&filePath, "file-path", "f", - "", "A path to file containing the spec") - CreateSpecCmd.Flags().StringVarP(&sourceURI, "source-uri", "s", - "", "Source URI") - CreateSpecCmd.Flags().StringToStringVar(&labels, "labels", - nil, "Labels attach identifying metadata to resources") - CreateSpecCmd.Flags().StringToStringVar(&annotations, "annotations", - nil, "Annotations attach non-identifying metadata to resources") - - _ = CreateSpecCmd.MarkFlagRequired("api-name") - _ = CreateSpecCmd.MarkFlagRequired("api-version") - _ = CreateSpecCmd.MarkFlagRequired("name") - _ = CreateSpecCmd.MarkFlagRequired("file-path") -} diff --git a/internal/cmd/registry/apis/versions/specs/delspec.go b/internal/cmd/registry/apis/versions/specs/delspec.go deleted file mode 100644 index 6b7b1bee0..000000000 --- a/internal/cmd/registry/apis/versions/specs/delspec.go +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2023 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 specs - -import ( - "internal/apiclient" - - "internal/client/registry/apis/versions" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// DeleteSpecCmd to get instance -var DeleteSpecCmd = &cobra.Command{ - Use: "delete", - Short: "Delete a spec associated with an API version", - Long: "Delete a spec associated with an API version in Apigee Registry", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = versions.DeleteSpec(apiName, apiVersion, name) - return - }, -} - -func init() { - DeleteSpecCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "API Name") - DeleteSpecCmd.Flags().StringVarP(&apiVersion, "api-version", "", - "", "API Version") - DeleteSpecCmd.Flags().StringVarP(&name, "name", "n", - "", "Name of the Spec") - - _ = DeleteSpecCmd.MarkFlagRequired("api-name") - _ = DeleteSpecCmd.MarkFlagRequired("api-version") - _ = DeleteSpecCmd.MarkFlagRequired("name") -} diff --git a/internal/cmd/registry/apis/versions/specs/getspec.go b/internal/cmd/registry/apis/versions/specs/getspec.go deleted file mode 100644 index 1276d7fbc..000000000 --- a/internal/cmd/registry/apis/versions/specs/getspec.go +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2023 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 specs - -import ( - "internal/apiclient" - - "internal/client/registry/apis/versions" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// GetSpecCmd to get instance -var GetSpecCmd = &cobra.Command{ - Use: "get", - Short: "Get the spec details for an API version", - Long: "Get the spec details for an API version in Apigee Registry", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - if content { - err = versions.GetSpecContents(apiName, apiVersion, name) - return err - } - _, err = versions.GetSpec(apiName, apiVersion, name) - return - }, -} - -var ( - name string - content bool -) - -func init() { - GetSpecCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "API Name") - GetSpecCmd.Flags().StringVarP(&apiVersion, "api-version", "", - "", "API Version") - GetSpecCmd.Flags().StringVarP(&name, "name", "n", - "", "Name of the Spec") - GetSpecCmd.Flags().BoolVarP(&content, "content", "c", - false, "If set to true, returns artifact contents") - - _ = GetSpecCmd.MarkFlagRequired("api-name") - _ = GetSpecCmd.MarkFlagRequired("api-version") - _ = GetSpecCmd.MarkFlagRequired("name") -} diff --git a/internal/cmd/registry/apis/versions/specs/listspecs.go b/internal/cmd/registry/apis/versions/specs/listspecs.go deleted file mode 100644 index 67a1ec925..000000000 --- a/internal/cmd/registry/apis/versions/specs/listspecs.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2023 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 specs - -import ( - "internal/apiclient" - - "internal/client/registry/apis/versions" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// ListSpecCmd to get instance -var ListSpecCmd = &cobra.Command{ - Use: "list", - Short: "List all specs for an API version", - Long: "List all artifacts for an API version in Apigee Registry", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = versions.ListSpecs(apiName, apiVersion, pageSize, pageToken, filter, orderBy) - return - }, -} - -var ( - apiName, apiVersion, pageToken, filter, orderBy string - pageSize int -) - -func init() { - ListSpecCmd.Flags().StringVarP(&apiName, "api-name", "", - "", "API Name") - ListSpecCmd.Flags().StringVarP(&apiVersion, "api-version", "", - "", "API Version") - ListSpecCmd.Flags().StringVarP(&pageToken, "page-token", "", - "", "A page token, received from a previous list call") - ListSpecCmd.Flags().StringVarP(&filter, "filter", "", - "", "An expression that can be used to filter the list") - ListSpecCmd.Flags().StringVarP(&orderBy, "order-by", "", - "", "A comma-separated list of fields to be sorted; ex: foo desc") - - _ = ListSpecCmd.MarkFlagRequired("api-name") - _ = ListSpecCmd.MarkFlagRequired("api-version") -} diff --git a/internal/cmd/registry/apis/versions/specs/specs.go b/internal/cmd/registry/apis/versions/specs/specs.go deleted file mode 100644 index d32983468..000000000 --- a/internal/cmd/registry/apis/versions/specs/specs.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2023 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 specs - -import ( - "internal/cmd/registry/apis/versions/specs/artifacts" - - "github.com/spf13/cobra" -) - -// SpecCmd to manage apis -var SpecCmd = &cobra.Command{ - Use: "specs", - Short: "Manage specs for an API version", - Long: "Manage specs for an API version in Apigee Registry", -} - -func init() { - SpecCmd.AddCommand(ListSpecCmd) - SpecCmd.AddCommand(GetSpecCmd) - SpecCmd.AddCommand(DeleteSpecCmd) - SpecCmd.AddCommand(CreateSpecCmd) - SpecCmd.AddCommand(artifacts.ArtifactCmd) -} diff --git a/internal/cmd/registry/apis/versions/versions.go b/internal/cmd/registry/apis/versions/versions.go deleted file mode 100644 index fcdce3d30..000000000 --- a/internal/cmd/registry/apis/versions/versions.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2023 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 versions - -import ( - "internal/cmd/registry/apis/versions/artifacts" - "internal/cmd/registry/apis/versions/specs" - - "github.com/spf13/cobra" -) - -// APIVersionCmd to manage apis -var APIVersionCmd = &cobra.Command{ - Use: "versions", - Short: "Manage API Versions in Apigee Registry", - Long: "Manage API Versions in Apigee Registry", -} - -func init() { - APIVersionCmd.AddCommand(ListVersionCmd) - APIVersionCmd.AddCommand(CreateVersionCmd) - APIVersionCmd.AddCommand(GetVersionCmd) - APIVersionCmd.AddCommand(DelVersionCmd) - APIVersionCmd.AddCommand(artifacts.ArtifactCmd) - APIVersionCmd.AddCommand(specs.SpecCmd) -} diff --git a/internal/cmd/registry/artifacts/artifacts.go b/internal/cmd/registry/artifacts/artifacts.go deleted file mode 100644 index f801d2e3a..000000000 --- a/internal/cmd/registry/artifacts/artifacts.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "github.com/spf13/cobra" -) - -// ArtifactCmd to manage apis -var ArtifactCmd = &cobra.Command{ - Use: "artifacts", - Short: "Manage artifacts in Apigee Registry", - Long: "Manage artifacts in Apigee Registry", -} - -var labels, annotations map[string]string - -func init() { - ArtifactCmd.AddCommand(CreateArtifactCmd) - ArtifactCmd.AddCommand(GetArtifactCmd) - ArtifactCmd.AddCommand(ListArtifactCmd) - ArtifactCmd.AddCommand(DelArtifactCmd) -} diff --git a/internal/cmd/registry/artifacts/crtartifact.go b/internal/cmd/registry/artifacts/crtartifact.go deleted file mode 100644 index 9265b61f3..000000000 --- a/internal/cmd/registry/artifacts/crtartifact.go +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "encoding/base64" - - "internal/apiclient" - "internal/client/registry/artifacts" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// CreateArtifactCmd to create a new instance -var CreateArtifactCmd = &cobra.Command{ - Use: "create", - Short: "Create an Apigee Registry Artifact", - Long: "Create an Apigee Registry Artifact", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - var payload []byte - if payload, err = utils.ReadFile(contentsFile); err != nil { - return err - } - contents := base64.StdEncoding.EncodeToString(payload) - _, err = artifacts.Create(artifactID, name, contents, labels, annotations) - return err - }, -} - -var name, artifactID, contentsFile string - -func init() { - CreateArtifactCmd.Flags().StringVarP(&artifactID, "id", "i", - "", "Apigee Registry Artifact ID") - CreateArtifactCmd.Flags().StringVarP(&name, "name", "n", - "", "Name of the Artifact") - CreateArtifactCmd.Flags().StringVarP(&contentsFile, "file", "f", - "", "Path to a file containing Artifact Contents") - CreateArtifactCmd.Flags().StringToStringVar(&labels, "labels", - nil, "Labels attach identifying metadata to resources") - CreateArtifactCmd.Flags().StringToStringVar(&annotations, "annotations", - nil, "Annotations attach non-identifying metadata to resources") - - _ = CreateArtifactCmd.MarkFlagRequired("id") - _ = CreateArtifactCmd.MarkFlagRequired("name") - _ = CreateArtifactCmd.MarkFlagRequired("file") -} diff --git a/internal/cmd/registry/artifacts/delartifact.go b/internal/cmd/registry/artifacts/delartifact.go deleted file mode 100644 index c859049fc..000000000 --- a/internal/cmd/registry/artifacts/delartifact.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "internal/apiclient" - - "internal/client/registry/artifacts" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// DelArtifactCmd to get instance -var DelArtifactCmd = &cobra.Command{ - Use: "delete", - Short: "Delete artifact from Apigee Registry", - Long: "Delete artifact from Apigee Registry", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = artifacts.Delete(name) - return - }, -} - -func init() { - DelArtifactCmd.Flags().StringVarP(&name, "name", "n", - "", "Artifact Name") -} diff --git a/internal/cmd/registry/artifacts/getartifact.go b/internal/cmd/registry/artifacts/getartifact.go deleted file mode 100644 index af120249f..000000000 --- a/internal/cmd/registry/artifacts/getartifact.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "internal/apiclient" - - "internal/client/registry/artifacts" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// GetArtifactCmd to get instance -var GetArtifactCmd = &cobra.Command{ - Use: "get", - Short: "Get Artifact details", - Long: "Get Artifact details", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - if content { - return artifacts.GetContents(name) - } - _, err = artifacts.Get(name) - return - }, -} - -var content bool - -func init() { - GetArtifactCmd.Flags().StringVarP(&name, "name", "n", - "", "Artifact Name") - GetArtifactCmd.Flags().BoolVarP(&content, "content", "c", - false, "If set to true, returns artifact contents") -} diff --git a/internal/cmd/registry/artifacts/listartifact.go b/internal/cmd/registry/artifacts/listartifact.go deleted file mode 100644 index 8fca24676..000000000 --- a/internal/cmd/registry/artifacts/listartifact.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2023 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 artifacts - -import ( - "internal/apiclient" - - "internal/client/registry/artifacts" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// ListArtifactCmd to get instance -var ListArtifactCmd = &cobra.Command{ - Use: "list", - Short: "List all artifacts in Apigee Registry", - Long: "List all artifacts in Apigee Registry", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = artifacts.List(pageSize, pageToken, filter, orderBy) - return - }, -} - -var ( - pageToken, filter, orderBy string - pageSize int -) - -func init() { - ListArtifactCmd.Flags().StringVarP(&pageToken, "page-token", "", - "", "A page token, received from a previous list call") - ListArtifactCmd.Flags().StringVarP(&filter, "filter", "", - "", "An expression that can be used to filter the list") - ListArtifactCmd.Flags().StringVarP(&orderBy, "order-by", "", - "", "A comma-separated list of fields to be sorted; ex: foo desc") -} diff --git a/internal/cmd/registry/instances/crtinstance.go b/internal/cmd/registry/instances/crtinstance.go deleted file mode 100644 index 100bd28eb..000000000 --- a/internal/cmd/registry/instances/crtinstance.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2023 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 instances - -import ( - "internal/apiclient" - "internal/client/registry/instances" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// CreateInstanceCmd to create a new instance -var CreateInstanceCmd = &cobra.Command{ - Use: "create", - Short: "Create an Apigee Registry Instance", - Long: "Create an Apigee Registry Instance", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = instances.Create(cmekName) - return err - }, -} - -var cmekName string - -func init() { - CreateInstanceCmd.Flags().StringVarP(&cmekName, "cmek", "k", - "", "Cloud KMS Key Resource ID") - - _ = CreateInstanceCmd.MarkFlagRequired("cmek") -} diff --git a/internal/cmd/registry/instances/delinstance.go b/internal/cmd/registry/instances/delinstance.go deleted file mode 100644 index be3d8ddbf..000000000 --- a/internal/cmd/registry/instances/delinstance.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2023 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 instances - -import ( - "internal/apiclient" - - "internal/client/registry/instances" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// DeleteInstanceCmd to delete instance -var DeleteInstanceCmd = &cobra.Command{ - Use: "delete", - Short: "Delete an Apigee Registry Instance", - Long: "Delete an Apigee Registry Instance", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = instances.Delete() - return - }, -} - -func init() { -} diff --git a/internal/cmd/registry/instances/getinstance.go b/internal/cmd/registry/instances/getinstance.go deleted file mode 100644 index 6dfaccb89..000000000 --- a/internal/cmd/registry/instances/getinstance.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2023 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 instances - -import ( - "internal/apiclient" - - "internal/client/registry/instances" - - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// GetInstanceCmd to get instance -var GetInstanceCmd = &cobra.Command{ - Use: "get", - Short: "Get an Apigee Registry Instance", - Long: "Get an Apigee Registry Instance", - Args: func(cmd *cobra.Command, args []string) (err error) { - apiclient.SetProjectID(utils.ProjectID) - apiclient.SetRegion(utils.Region) - return apiclient.SetApigeeOrg(utils.Org) - }, - RunE: func(cmd *cobra.Command, args []string) (err error) { - _, err = instances.Get() - return - }, -} - -func init() { -} diff --git a/internal/cmd/registry/instances/instances.go b/internal/cmd/registry/instances/instances.go deleted file mode 100644 index 4a0aa36ae..000000000 --- a/internal/cmd/registry/instances/instances.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2023 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 instances - -import ( - "github.com/spf13/cobra" -) - -// InstanceCmd to manage apis -var InstanceCmd = &cobra.Command{ - Use: "instances", - Short: "Manage Apigee Registry Instances", - Long: "Manage Apigee Registry Instances", -} - -func init() { - InstanceCmd.AddCommand(CreateInstanceCmd) - InstanceCmd.AddCommand(GetInstanceCmd) - InstanceCmd.AddCommand(DeleteInstanceCmd) -} diff --git a/internal/cmd/registry/registry.go b/internal/cmd/registry/registry.go deleted file mode 100644 index 44d7d4b6e..000000000 --- a/internal/cmd/registry/registry.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2023 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 registry - -import ( - "internal/cmd/registry/apis" - "internal/cmd/registry/artifacts" - "internal/cmd/registry/instances" - "internal/cmd/utils" - - "github.com/spf13/cobra" -) - -// Cmd to manage apis -var Cmd = &cobra.Command{ - Use: "registry", - Short: "Manage Apigee API Registry APIs", - Long: "Manage Apigee API Registry APIs", -} - -func init() { - Cmd.AddCommand(apis.APICmd) - Cmd.AddCommand(artifacts.ArtifactCmd) - Cmd.AddCommand(instances.InstanceCmd) - - Cmd.PersistentFlags().StringVarP(&utils.Org, "org", "o", - "", "Apigee organization name") - Cmd.PersistentFlags().StringVarP(&utils.Region, "region", "", - "", "Region where Apigee Registry is provisioned") - Cmd.PersistentFlags().StringVarP(&utils.ProjectID, "projectID", "p", - "", "Apigee Registry Project ID; Use if Apigee Orgniazation not provisioned in this project") -} diff --git a/internal/cmd/root.go b/internal/cmd/root.go index 54c3015cf..00fab30a5 100644 --- a/internal/cmd/root.go +++ b/internal/cmd/root.go @@ -51,7 +51,6 @@ import ( "internal/cmd/products" "internal/cmd/projects" "internal/cmd/references" - "internal/cmd/registry" res "internal/cmd/res" "internal/cmd/securityprofiles" "internal/cmd/sharedflows" @@ -187,7 +186,6 @@ func init() { RootCmd.AddCommand(datastores.Cmd) RootCmd.AddCommand(securityprofiles.Cmd) RootCmd.AddCommand(sites.Cmd) - RootCmd.AddCommand(registry.Cmd) } func initConfig() {