Skip to content

Commit

Permalink
feat: implement REST bulk download segment users (#1448)
Browse files Browse the repository at this point in the history
Part of #1417
  • Loading branch information
hvn2k1 authored Jan 14, 2025
1 parent af47c18 commit 03efd5d
Show file tree
Hide file tree
Showing 9 changed files with 884 additions and 626 deletions.
60 changes: 60 additions & 0 deletions api-description/web-api.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3664,6 +3664,66 @@ paths:
$ref: '#/definitions/featureUpdateSegmentRequest'
tags:
- segment
/v1/segment_users/bulk_download:
get:
summary: Bulk download
description: Bulk download segment users.
operationId: web.v1.segment_users.bulk_download
responses:
"200":
description: A successful response.
schema:
$ref: '#/definitions/featureBulkDownloadSegmentUsersResponse'
"400":
description: Returned for bad requests that may have failed validation.
schema:
$ref: '#/definitions/googlerpcStatus'
examples:
application/json:
code: 3
details: []
message: invalid arguments error
"401":
description: Request could not be authenticated (authentication required).
schema:
$ref: '#/definitions/googlerpcStatus'
examples:
application/json:
code: 16
details: []
message: not authenticated
"503":
description: Returned for internal errors.
schema:
$ref: '#/definitions/googlerpcStatus'
examples:
application/json:
code: 13
details: []
message: internal
default:
description: An unexpected error response.
schema:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: segmentId
in: query
required: true
type: string
- name: state
in: query
required: false
type: string
enum:
- INCLUDED
- EXCLUDED
default: INCLUDED
- name: environmentId
in: query
required: true
type: string
tags:
- segment
/v1/segment_users/bulk_upload:
post:
summary: Bulk upload
Expand Down
2 changes: 1 addition & 1 deletion manifests/bucketeer/charts/api/values.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion manifests/bucketeer/charts/web/values.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/feature/api/segment_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ func (s *FeatureService) BulkDownloadSegmentUsers(
segmentStorage := v2fs.NewSegmentStorage(s.mysqlClient)
segment, _, err := segmentStorage.GetSegment(ctx, req.SegmentId, req.EnvironmentId)
if err != nil {
if err == v2fs.ErrSegmentNotFound {
if errors.Is(err, v2fs.ErrSegmentNotFound) {
dt, err := statusSegmentNotFound.WithDetails(&errdetails.LocalizedMessage{
Locale: localizer.GetLocale(),
Message: localizer.MustLocalize(locale.NotFoundError),
Expand Down
Binary file modified proto/feature/proto_descriptor.pb
Binary file not shown.
1,266 changes: 649 additions & 617 deletions proto/feature/service.pb.go

Large diffs are not rendered by default.

38 changes: 35 additions & 3 deletions proto/feature/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,9 @@ message BulkUploadSegmentUsersResponse {}

message BulkDownloadSegmentUsersRequest {
reserved 1;
string segment_id = 2;
string segment_id = 2 [(google.api.field_behavior) = REQUIRED];
SegmentUser.State state = 3;
string environment_id = 4;
string environment_id = 4 [(google.api.field_behavior) = REQUIRED];
}

message BulkDownloadSegmentUsersResponse {
Expand Down Expand Up @@ -779,7 +779,39 @@ service FeatureService {
};
}
rpc BulkDownloadSegmentUsers(BulkDownloadSegmentUsersRequest)
returns (BulkDownloadSegmentUsersResponse) {}
returns (BulkDownloadSegmentUsersResponse) {
option (google.api.http) = {
get: "/v1/segment_users/bulk_download"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Bulk download",
description: "Bulk download segment users."
tags: "segment"
operation_id: "web.v1.segment_users.bulk_download"
responses: {
key: "400"
value: {
description: "Returned for bad requests that may have failed validation."
schema: { json_schema: { ref: ".google.rpc.Status" } }
examples: {
key: "application/json"
value: '{ "code": 3, "message": "invalid arguments error", "details": [] }'
}
}
}
responses: {
key: "401"
value: {
description: "Request could not be authenticated (authentication required)."
schema: { json_schema: { ref: ".google.rpc.Status" } }
examples: {
key: "application/json"
value: '{ "code": 16, "message": "not authenticated", "details": [] }'
}
}
}
};
}
rpc EvaluateFeatures(EvaluateFeaturesRequest)
returns (EvaluateFeaturesResponse) {}
rpc ListTags(ListTagsRequest) returns (ListTagsResponse) {
Expand Down
Binary file modified proto/gateway/proto_descriptor.pb
Binary file not shown.
140 changes: 137 additions & 3 deletions proto/proto.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24410,7 +24410,13 @@
{
"id": 2,
"name": "segment_id",
"type": "string"
"type": "string",
"options": [
{
"name": "(google.api.field_behavior)",
"value": "REQUIRED"
}
]
},
{
"id": 3,
Expand All @@ -24420,7 +24426,13 @@
{
"id": 4,
"name": "environment_id",
"type": "string"
"type": "string",
"options": [
{
"name": "(google.api.field_behavior)",
"value": "REQUIRED"
}
]
}
],
"reserved_ids": [
Expand Down Expand Up @@ -25738,7 +25750,129 @@
{
"name": "BulkDownloadSegmentUsers",
"in_type": "BulkDownloadSegmentUsersRequest",
"out_type": "BulkDownloadSegmentUsersResponse"
"out_type": "BulkDownloadSegmentUsersResponse",
"options": [
{
"name": "(google.api.http)",
"aggregated": [
{
"name": "get",
"value": "/v1/segment_users/bulk_download"
}
]
},
{
"name": "(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation)",
"aggregated": [
{
"name": "summary",
"value": "Bulk download"
},
{
"name": "description",
"value": "Bulk download segment users."
},
{
"name": "tags",
"value": "segment"
},
{
"name": "operation_id",
"value": "web.v1.segment_users.bulk_download"
},
{
"name": "responses",
"aggregated": [
{
"name": "key",
"value": "400"
},
{
"name": "value",
"aggregated": [
{
"name": "description",
"value": "Returned for bad requests that may have failed validation."
},
{
"name": "schema",
"aggregated": [
{
"name": "json_schema",
"aggregated": [
{
"name": "ref",
"value": ".google.rpc.Status"
}
]
}
]
},
{
"name": "examples",
"aggregated": [
{
"name": "key",
"value": "application/json"
},
{
"name": "value",
"value": "{\"code\":3,\"message\":\"invalid arguments error\",\"details\":[]}"
}
]
}
]
}
]
},
{
"name": "responses",
"aggregated": [
{
"name": "key",
"value": "401"
},
{
"name": "value",
"aggregated": [
{
"name": "description",
"value": "Request could not be authenticated (authentication required)."
},
{
"name": "schema",
"aggregated": [
{
"name": "json_schema",
"aggregated": [
{
"name": "ref",
"value": ".google.rpc.Status"
}
]
}
]
},
{
"name": "examples",
"aggregated": [
{
"name": "key",
"value": "application/json"
},
{
"name": "value",
"value": "{\"code\":16,\"message\":\"not authenticated\",\"details\":[]}"
}
]
}
]
}
]
}
]
}
]
},
{
"name": "EvaluateFeatures",
Expand Down

0 comments on commit 03efd5d

Please sign in to comment.