Skip to content

Instantly share code, notes, and snippets.

@timburks
Created September 22, 2021 00:47
Show Gist options
  • Save timburks/2c9e13baff1c7a7bd3d0be6a0fea77fc to your computer and use it in GitHub Desktop.
Save timburks/2c9e13baff1c7a7bd3d0be6a0fea77fc to your computer and use it in GitHub Desktop.
HTTP samples
#!/bin/sh
#
# Copyright 2021 Google LLC. All Rights Reserved.
#
# 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.
#
echo "\nGet server status"
curl $APG_REGISTRY_AUDIENCES/v1/status \
-i \
-H "Authorization: Bearer $APG_REGISTRY_TOKEN"
echo "\nCreate a project"
curl $APG_REGISTRY_AUDIENCES/v1/projects?project_id=test \
-X POST \
-H 'Content-Type: application/json' \
-d '{}' \
-i \
-H "Authorization: Bearer $APG_REGISTRY_TOKEN"
echo "\nCreate an API"
curl $APG_REGISTRY_AUDIENCES/v1/projects/test/locations/global/apis?api_id=petstore \
-X POST \
-H 'Content-Type: application/json' \
-d '{}' \
-i \
-H "Authorization: Bearer $APG_REGISTRY_TOKEN"
echo "\nCreate an API version"
curl $APG_REGISTRY_AUDIENCES/v1/projects/test/locations/global/apis/petstore/versions?api_version_id=1.0.0 \
-X POST \
-H 'Content-Type: application/json' \
-d '{}' \
-i \
-H "Authorization: Bearer $APG_REGISTRY_TOKEN"
echo "\nCreate an API spec"
curl $APG_REGISTRY_AUDIENCES/v1/projects/test/locations/global/apis/petstore/versions/1.0.0/specs?api_spec_id=html \
-X POST \
-H 'Content-Type: application/json' \
-d '{"contents":"PGgxPk9LPC9oMT4K", "mimeType": "text/html"}' \
-i \
-H "Authorization: Bearer $APG_REGISTRY_TOKEN"
echo "\nGet an API"
curl $APG_REGISTRY_AUDIENCES/v1/projects/test/locations/global/apis/petstore \
-i \
-H "Authorization: Bearer $APG_REGISTRY_TOKEN"
echo "\nGet an API Spec"
curl $APG_REGISTRY_AUDIENCES/v1/projects/test/locations/global/apis/petstore/versions/1.0.0/specs/html \
-i \
-H "Authorization: Bearer $APG_REGISTRY_TOKEN"
echo "\nGet the contents of a spec"
curl $APG_REGISTRY_AUDIENCES/v1/projects/test/locations/global/apis/petstore/versions/1.0.0/specs/html/contents \
-i \
-H "Authorization: Bearer $APG_REGISTRY_TOKEN"
echo "\nCreate an artifact"
curl $APG_REGISTRY_AUDIENCES/v1/projects/test/locations/global/artifacts?artifact_id=sample \
-X POST \
-H 'Content-Type: application/json' \
-d '{"contents":"aGVsbG8K"}' \
-i \
-H "Authorization: Bearer $APG_REGISTRY_TOKEN"
echo "\nList artifacts"
curl $APG_REGISTRY_AUDIENCES/v1/projects/test/locations/global/artifacts \
-i \
-H "Authorization: Bearer $APG_REGISTRY_TOKEN"
echo "\nGet the contents of an artifact"
curl $APG_REGISTRY_AUDIENCES/v1/projects/test/locations/global/artifacts/sample/contents \
-i \
-H "Authorization: Bearer $APG_REGISTRY_TOKEN"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment