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

registry-connect: what to import for API Gateway APIs? #163

Open
timburks opened this issue Mar 10, 2023 · 2 comments
Open

registry-connect: what to import for API Gateway APIs? #163

timburks opened this issue Mar 10, 2023 · 2 comments

Comments

@timburks
Copy link
Contributor

timburks commented Mar 10, 2023

Our first effort to import from API Gateway imports each gateway as an API and includes a deployment and spec (if the spec is available). This uses the gateway and api-config resources. These are also associated with a top-level api resource, which is fairly sparse:

$ gcloud api-gateway apis list --format json
[
  {
    "createTime": "2022-08-09T23:21:09.797675125Z",
    "displayName": "shakes",
    "managedService": "shakes-2zd0s6jcf3fpb.apigateway.timburks-test.cloud.goog",
    "name": "projects/timburks-test/locations/global/apis/shakes",
    "state": "ACTIVE",
    "updateTime": "2022-08-09T23:22:46.663939562Z"
  },
  {
    "createTime": "2022-10-18T01:52:26.685353895Z",
    "displayName": "bookstore",
    "managedService": "bookstore-0kmzty5nm7anj.apigateway.timburks-test.cloud.goog",
    "name": "projects/timburks-test/locations/global/apis/bookstore",
    "state": "ACTIVE",
    "updateTime": "2022-10-18T01:54:04.933554988Z"
  },
  {
    "createTime": "2022-08-12T21:04:25.885733799Z",
    "displayName": "hello",
    "labels": {
      "x": "3",
      "y": "4"
    },
    "managedService": "hello-1uw9r3za60r8p.apigateway.timburks-test.cloud.goog",
    "name": "projects/timburks-test/locations/global/apis/hello",
    "state": "ACTIVE",
    "updateTime": "2022-08-12T21:28:43.440993482Z"
  },
  {
    "createTime": "2022-10-05T19:17:32.327653674Z",
    "displayName": "thirdparty",
    "managedService": "thirdparty-1omvx0hwvgzap.apigateway.timburks-test.cloud.goog",
    "name": "projects/timburks-test/locations/global/apis/thirdparty",
    "state": "ACTIVE",
    "updateTime": "2022-10-05T19:19:10.637324810Z"
  }
]

I think it would be useful to import each of these as API resources and link them to their associated gateways, but if this is all the information we have, there's not much to put in those new API resources. I'm curious to see what's in the managedService records but haven't looked up how to get those from the Service Management (?) API.

@timburks
Copy link
Contributor Author

This gets a high-level description of a service:

$ curl https://servicemanagement.googleapis.com/v1/services/hello-1uw9r3za60r8p.apigateway.timburks-test.cloud.goog -H "Authorization: Bearer `gcloud auth print-access-token`"
{
  "serviceName": "hello-1uw9r3za60r8p.apigateway.timburks-test.cloud.goog",
  "producerProjectId": "timburks-test"
}

This gets the service configurations:

curl https://servicemanagement.googleapis.com/v1/services/hello-1uw9r3za60r8p.apigateway.timburks-test.cloud.goog/configs -H "Authorization: Bearer `gcloud auth print-access-token`"
...
  {
      "name": "hello-1uw9r3za60r8p.apigateway.timburks-test.cloud.goog",
      "title": "Hello API",
      "documentation": {
        "summary": "Sample API on API Gateway with a Google Cloud Functions backend"
      },
      "usage": {},
      "metrics": [
        {
          "name": "serviceruntime.googleapis.com/api/consumer/request_count",
          "labels": [
            {
              "key": "/credential_id"
            },
            {
              "key": "/protocol"
            },
            {
              "key": "/response_code"
            },
            {
              "key": "/response_code_class"
            },
            {
              "key": "/status_code"
            }
          ]
        },
        {
          "name": "serviceruntime.googleapis.com/api/consumer/total_latencies",
          "labels": [
            {
              "key": "/credential_id"
            }
          ]
        },
        {
          "name": "serviceruntime.googleapis.com/api/producer/request_count",
          "labels": [
            {
              "key": "/protocol"
            },
            {
              "key": "/response_code"
            },
            {
              "key": "/response_code_class"
            },
            {
              "key": "/status_code"
            }
          ]
        },
        {
          "name": "serviceruntime.googleapis.com/api/producer/total_latencies"
        },
        {
          "name": "serviceruntime.googleapis.com/api/consumer/quota_used_count",
          "labels": [
            {
              "key": "/credential_id"
            },
            {
              "key": "/quota_group_name"
            }
          ]
        },
        {
          "name": "serviceruntime.googleapis.com/api/consumer/request_sizes",
          "labels": [
            {
              "key": "/credential_id"
            }
          ]
        },
        {
          "name": "serviceruntime.googleapis.com/api/consumer/response_sizes",
          "labels": [
            {
              "key": "/credential_id"
            }
          ]
        },
        {
          "name": "serviceruntime.googleapis.com/api/producer/request_overhead_latencies"
        },
        {
          "name": "serviceruntime.googleapis.com/api/producer/backend_latencies"
        },
        {
          "name": "serviceruntime.googleapis.com/api/producer/request_sizes"
        },
        {
          "name": "serviceruntime.googleapis.com/api/producer/response_sizes"
        }
      ],
      "monitoredResources": [
        {
          "type": "api",
          "labels": [
            {
              "key": "cloud.googleapis.com/location"
            },
            {
              "key": "cloud.googleapis.com/uid"
            },
            {
              "key": "serviceruntime.googleapis.com/api_version"
            },
            {
              "key": "serviceruntime.googleapis.com/api_method"
            },
            {
              "key": "serviceruntime.googleapis.com/consumer_project"
            },
            {
              "key": "cloud.googleapis.com/project"
            },
            {
              "key": "cloud.googleapis.com/service"
            }
          ]
        }
      ],
      "monitoring": {
        "consumerDestinations": [
          {
            "monitoredResource": "api",
            "metrics": [
              "serviceruntime.googleapis.com/api/consumer/request_count",
              "serviceruntime.googleapis.com/api/consumer/quota_used_count",
              "serviceruntime.googleapis.com/api/consumer/total_latencies",
              "serviceruntime.googleapis.com/api/consumer/request_sizes",
              "serviceruntime.googleapis.com/api/consumer/response_sizes"
            ]
          }
        ]
      },
      "id": "hello-2f8ts0sbxtpig"
    }
...

@timburks
Copy link
Contributor Author

rollouts:

$ curl https://servicemanagement.googleapis.com/v1/services/hello-1uw9r3za60r8p.apigateway.timburks-test.cloud.goog/rollouts -H "Authorization: Bearer `gcloud auth print-access-token`"
{
  "rollouts": [
    {
      "rolloutId": "2022-08-19r0",
      "createTime": "2022-08-19T03:52:21.036Z",
      "createdBy": "service-659507087217@gcp-sa-apigateway-mgmt.iam.gserviceaccount.com",
      "status": "SUCCESS",
      "trafficPercentStrategy": {
        "percentages": {
          "hello5-0lhnlcwseyqro": 100
        }
      },
      "serviceName": "hello-1uw9r3za60r8p.apigateway.timburks-test.cloud.goog"
    },
    {
      "rolloutId": "2022-08-18r0",
      "createTime": "2022-08-18T23:47:37.757Z",
      "createdBy": "service-659507087217@gcp-sa-apigateway-mgmt.iam.gserviceaccount.com",
      "status": "SUCCESS",
      "trafficPercentStrategy": {
        "percentages": {
          "hello4-0p68fyurn0bdw": 100
        }
      },
      "serviceName": "hello-1uw9r3za60r8p.apigateway.timburks-test.cloud.goog"
    },
    {
      "rolloutId": "2022-08-12r2",
      "createTime": "2022-08-12T22:13:27.748Z",
      "createdBy": "service-659507087217@gcp-sa-apigateway-mgmt.iam.gserviceaccount.com",
      "status": "SUCCESS",
      "trafficPercentStrategy": {
        "percentages": {
          "hello3-0ke4tee1dkbaf": 100
        }
      },
      "serviceName": "hello-1uw9r3za60r8p.apigateway.timburks-test.cloud.goog"
    },
    {
      "rolloutId": "2022-08-12r1",
      "createTime": "2022-08-12T21:53:16.256Z",
      "createdBy": "service-659507087217@gcp-sa-apigateway-mgmt.iam.gserviceaccount.com",
      "status": "SUCCESS",
      "trafficPercentStrategy": {
        "percentages": {
          "hello2-2zv5ghdtyg9ls": 100
        }
      },
      "serviceName": "hello-1uw9r3za60r8p.apigateway.timburks-test.cloud.goog"
    },
    {
      "rolloutId": "2022-08-12r0",
      "createTime": "2022-08-12T21:08:37.209Z",
      "createdBy": "service-659507087217@gcp-sa-apigateway-mgmt.iam.gserviceaccount.com",
      "status": "SUCCESS",
      "trafficPercentStrategy": {
        "percentages": {
          "hello-2f8ts0sbxtpig": 100
        }
      },
      "serviceName": "hello-1uw9r3za60r8p.apigateway.timburks-test.cloud.goog"
    }
  ]
}

@timburks timburks moved this to Todo in Apigee API Registry Apr 5, 2023
@timburks timburks moved this from Todo to Discussion in Apigee API Registry Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Discussion
Development

No branches or pull requests

1 participant