Skip to content

Use APIM #37

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

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.tools
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export TOOLS_BUILDNUMBER=20241007.3
export TOOLS_BUILDNUMBER=20241108.3
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Generate, Test and Export
run: |
# Note: it is by design that we don't use the builder
task local-all
task all

- name: Show exports
working-directory: exported/
Expand Down
25 changes: 0 additions & 25 deletions .github/workflows/workflow.yml

This file was deleted.

53 changes: 9 additions & 44 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,60 +21,25 @@ includes:
# dev-notes/build-warts.md#always-set-dir-relative-to-current-task-file
dir: ./taskfiles

vars:
ACR: rkvstdev.azurecr.io
# Default to the stage master-latest builder image
# Note: the CI tags builder images with the build number of the avid-builder pipeline run,
# i.e. 20220607.10
# For local builder development build run `task builder` in the avid-builder git repo to
# build a new local builder image, then run these tasks like
# task generate BUILDER_ACR=rkvstdev.azurecr.io BUILDER_IMAGE_TAG=dev-$USER
BUILDER_ACR: rkvststage.azurecr.io
BUILDER_IMAGE_TAG: master-latest

BUILD_CONTAINER: go-datatrails-common-api-builder

tasks:

### -------------------------
# Docker container tasks
### -------------------------

builder-start:
summary: |
Creates the build container for go-datatrails-common-api

Many tasks docker exec into this container so DO NOT ADD --rm.

Use defer to cleanup the docker container in top level workflow tasks
which create the builder container
vars:
BUILDER_IMAGE: '{{.BUILDER_ACR}}/avid-builder:{{.BUILDER_IMAGE_TAG}}'
default:
desc: Default task lists all available tasks to run.
cmds:
- which task
- |
docker run \
--env CONCURRENCY={{.SKAFFOLD_CONCURRENCY | default 2}} \
--name {{.BUILD_CONTAINER}} \
-dt -u $(id -u):$(id -g) \
--mount type=bind,src=$(pwd),dst=/avid -w /avid \
{{.BUILDER_IMAGE}}
task --list --sort=none

builder-cleanup:
summary: cleans up the forestrie build container
environment:
desc: Show environment and location of tools executables.
cmds:
- docker rm -f {{.BUILD_CONTAINER}}
- env | sort
- which go

### -------------------------
# Primary workflow tasks
### -------------------------
all:
desc: "do everything necessary after clone (or rebase) in the builder"
cmds:
- task: builder-start
- defer: {task: builder-cleanup}
- docker exec -t {{.BUILD_CONTAINER}} task local-all

local-all:
desc: |
do everything necessary after clone (or rebase) (faster as it RUNS ON NATIVE HOST)

Expand Down Expand Up @@ -105,4 +70,4 @@ tasks:
generate:
desc: generates all the artifacts we need pre-build
cmds:
- task: apis:generate
- task: apis:generate
85 changes: 55 additions & 30 deletions datatrails-common-api/assets/v2/assets/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@ option go_package="github.com/datatrails/go-datatrails-common-api-gen/assets/v2/

import "google/api/annotations.proto";
import "protoc-gen-openapiv2/options/annotations.proto";

import "datatrails-common-api/assets/v2/assets/assetresponse.proto";
import "datatrails-common-api/caps/v1/caps/caps.proto";
import "datatrails-common-api/assets/v2/assets/createasset.proto";
import "datatrails-common-api/assets/v2/assets/assetresponse.proto";
import "datatrails-common-api/assets/v2/assets/getasset.proto";
import "datatrails-common-api/assets/v2/assets/listassets.proto";
import "datatrails-common-api/assets/v2/assets/createevent.proto";
import "datatrails-common-api/assets/v2/assets/eventresponse.proto";
import "datatrails-common-api/assets/v2/assets/getasset.proto";
import "datatrails-common-api/assets/v2/assets/getevent.proto";
import "datatrails-common-api/assets/v2/assets/listassets.proto";
import "datatrails-common-api/assets/v2/assets/listevents.proto";
import "datatrails-common-api/assets/v2/assets/miscmessages.proto";
import "datatrails-common-api/caps/v1/caps/caps.proto";

option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info: {
Expand All @@ -25,41 +24,28 @@ option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
version: "2.0"
contact: {
name: "DataTrails"
url: "https://www.datatrails.com"
url: "https://www.datatrails.ai"
}
};
base_path: "/_api";
base_path: "/archivist/v2/assets";
schemes: HTTPS;
consumes: "application/json";
produces: "application/json";
tags: [
{
name: "Assets & Events",
name: "Assets and Events",
description: "Primary API for Asset management"
},
{
name: "Unsupported",
description: "Internal APIs that are unstable and should not be used in a production setting."
}
];
};

service Events {
rpc Create(CreateEventRequest) returns (EventResponse) {
option (google.api.http) = {
post: "/archivist/v2/assets/{uuid}/events"
body: "*"
};
}
}

service Assets {
rpc ListAssets(ListAssetsRequest) returns (ListAssetsResponse) {
option (google.api.http) = {
get: "/archivist/v2/assets"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Assets & Events" ]
tags: [ "Assets and Events" ]
summary: "List Assets"
description: "Retrieves a list of Assets"
responses: {
Expand All @@ -83,6 +69,12 @@ service Assets {
description: "Returned when the user is not authenticated to the system."
}
}
responses: {
key: "402";
value: {
description: "Returned when the user's quota of Assets for the given proof mechanism has been reached."
}
}
responses: {
key: "403";
value: {
Expand All @@ -104,7 +96,7 @@ service Assets {
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Assets & Events" ]
tags: [ "Assets and Events" ]
summary: "Create an Asset"
description: "Creates an Asset"
responses: {
Expand Down Expand Up @@ -139,7 +131,7 @@ service Assets {
get: "/archivist/v2/assets/{uuid}"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Assets & Events" ]
tags: [ "Assets and Events" ]
summary: "Retrieves a specific Asset"
description: "Retrieves a specific Asset"
responses: {
Expand Down Expand Up @@ -174,7 +166,7 @@ service Assets {
get: "/archivist/v2/assets/{uuid}:publicurl"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Assets & Events" ]
tags: [ "Assets and Events" ]
summary: "Retrieves the public url for a specific Asset."
description: "Retrieves the public url for a specific Asset."
responses: {
Expand Down Expand Up @@ -209,7 +201,7 @@ service Assets {
get: "/archivist/v2/assets/{asset_uuid}/events/{uuid}"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Assets & Events" ]
tags: [ "Assets and Events" ]
summary: "Retrieves Event"
description: "Retrieves a specific Event"
responses: {
Expand Down Expand Up @@ -244,7 +236,7 @@ service Assets {
get: "/archivist/v2/assets/{asset_uuid}/events/{uuid}:publicurl"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Assets & Events" ]
tags: [ "Assets and Events" ]
summary: "Retrieves the public url for a specific Event."
description: "Retrieves the public url for a specific Event."
responses: {
Expand Down Expand Up @@ -279,7 +271,7 @@ service Assets {
get: "/archivist/v2/assets/{uuid}/events"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Assets & Events" ]
tags: [ "Assets and Events" ]
summary: "List Events"
description: "Lists Events"
responses: {
Expand Down Expand Up @@ -324,7 +316,7 @@ service Assets {
get: "/archivist/v2/assets:caps"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Assets & Events", "Unsupported" ] // Unsupported is signal for future OAPI parsing
tags: [ "Assets and Events", "Unsupported" ] // Unsupported is signal for future OAPI parsing
summary: "Get remaining capped resources for Assets"
description: "Not stable or officially supported. Get remaining capped resources for Assets"
responses: {
Expand All @@ -341,4 +333,37 @@ service Assets {
}
};
}
}
}

service Events {
rpc Create(CreateEventRequest) returns (EventResponse) {
option (google.api.http) = {
post: "/archivist/v2/assets/{uuid}/events"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
tags: [ "Assets and Events" ]
summary: "Creates an Event"
description: "Creates an Event"
responses: {
key: "401";
value: {
description: "Returned when the user is not authenticated to the system."
}
}
responses: {
key: "402";
value: {
description: "Returned when the user's quota of Events has been reached."
}
}
responses: {
key: "429";
value: {
description: "Returned when a user exceeds their subscription's rate limit for requests.";
}
}
};
}
}

7 changes: 2 additions & 5 deletions taskfiles/Taskfile_apis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ tasks:
rm -rf {{.GOOGLE_COMMON_INC_ARCHIVE_BASEDIR}}-{{.GOOGLE_COMMON_PROTOS_VERSION}}
find proto-include -type d


bootstrap:grpc_health:
desc: download and prepare the grpc health definitions we require under proto-include
dir: '..'
Expand Down Expand Up @@ -114,15 +113,12 @@ tasks:
github.com/envoyproxy/protoc-gen-validate
cmds:
- |
go get github.com/datatrails/go-datatrails-common-api-gen/tools

go install \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
google.golang.org/protobuf/cmd/protoc-gen-go \
google.golang.org/grpc/cmd/protoc-gen-go-grpc \
github.com/envoyproxy/protoc-gen-validate \
github.com/lyft/protoc-gen-star/v2 \
github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc
- for: { var: API_PROTO_DEPS }
cmd: |
Expand Down Expand Up @@ -156,6 +152,7 @@ tasks:
dir: '../datatrails-common-api'
cmds:
- go mod tidy
- go mod verify

generate:
desc: generate api grpc bindings
Expand Down Expand Up @@ -278,4 +275,4 @@ tasks:
# OUTPATH: datatrails-common-api
OUTPATH: .
GOBIN:
sh: echo ${GOBIN:-$HOME/go/bin}
sh: echo ${GOBIN:-$HOME/go/bin}
Loading