Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first attempt to export from API Gateway #160

Merged
merged 2 commits into from
Mar 9, 2023

Conversation

timburks
Copy link
Contributor

@timburks timburks commented Mar 9, 2023

This is a hastily-written exporter that creates API entries for each gateway in the currently-configured gcloud project. It uses gcloud to call the apigateway API (that could be replaced with direct calls). I've exported both OpenAPI and gRPC services and verified that exported results are read into the registry, but the protobuf-based specs aren't fully-resolved (they are missing common dependencies), so they won't be compilable with protoc without some additional work.

This is potentially all throwaway code, I just wanted to have something to show for API Gateway.

Usage: registry-connect discover apigateway gateways --output DIRECTORY where DIRECTORY is the directory to contain exported Registry YAML and API specs. This requires that gcloud be installed and configured to use a project that has some API Gateway instances to export.

By default it writes to gateway-export and here's what I get for a sample project with three gateways:

$ find gateway-export/
gateway-export/
gateway-export/timburks-test-shakes
gateway-export/timburks-test-shakes/info.yaml
gateway-export/timburks-test-shakes/shakes.proto
gateway-export/timburks-test-shakes/api_config.yaml
gateway-export/timburks-test-bookstore
gateway-export/timburks-test-bookstore/info.yaml
gateway-export/timburks-test-bookstore/bookstore.proto
gateway-export/timburks-test-bookstore/api_config.yaml
gateway-export/timburks-test-hello
gateway-export/timburks-test-hello/info.yaml
gateway-export/timburks-test-hello/openapi.yaml

$ cat gateway-export/timburks-test-shakes/info.yaml 
apiVersion: apigeeregistry/v1
kind: API
metadata:
  name: timburks-test-shakes
  labels:
    provider: timburks-test
data:
  displayName: timburks-test gateway shakes
  description: Exported from API Gateway
  versions:
    - metadata:
        name: v1
      data:
        displayName: v1
        specs:
          - metadata:
              name: protos
            data:
              filename: protos.zip
              mimeType: application/x.proto+zip
  deployments:
    - metadata:
        name: gateway
      data:
        displayName: gateway
        endpointURI: https://shakes-8ez1hpbl.wl.gateway.dev

@timburks
Copy link
Contributor Author

timburks commented Mar 9, 2023

I'll follow up with a PR that sets some labels with more detail.

@timburks timburks merged commit d54571d into apigee:main Mar 9, 2023
@timburks timburks deleted the apigateway-export branch September 18, 2023 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants