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

feat: add new query APIs #399

Merged
merged 3 commits into from
Aug 3, 2023
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ build/
vendor/
.local
.task
coverage.out
38 changes: 38 additions & 0 deletions proto/greenfield/storage/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,21 @@ service Query {
option (google.api.http).get = "/greenfield/storage/is_price_changed/{bucket_name}";
}

// Queries whether some members are in the group.
rpc QueryGroupMembersExist(QueryGroupMembersExistRequest) returns (QueryGroupMembersExistResponse) {
option (google.api.http).get = "/greenfield/storage/group_members_exist/{group_id}/{members}";
unclezoro marked this conversation as resolved.
Show resolved Hide resolved
}

// Queries whether some groups are exist.
rpc QueryGroupsExist(QueryGroupsExistRequest) returns (QueryGroupsExistResponse) {
option (google.api.http).get = "/greenfield/storage/groups_exist/{group_owner}/{group_names}";
}

// Queries whether some groups are exist by id.
rpc QueryGroupsExistById(QueryGroupsExistByIdRequest) returns (QueryGroupsExistResponse) {
option (google.api.http).get = "/greenfield/storage/groups_exist_by_id/{group_ids}";
}

// this line is used by starport scaffolding # 2
}

Expand Down Expand Up @@ -356,4 +371,27 @@ message QueryIsPriceChangedResponse {
(gogoproto.nullable) = false
];
}

message QueryGroupMembersExistRequest {
string group_id = 1;
repeated string members = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

message QueryGroupMembersExistResponse {
map<string, bool> exists = 1;
}

message QueryGroupsExistRequest {
string group_owner = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated string group_names = 2;
}

message QueryGroupsExistByIdRequest {
repeated string group_ids = 1;
}

message QueryGroupsExistResponse {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we unify the name of the API? E,g. HeadGroup, HeadGroups, HeadGroupById, HeadGroupsByIds, HeadGroupMember, HeanGroupMemebers

Copy link
Contributor Author

@pythonberg1997 pythonberg1997 Jul 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The methods you mentioned are all existed. These new APIs are just used to query if the object exists

map<string, bool> exists = 1;
}

// this line is used by starport scaffolding # 3
163 changes: 163 additions & 0 deletions swagger/static/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2198,6 +2198,155 @@ paths:
type: boolean
tags:
- Query
/greenfield/storage/group_members_exist/{group_id}/{members}:
get:
summary: Queries whether some members are in the group.
operationId: QueryGroupMembersExist
responses:
'200':
description: A successful response.
schema:
type: object
properties:
exists:
type: object
additionalProperties:
type: boolean
default:
description: An unexpected error response.
schema:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
type_url:
type: string
value:
type: string
format: byte
parameters:
- name: group_id
in: path
required: true
type: string
- name: members
in: path
required: true
type: array
items:
type: string
collectionFormat: csv
minItems: 1
tags:
- Query
/greenfield/storage/groups_exist/{group_owner}/{group_names}:
get:
summary: Queries whether some groups are exist.
operationId: QueryGroupsExist
responses:
'200':
description: A successful response.
schema:
type: object
properties:
exists:
type: object
additionalProperties:
type: boolean
default:
description: An unexpected error response.
schema:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
type_url:
type: string
value:
type: string
format: byte
parameters:
- name: group_owner
in: path
required: true
type: string
- name: group_names
in: path
required: true
type: array
items:
type: string
collectionFormat: csv
minItems: 1
tags:
- Query
/greenfield/storage/groups_exist_by_id/{group_ids}:
get:
summary: Queries whether some groups are exist by id.
operationId: QueryGroupsExistById
responses:
'200':
description: A successful response.
schema:
type: object
properties:
exists:
type: object
additionalProperties:
type: boolean
default:
description: An unexpected error response.
schema:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
type_url:
type: string
value:
type: string
format: byte
parameters:
- name: group_ids
in: path
required: true
type: array
items:
type: string
collectionFormat: csv
minItems: 1
tags:
- Query
/greenfield/storage/head_bucket/{bucket_name}:
get:
summary: Queries a bucket with specify name.
Expand Down Expand Up @@ -33742,6 +33891,13 @@ definitions:
value:
type: string
title: attributes
greenfield.storage.QueryGroupMembersExistResponse:
type: object
properties:
exists:
type: object
additionalProperties:
type: boolean
greenfield.storage.QueryGroupNFTResponse:
type: object
properties:
Expand Down Expand Up @@ -33770,6 +33926,13 @@ definitions:
value:
type: string
title: attributes
greenfield.storage.QueryGroupsExistResponse:
type: object
properties:
exists:
type: object
additionalProperties:
type: boolean
greenfield.storage.QueryHeadBucketExtraResponse:
type: object
properties:
Expand Down
Loading
Loading