1// Copyright 2018 Google LLC 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// https://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15syntax = "proto3"; 16 17import "google/api/annotations.proto"; 18import "google/api/client.proto"; 19import "google/api/field_behavior.proto"; 20import "google/api/resource.proto"; 21import "google/protobuf/empty.proto"; 22import "google/protobuf/field_mask.proto"; 23import "google/protobuf/timestamp.proto"; 24 25package google.showcase.v1beta1; 26 27option go_package = "github.com/googleapis/gapic-showcase/server/genproto"; 28option java_package = "com.google.showcase.v1beta1"; 29option java_multiple_files = true; 30 31// A simple identity service. 32service Identity { 33 // This service is meant to only run locally on the port 7469 (keypad digits 34 // for "show"). 35 option (google.api.default_host) = "localhost:7469"; 36 option (google.api.oauth_scopes) = 37 "https://www.googleapis.com/auth/cloud-platform"; 38 39 // Creates a user. 40 rpc CreateUser(CreateUserRequest) returns (User) { 41 option (google.api.http) = { 42 post: "/v1beta1/{parent=users}" 43 body: "*" 44 }; 45 option (google.api.method_signature) = 46 "parent,user.display_name,user.email"; 47 option (google.api.method_signature) = 48 "parent,user.display_name,user.email,user.age,user.nickname,user.enable_notifications,user.height_feet"; 49 // Test nested method arguments and ensure that order doesn't matter. 50 option (google.api.method_signature) = 51 "parent,user.display_name,user.email,user.hobby.hobby_name,user.song.song_name,user.hobby.weekly_frequency,user.song.song_artist.recording_company.company_name,user.hobby.instruction_manual.title,user.hobby.instruction_manual.subject,user.song.song_artist.artist_name"; 52 } 53 54 // Retrieves the User with the given uri. 55 rpc GetUser(GetUserRequest) returns (User) { 56 option (google.api.http) = { 57 get: "/v1beta1/{name=users/*}" 58 }; 59 option (google.api.method_signature) = "name"; 60 } 61 62 // Updates a user. 63 rpc UpdateUser(UpdateUserRequest) returns (User) { 64 option (google.api.http) = { 65 patch: "/v1beta1/{user.name=users/*}" 66 body: "*" 67 }; 68 } 69 70 // Deletes a user, their profile, and all of their authored messages. 71 rpc DeleteUser(DeleteUserRequest) returns (google.protobuf.Empty) { 72 option (google.api.http) = { 73 delete: "/v1beta1/{name=users/*}" 74 }; 75 option (google.api.method_signature) = "name"; 76 } 77 78 // Lists all users. 79 rpc ListUsers(ListUsersRequest) returns (ListUsersResponse) { 80 option (google.api.http) = { 81 get: "/v1beta1/users" 82 }; 83 } 84} 85 86// A user. 87message User { 88 option (google.api.resource) = { 89 type: "showcase.googleapis.com/User" 90 pattern: "users/{user}" 91 }; 92 93 // The resource name of the user. 94 string name = 1; 95 96 // The display_name of the user. 97 string display_name = 2 [(google.api.field_behavior) = REQUIRED]; 98 99 // The email address of the user. 100 string email = 3 [(google.api.field_behavior) = REQUIRED]; 101 102 // The timestamp at which the user was created. 103 google.protobuf.Timestamp create_time = 4 104 [(google.api.field_behavior) = OUTPUT_ONLY]; 105 106 // The latest timestamp at which the user was updated. 107 google.protobuf.Timestamp update_time = 5 108 [(google.api.field_behavior) = OUTPUT_ONLY]; 109 110 // The age of the use in years. 111 optional int32 age = 6; 112 113 // The height of the user in feet. 114 optional double height_feet = 7; 115 116 // The nickname of the user. 117 // 118 // (-- aip.dev/not-precedent: An empty string is a valid nickname. 119 // Ordinarily, proto3_optional should not be used on a `string` field. --) 120 optional string nickname = 8; 121 122 // Enables the receiving of notifications. The default is true if unset. 123 // 124 // (-- aip.dev/not-precedent: The default for the feature is true. 125 // Ordinarily, the default for a `bool` field should be false. --) 126 optional bool enable_notifications = 9; 127 128 // The user's favorite hobby. 129 optional Hobby hobby = 10; 130 131 // The user's song. 132 optional Song song = 11; 133} 134 135message Hobby { 136 // The name of the hobby. 137 string hobby_name = 1; 138 139 // Weekly frequency this hobby is performed. 140 int32 weekly_frequency = 2; 141 142 // The instruction manual for the hobby. 143 Book instruction_manual = 3; 144} 145 146message Book { 147 // The title of the instruction manual. 148 string title = 1; 149 150 // The subject of the instruction manual. 151 string subject = 2; 152} 153 154message Song { 155 // The name of the song. 156 string song_name = 1; 157 158 // The song's artist. 159 Artist song_artist = 2; 160} 161 162message Artist { 163 // The name of the artist. 164 string artist_name = 1; 165 166 // The artist's recording company. 167 RecordingCompany recording_company = 2; 168} 169 170message RecordingCompany { 171 // The recording company's name 172 string company_name = 1; 173 174 // The year the company was founded. 175 int32 founding_year = 2; 176} 177 178// The request message for the google.showcase.v1beta1.Identity\CreateUser 179// method. 180message CreateUserRequest { 181 string parent = 1 [ 182 (google.api.resource_reference).child_type = "showcase.googleapis.com/User", 183 (google.api.field_behavior) = REQUIRED 184 ]; 185 // The user to create. 186 User user = 2 [(google.api.field_behavior) = REQUIRED]; 187} 188 189// The request message for the google.showcase.v1beta1.Identity\GetUser 190// method. 191message GetUserRequest { 192 // The resource name of the requested user. 193 string name = 1 [ 194 (google.api.resource_reference).type = "showcase.googleapis.com/User", 195 (google.api.field_behavior) = REQUIRED 196 ]; 197} 198 199// The request message for the google.showcase.v1beta1.Identity\UpdateUser 200// method. 201message UpdateUserRequest { 202 // The user to update. 203 User user = 1; 204 205 // The field mask to determine wich fields are to be updated. If empty, the 206 // server will assume all fields are to be updated. 207 google.protobuf.FieldMask update_mask = 2; 208} 209 210// The request message for the google.showcase.v1beta1.Identity\DeleteUser 211// method. 212message DeleteUserRequest { 213 // The resource name of the user to delete. 214 string name = 1 [ 215 (google.api.resource_reference).type = "showcase.googleapis.com/User", 216 (google.api.field_behavior) = REQUIRED 217 ]; 218} 219 220// The request message for the google.showcase.v1beta1.Identity\ListUsers 221// method. 222message ListUsersRequest { 223 // The maximum number of users to return. Server may return fewer users 224 // than requested. If unspecified, server will pick an appropriate default. 225 int32 page_size = 1; 226 227 // The value of google.showcase.v1beta1.ListUsersResponse.next_page_token 228 // returned from the previous call to 229 // `google.showcase.v1beta1.Identity\ListUsers` method. 230 string page_token = 2; 231} 232 233// The response message for the google.showcase.v1beta1.Identity\ListUsers 234// method. 235message ListUsersResponse { 236 // The list of users. 237 repeated User users = 1; 238 239 // A token to retrieve next page of results. 240 // Pass this value in ListUsersRequest.page_token field in the subsequent 241 // call to `google.showcase.v1beta1.Message\ListUsers` method to retrieve the 242 // next page of results. 243 string next_page_token = 2; 244} 245