-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f56b19d
commit 287a112
Showing
7 changed files
with
111 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2016 Google, Inc. | ||
* | ||
* 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. | ||
*/ | ||
|
||
// 1. syntax, package, option | ||
syntax = "proto3"; | ||
|
||
package com.example.grpc; | ||
|
||
option java_multiple_files = true; | ||
import "request/helloRequest.proto"; | ||
import "response/helloResponse.proto"; | ||
import "google/protobuf/empty.proto"; | ||
import "google/protobuf/any.proto"; | ||
|
||
// 4. service, unary request/response | ||
service GreetingService { | ||
rpc greeting(com.example.grpc.request.HelloRequest) returns (com.example.grpc.response.HelloResponse); | ||
rpc manyGreetingsOneReply(stream com.example.grpc.request.HelloRequest) returns (com.example.grpc.response.HelloResponse); | ||
rpc oneGreetingManyReplies(com.example.grpc.request.HelloRequest) returns (stream com.example.grpc.response.HelloResponse); | ||
rpc oneGreetingEmptyReply(com.example.grpc.request.HelloRequest) returns (google.protobuf.Empty); | ||
rpc greetingAnyRequest(google.protobuf.Any) returns ( com.example.grpc.response.HelloResponse) ; | ||
rpc greetingAnyResponse(com.example.grpc.request.HelloRequest) returns (google.protobuf.Any) ; | ||
} | ||
|
||
service AnotherGreetingService { | ||
rpc differentGreeting(com.example.grpc.request.HelloRequest) returns (com.example.grpc.response.HelloResponse); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
syntax = "proto3"; | ||
|
||
package com.example.grpc.request; | ||
|
||
option java_multiple_files = true; | ||
import "request/models/sentiment.proto"; | ||
|
||
message HelloRequest { | ||
string name = 1; | ||
int32 age = 2; | ||
repeated string hobbies = 3; | ||
map<string, string> bagOfTricks = 4; | ||
com.example.grpc.request.models.Sentiment sentiment = 5; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
syntax = "proto3"; | ||
|
||
package com.example.grpc.request.models; | ||
|
||
option java_multiple_files = true; | ||
|
||
enum Sentiment { | ||
HAPPY = 0; | ||
SLEEPY = 1; | ||
ANGRY = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
syntax = "proto3"; | ||
|
||
package com.example.grpc.response; | ||
|
||
option java_multiple_files = true; | ||
|
||
message HelloResponse { | ||
string greeting = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eo pipefail | ||
|
||
if [ -z "$WIREMOCK_API_TOKEN" ]; then | ||
echo "Environment variable WIREMOCK_API_TOKEN must be set with a valid API token" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$MOCK_API_ID" ]; then | ||
echo "Environment variable MOCK_API_ID must be set with the target API's ID string e.g. ek2z9" | ||
exit 1 | ||
fi | ||
|
||
mkdir -p build | ||
protoc --descriptor_set_out=build/services.dsc --include_imports --include_source_info --proto_path=proto proto/*.proto | ||
|
||
curl "https://api.wiremock.cloud/v1/mock-apis/$MOCK_API_ID/__admin/ext/grpc/descriptor" \ | ||
-X PUT \ | ||
--data-binary @build/services.dsc \ | ||
-H 'content-type:application/octet-stream' \ | ||
-H "authorization:Token $WIREMOCK_API_TOKEN" | ||
|