-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introducing eventarc apihub reference
- Loading branch information
Showing
10 changed files
with
372 additions
and
1 deletion.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
eventarc-apihub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Eventarc Api Hub Lab | ||
|
||
Use [claat](https://github.com/googlecodelabs/tools) to | ||
generate static HTML site from the Markdown document. | ||
|
||
go get github.com/googlecodelabs/tools/claat | ||
|
||
claat export ./lab.md | ||
|
||
This will create directory with static files. Serve it from any static file | ||
webserver. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# 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. | ||
|
||
FROM debian:11 | ||
|
||
RUN apt update | ||
RUN apt install nodejs npm -y | ||
RUN npm install -g openapi2apigee | ||
RUN apt install default-jre -y | ||
|
||
COPY wsdl2apigee-1.0.0-jar-with-dependencies.jar . | ||
ENTRYPOINT ["bash"] | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
# 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. | ||
|
||
# build labs | ||
claat export ./lab.md |
41 changes: 41 additions & 0 deletions
41
labs/eventarc-apihub/workflows/apigee-notifydeployment-apihub.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# 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. | ||
main: | ||
params: [input] | ||
steps: | ||
- init: | ||
assign: | ||
- project_id: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")} | ||
- getRevisionList: | ||
call: http.get | ||
args: | ||
url: ${"https://apigeeregistry.googleapis.com/v1/projects/" + project_id + "/locations/global/apis/"+text.to_lower(input.data.protoPayload.response.apiProxy)+"/versions/"+"1"+"/specs"} | ||
auth: | ||
type: OAuth2 | ||
scopes: https://www.googleapis.com/auth/cloud-platform | ||
result: revisionList | ||
- callApiRegistry: | ||
call: http.post | ||
args: | ||
url: ${"https://apigeeregistry.googleapis.com/v1/projects/" + project_id + "/locations/global/apis/" + text.to_lower(input.data.protoPayload.response.apiProxy) + "/deployments"} | ||
auth: | ||
type: OAuth2 | ||
scopes: https://www.googleapis.com/auth/cloud-platform | ||
query: | ||
apiDeploymentId: ${text.to_lower(input.data.protoPayload.response.apiProxy)+"-"+ input.data.protoPayload.response.revision +"-"+ text.substring(time.format(sys.now()), 0, 10)} | ||
body: | ||
labels: | ||
apihub-gateway: apihub-google-cloud-apigee | ||
displayName: ${input.data.protoPayload.response.environment} | ||
apiSpecRevision: ${revisionList.body.apiSpecs[0].name+"@"+revisionList.body.apiSpecs[0].revisionId} | ||
result: callApiRegistry | ||
- returnOutput: | ||
return: ${revisionList.body} |
84 changes: 84 additions & 0 deletions
84
labs/eventarc-apihub/workflows/apiregistry-updatespec-workflow.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# 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. | ||
main: | ||
params: [input] | ||
steps: | ||
- init: | ||
assign: | ||
- project_id: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")} | ||
- location_id: "global" | ||
- checkServiceTipe: | ||
switch: | ||
- condition: ${input.data.payload.mimeType == "application/x.openapi"} | ||
steps: | ||
- stepa: | ||
assign: | ||
- service_type: "rest" | ||
- createBuildRest: | ||
call: googleapis.cloudbuild.v1.projects.builds.create | ||
args: | ||
projectId: ${project_id} | ||
parent: ${"projects/" + project_id + "/locations/" + location_id} | ||
body: | ||
steps: | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
script: '${"curl -H \"Authorization: Bearer "+ "\"$(gcloud auth print-access-token)\"\"" +" https://apigeeregistry.googleapis.com/v1/" + input.data.payload.name + ":getContents --output "+input.data.payload.filename}' | ||
- name: ${"europe-docker.pkg.dev/"+project_id+"/builder/apigee-automation-builder"} | ||
script: '${"openapi2apigee generateApi "+input.api+" -s "+ input.data.payload.filename +" -d . -O true -B /"+input.api+"/"+input.version}'#TODO add targetEndpoint?? | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
script: '${"curl -X POST -H \"Authorization: Bearer "+ "\"$(gcloud auth print-access-token)\"\"" +" -F file=@" +input.api+"/"+ "apiproxy.zip \"https://apigee.googleapis.com/v1/organizations/" + project_id + "/apis?action=import&name="+input.api +"\"" }' | ||
- condition: ${input.data.payload.mimeType == "application/wsdl+xml"} | ||
steps: | ||
- stepb: | ||
assign: | ||
- service_type: "soap" | ||
- createBuildSoap: | ||
switch: | ||
- condition: ${text.split(input.data.payload.filename, ".")[1] != "zip"} | ||
steps: | ||
- createSoapPackageFromWsdl: | ||
call: googleapis.cloudbuild.v1.projects.builds.create | ||
args: | ||
projectId: ${project_id} | ||
parent: ${"projects/" + project_id + "/locations/" + location_id} | ||
body: | ||
steps: | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
script: '${"curl -H \"Authorization: Bearer "+ "\"$(gcloud auth print-access-token)\"\"" +" https://apigeeregistry.googleapis.com/v1/" + input.data.payload.name + ":getContents --output "+input.data.payload.filename}' | ||
- name: ${"europe-docker.pkg.dev/"+project_id+"/builder/apigee-automation-builder"} | ||
script: '${"java -jar wsdl2apigee-1.0.0-jar-with-dependencies.jar -wsdl="+ input.data.payload.filename + " -passthru=true -oauth=true -basepath=/"+input.api+"/"+input.version}'#TODO add targetEndpoint?? | ||
- name: 'bash' | ||
script: 'mv *.zip package.zip' | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
script: '${"curl -X POST -H \"Authorization: Bearer "+ "\"$(gcloud auth print-access-token)\"\"" +" -F file=@package.zip \"https://apigee.googleapis.com/v1/organizations/" + project_id + "/apis?action=import&name="+input.api +"\"" }' | ||
- condition: ${text.split(input.data.payload.filename, ".")[1] == "zip"} | ||
steps: | ||
- createSoapPackageFromZip: | ||
call: googleapis.cloudbuild.v1.projects.builds.create | ||
args: | ||
projectId: ${project_id} | ||
parent: ${"projects/" + project_id + "/locations/" + location_id} | ||
body: | ||
steps: | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
script: '${"curl -H \"Authorization: Bearer "+ "\"$(gcloud auth print-access-token)\"\"" +" https://apigeeregistry.googleapis.com/v1/" + input.data.payload.name + ":getContents --output "+input.data.payload.filename}' | ||
- name: 'bash' | ||
script: '${"unzip "+input.data.payload.filename +" -d ./"+ text.split(input.data.payload.filename, ".")[0]}' | ||
- name: ${"europe-docker.pkg.dev/"+project_id+"/builder/apigee-automation-builder"} | ||
script: '${"java -jar ../wsdl2apigee-1.0.0-jar-with-dependencies.jar -wsdl=./"+ text.split(input.data.payload.filename, ".")[0]+"/service.wsdl" + " -passthru=true -oauth=true -basepath=/"+input.api+"/"+input.version}' #TODO add targetEndpoint?? | ||
- name: 'bash' | ||
script: '${"rm " + input.data.payload.filename}' | ||
- name: 'bash' | ||
script: 'mv *.zip package.zip' | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
script: '${"curl -X POST -H \"Authorization: Bearer "+ "\"$(gcloud auth print-access-token)\"\"" +" -F file=@package.zip \"https://apigee.googleapis.com/v1/organizations/" + project_id + "/apis?action=import&name="+input.api +"\"" }' | ||
- returnOutput: | ||
return: ${service_type} |