Skip to content

Commit d6fe643

Browse files
authored
Use APIM (#37)
* AB#10288 * Use apim The assets proto file is now suitable for APIM Removed the requirement for avid-builder Added standard default and environment runes Removed workflow(docker-all) git hub action AB#10288
1 parent 6107ca0 commit d6fe643

File tree

6 files changed

+68
-107
lines changed

6 files changed

+68
-107
lines changed

.env.tools

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export TOOLS_BUILDNUMBER=20241007.3
1+
export TOOLS_BUILDNUMBER=20241108.3

.github/workflows/ci.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ jobs:
2929
repo-token: ${{ secrets.GITHUB_TOKEN }}
3030
- name: Generate, Test and Export
3131
run: |
32-
# Note: it is by design that we don't use the builder
33-
task local-all
32+
task all
3433
3534
- name: Show exports
3635
working-directory: exported/

.github/workflows/workflow.yml

-25
This file was deleted.

Taskfile.yml

+9-44
Original file line numberDiff line numberDiff line change
@@ -21,60 +21,25 @@ includes:
2121
# dev-notes/build-warts.md#always-set-dir-relative-to-current-task-file
2222
dir: ./taskfiles
2323

24-
vars:
25-
ACR: rkvstdev.azurecr.io
26-
# Default to the stage master-latest builder image
27-
# Note: the CI tags builder images with the build number of the avid-builder pipeline run,
28-
# i.e. 20220607.10
29-
# For local builder development build run `task builder` in the avid-builder git repo to
30-
# build a new local builder image, then run these tasks like
31-
# task generate BUILDER_ACR=rkvstdev.azurecr.io BUILDER_IMAGE_TAG=dev-$USER
32-
BUILDER_ACR: rkvststage.azurecr.io
33-
BUILDER_IMAGE_TAG: master-latest
34-
35-
BUILD_CONTAINER: go-datatrails-common-api-builder
36-
3724
tasks:
3825

39-
### -------------------------
40-
# Docker container tasks
41-
### -------------------------
42-
43-
builder-start:
44-
summary: |
45-
Creates the build container for go-datatrails-common-api
46-
47-
Many tasks docker exec into this container so DO NOT ADD --rm.
48-
49-
Use defer to cleanup the docker container in top level workflow tasks
50-
which create the builder container
51-
vars:
52-
BUILDER_IMAGE: '{{.BUILDER_ACR}}/avid-builder:{{.BUILDER_IMAGE_TAG}}'
26+
default:
27+
desc: Default task lists all available tasks to run.
5328
cmds:
29+
- which task
5430
- |
55-
docker run \
56-
--env CONCURRENCY={{.SKAFFOLD_CONCURRENCY | default 2}} \
57-
--name {{.BUILD_CONTAINER}} \
58-
-dt -u $(id -u):$(id -g) \
59-
--mount type=bind,src=$(pwd),dst=/avid -w /avid \
60-
{{.BUILDER_IMAGE}}
31+
task --list --sort=none
6132
62-
builder-cleanup:
63-
summary: cleans up the forestrie build container
33+
environment:
34+
desc: Show environment and location of tools executables.
6435
cmds:
65-
- docker rm -f {{.BUILD_CONTAINER}}
36+
- env | sort
37+
- which go
6638

6739
### -------------------------
6840
# Primary workflow tasks
6941
### -------------------------
7042
all:
71-
desc: "do everything necessary after clone (or rebase) in the builder"
72-
cmds:
73-
- task: builder-start
74-
- defer: {task: builder-cleanup}
75-
- docker exec -t {{.BUILD_CONTAINER}} task local-all
76-
77-
local-all:
7843
desc: |
7944
do everything necessary after clone (or rebase) (faster as it RUNS ON NATIVE HOST)
8045
@@ -105,4 +70,4 @@ tasks:
10570
generate:
10671
desc: generates all the artifacts we need pre-build
10772
cmds:
108-
- task: apis:generate
73+
- task: apis:generate

datatrails-common-api/assets/v2/assets/service.proto

+55-30
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@ option go_package="github.com/datatrails/go-datatrails-common-api-gen/assets/v2/
66

77
import "google/api/annotations.proto";
88
import "protoc-gen-openapiv2/options/annotations.proto";
9-
10-
import "datatrails-common-api/assets/v2/assets/assetresponse.proto";
9+
import "datatrails-common-api/caps/v1/caps/caps.proto";
1110
import "datatrails-common-api/assets/v2/assets/createasset.proto";
11+
import "datatrails-common-api/assets/v2/assets/assetresponse.proto";
12+
import "datatrails-common-api/assets/v2/assets/getasset.proto";
13+
import "datatrails-common-api/assets/v2/assets/listassets.proto";
1214
import "datatrails-common-api/assets/v2/assets/createevent.proto";
1315
import "datatrails-common-api/assets/v2/assets/eventresponse.proto";
14-
import "datatrails-common-api/assets/v2/assets/getasset.proto";
1516
import "datatrails-common-api/assets/v2/assets/getevent.proto";
16-
import "datatrails-common-api/assets/v2/assets/listassets.proto";
1717
import "datatrails-common-api/assets/v2/assets/listevents.proto";
1818
import "datatrails-common-api/assets/v2/assets/miscmessages.proto";
19-
import "datatrails-common-api/caps/v1/caps/caps.proto";
2019

2120
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
2221
info: {
@@ -25,41 +24,28 @@ option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
2524
version: "2.0"
2625
contact: {
2726
name: "DataTrails"
28-
url: "https://www.datatrails.com"
27+
url: "https://www.datatrails.ai"
2928
}
3029
};
31-
base_path: "/_api";
30+
base_path: "/archivist/v2/assets";
3231
schemes: HTTPS;
3332
consumes: "application/json";
3433
produces: "application/json";
3534
tags: [
3635
{
37-
name: "Assets & Events",
36+
name: "Assets and Events",
3837
description: "Primary API for Asset management"
39-
},
40-
{
41-
name: "Unsupported",
42-
description: "Internal APIs that are unstable and should not be used in a production setting."
4338
}
4439
];
4540
};
4641

47-
service Events {
48-
rpc Create(CreateEventRequest) returns (EventResponse) {
49-
option (google.api.http) = {
50-
post: "/archivist/v2/assets/{uuid}/events"
51-
body: "*"
52-
};
53-
}
54-
}
55-
5642
service Assets {
5743
rpc ListAssets(ListAssetsRequest) returns (ListAssetsResponse) {
5844
option (google.api.http) = {
5945
get: "/archivist/v2/assets"
6046
};
6147
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
62-
tags: [ "Assets & Events" ]
48+
tags: [ "Assets and Events" ]
6349
summary: "List Assets"
6450
description: "Retrieves a list of Assets"
6551
responses: {
@@ -83,6 +69,12 @@ service Assets {
8369
description: "Returned when the user is not authenticated to the system."
8470
}
8571
}
72+
responses: {
73+
key: "402";
74+
value: {
75+
description: "Returned when the user's quota of Assets for the given proof mechanism has been reached."
76+
}
77+
}
8678
responses: {
8779
key: "403";
8880
value: {
@@ -104,7 +96,7 @@ service Assets {
10496
body: "*"
10597
};
10698
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
107-
tags: [ "Assets & Events" ]
99+
tags: [ "Assets and Events" ]
108100
summary: "Create an Asset"
109101
description: "Creates an Asset"
110102
responses: {
@@ -139,7 +131,7 @@ service Assets {
139131
get: "/archivist/v2/assets/{uuid}"
140132
};
141133
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
142-
tags: [ "Assets & Events" ]
134+
tags: [ "Assets and Events" ]
143135
summary: "Retrieves a specific Asset"
144136
description: "Retrieves a specific Asset"
145137
responses: {
@@ -174,7 +166,7 @@ service Assets {
174166
get: "/archivist/v2/assets/{uuid}:publicurl"
175167
};
176168
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
177-
tags: [ "Assets & Events" ]
169+
tags: [ "Assets and Events" ]
178170
summary: "Retrieves the public url for a specific Asset."
179171
description: "Retrieves the public url for a specific Asset."
180172
responses: {
@@ -209,7 +201,7 @@ service Assets {
209201
get: "/archivist/v2/assets/{asset_uuid}/events/{uuid}"
210202
};
211203
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
212-
tags: [ "Assets & Events" ]
204+
tags: [ "Assets and Events" ]
213205
summary: "Retrieves Event"
214206
description: "Retrieves a specific Event"
215207
responses: {
@@ -244,7 +236,7 @@ service Assets {
244236
get: "/archivist/v2/assets/{asset_uuid}/events/{uuid}:publicurl"
245237
};
246238
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
247-
tags: [ "Assets & Events" ]
239+
tags: [ "Assets and Events" ]
248240
summary: "Retrieves the public url for a specific Event."
249241
description: "Retrieves the public url for a specific Event."
250242
responses: {
@@ -279,7 +271,7 @@ service Assets {
279271
get: "/archivist/v2/assets/{uuid}/events"
280272
};
281273
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
282-
tags: [ "Assets & Events" ]
274+
tags: [ "Assets and Events" ]
283275
summary: "List Events"
284276
description: "Lists Events"
285277
responses: {
@@ -324,7 +316,7 @@ service Assets {
324316
get: "/archivist/v2/assets:caps"
325317
};
326318
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
327-
tags: [ "Assets & Events", "Unsupported" ] // Unsupported is signal for future OAPI parsing
319+
tags: [ "Assets and Events", "Unsupported" ] // Unsupported is signal for future OAPI parsing
328320
summary: "Get remaining capped resources for Assets"
329321
description: "Not stable or officially supported. Get remaining capped resources for Assets"
330322
responses: {
@@ -341,4 +333,37 @@ service Assets {
341333
}
342334
};
343335
}
344-
}
336+
}
337+
338+
service Events {
339+
rpc Create(CreateEventRequest) returns (EventResponse) {
340+
option (google.api.http) = {
341+
post: "/archivist/v2/assets/{uuid}/events"
342+
body: "*"
343+
};
344+
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
345+
tags: [ "Assets and Events" ]
346+
summary: "Creates an Event"
347+
description: "Creates an Event"
348+
responses: {
349+
key: "401";
350+
value: {
351+
description: "Returned when the user is not authenticated to the system."
352+
}
353+
}
354+
responses: {
355+
key: "402";
356+
value: {
357+
description: "Returned when the user's quota of Events has been reached."
358+
}
359+
}
360+
responses: {
361+
key: "429";
362+
value: {
363+
description: "Returned when a user exceeds their subscription's rate limit for requests.";
364+
}
365+
}
366+
};
367+
}
368+
}
369+

taskfiles/Taskfile_apis.yml

+2-5
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ tasks:
8080
rm -rf {{.GOOGLE_COMMON_INC_ARCHIVE_BASEDIR}}-{{.GOOGLE_COMMON_PROTOS_VERSION}}
8181
find proto-include -type d
8282
83-
8483
bootstrap:grpc_health:
8584
desc: download and prepare the grpc health definitions we require under proto-include
8685
dir: '..'
@@ -114,15 +113,12 @@ tasks:
114113
github.com/envoyproxy/protoc-gen-validate
115114
cmds:
116115
- |
117-
go get github.com/datatrails/go-datatrails-common-api-gen/tools
118-
119116
go install \
120117
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
121118
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
122119
google.golang.org/protobuf/cmd/protoc-gen-go \
123120
google.golang.org/grpc/cmd/protoc-gen-go-grpc \
124121
github.com/envoyproxy/protoc-gen-validate \
125-
github.com/lyft/protoc-gen-star/v2 \
126122
github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc
127123
- for: { var: API_PROTO_DEPS }
128124
cmd: |
@@ -156,6 +152,7 @@ tasks:
156152
dir: '../datatrails-common-api'
157153
cmds:
158154
- go mod tidy
155+
- go mod verify
159156

160157
generate:
161158
desc: generate api grpc bindings
@@ -278,4 +275,4 @@ tasks:
278275
# OUTPATH: datatrails-common-api
279276
OUTPATH: .
280277
GOBIN:
281-
sh: echo ${GOBIN:-$HOME/go/bin}
278+
sh: echo ${GOBIN:-$HOME/go/bin}

0 commit comments

Comments
 (0)