Commit e8fcc8b9 authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Split protocol message and service definitions.

parent 62be9c7c
Loading
Loading
Loading
Loading
+205 −2415

File changed.

Preview size limit exceeded, changes collapsed.

+0 −522
Original line number Diff line number Diff line
@@ -19,11 +19,8 @@ syntax = "proto3";

package nakama.api;

import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
import "protoc-gen-swagger/options/annotations.proto";

option go_package = "api";

@@ -35,525 +32,6 @@ option csharp_namespace = "Nakama";

option objc_class_prefix = "NKPB";

option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = {
  info: {
    title: "Nakama API v2";
    version: "2.0";
    contact: {
      name: "The Nakama Authors & Contributors";
      url: "https://github.com/heroiclabs/nakama";
      email: "hello@heroiclabs.com";
    };
  };
  host: "127.0.0.1:7350";
  external_docs: {
    url: "https://heroiclabs.com/docs";
    description: "Nakama server documentation";
  }
  schemes: HTTP;
  consumes: "application/json";
  produces: "application/json";
  security_definitions: {
    security: {
      key: "BasicAuth";
      value: {
        type: TYPE_BASIC;
      }
    }
    security: {
      // Made up security so we can apply "Bearer <JWT_TOKEN>"
      key: "BearerJwt";
      value: {
        type: TYPE_INVALID;
      }
    }
    security: {
      key: "HttpKeyAuth";
      value: {
        type: TYPE_API_KEY;
        in: IN_HEADER;
        name: "http_key";
      }
    }
  }
  // Default security definition.
  security: {
    security_requirement: {
      key: "BearerJwt";
      value: {};
    }
  }
};

/**
 * The Nakama RPC protocol service built with GRPC.
 */
service Nakama {
  // Add friends by ID or username to a user's account.
  rpc AddFriends (AddFriendsRequest) returns (google.protobuf.Empty) {
    option (google.api.http).post = "/v2/friend";
  }

  // Add users to a group.
  rpc AddGroupUsers (AddGroupUsersRequest) returns (google.protobuf.Empty) {
    option (google.api.http).post = "/v2/group/{group_id}/add";
  }

  // Authenticate a user with a custom id against the server.
  rpc AuthenticateCustom (AuthenticateCustomRequest) returns (Session) {
    option (google.api.http) = {
      post: "/v2/account/authenticate/custom",
      body: "account"
    };
    option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
      security: {
        security_requirement: {
          key: "BasicAuth";
          value: {};
        }
      }
    };
  }

  // Authenticate a user with a device id against the server.
  rpc AuthenticateDevice (AuthenticateDeviceRequest) returns (Session) {
    option (google.api.http) = {
      post: "/v2/account/authenticate/device",
      body: "account"
    };
    option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
      security: {
        security_requirement: {
          key: "BasicAuth";
          value: {};
        }
      }
    };
  }

  // Authenticate a user with an email+password against the server.
  rpc AuthenticateEmail (AuthenticateEmailRequest) returns (Session) {
    option (google.api.http) = {
      post: "/v2/account/authenticate/email",
      body: "account"
    };
    option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
      security: {
        security_requirement: {
          key: "BasicAuth";
          value: {};
        }
      }
    };
  }

  // Authenticate a user with a Facebook OAuth token against the server.
  rpc AuthenticateFacebook (AuthenticateFacebookRequest) returns (Session) {
    option (google.api.http) = {
      post: "/v2/account/authenticate/facebook",
      body: "account"
    };
    option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
      security: {
        security_requirement: {
          key: "BasicAuth";
          value: {};
        }
      }
    };
  }

  // Authenticate a user with Apple's GameCenter against the server.
  rpc AuthenticateGameCenter (AuthenticateGameCenterRequest) returns (Session) {
    option (google.api.http) = {
      post: "/v2/account/authenticate/gamecenter",
      body: "account"
    };
    option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
      security: {
        security_requirement: {
          key: "BasicAuth";
          value: {};
        }
      }
    };
  }

  // Authenticate a user with Google against the server.
  rpc AuthenticateGoogle (AuthenticateGoogleRequest) returns (Session) {
    option (google.api.http) = {
      post: "/v2/account/authenticate/google",
      body: "account"
    };
    option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
      security: {
        security_requirement: {
          key: "BasicAuth";
          value: {};
        }
      }
    };
  }

  // Authenticate a user with Steam against the server.
  rpc AuthenticateSteam (AuthenticateSteamRequest) returns (Session) {
    option (google.api.http) = {
      post: "/v2/account/authenticate/steam",
      body: "account"
    };
    option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
      security: {
        security_requirement: {
          key: "BasicAuth";
          value: {};
        }
      }
    };
  }

  // Block one or more users by ID or username.
  rpc BlockFriends (BlockFriendsRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/v2/friend/block"
    };
  }

  // Create a new group with the current user as the owner.
  rpc CreateGroup (CreateGroupRequest) returns (Group) {
    option (google.api.http) = {
      post: "/v2/group",
      body: "*"
    };
  }

  // Delete one or more users by ID or username.
  rpc DeleteFriends (DeleteFriendsRequest) returns (google.protobuf.Empty) {
    option (google.api.http).delete = "/v2/friend";
  }

  // Delete a group by ID.
  rpc DeleteGroup (DeleteGroupRequest) returns (google.protobuf.Empty) {
    option (google.api.http).delete = "/v2/group/{group_id}";
  }

  // Delete a leaderboard record.
  rpc DeleteLeaderboardRecord (DeleteLeaderboardRecordRequest) returns (google.protobuf.Empty) {
    option (google.api.http).delete = "/v2/leaderboard/{leaderboard_id}";
  }

  // Delete one or more notifications for the current user.
  rpc DeleteNotifications (DeleteNotificationsRequest) returns (google.protobuf.Empty) {
    option (google.api.http).delete = "/v2/notification";
  }

  // Delete one or more objects by ID or username.
  rpc DeleteStorageObjects (DeleteStorageObjectsRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      put: "/v2/storage/delete",
      body: "*"
    };
  }

  // Fetch the current user's account.
  rpc GetAccount (google.protobuf.Empty) returns (Account) {
    option (google.api.http).get = "/v2/account";
  }

  // Fetch zero or more users by ID and/or username.
  rpc GetUsers (GetUsersRequest) returns (Users) {
    option (google.api.http).get = "/v2/user";
  }

  // A healthcheck which load balancers can use to check the service.
  rpc Healthcheck (google.protobuf.Empty) returns (google.protobuf.Empty) {
    option (google.api.http).get = "/healthcheck";
  }

  // Import Facebook friends and add them to a user's account.
  rpc ImportFacebookFriends (ImportFacebookFriendsRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/v2/friend/facebook",
      body: "account"
    };
  }

  // Immediately join an open group, or request to join a closed one.
  rpc JoinGroup (JoinGroupRequest) returns (google.protobuf.Empty) {
    option (google.api.http).post = "/v2/group/{group_id}/join";
  }

  rpc JoinTournament (JoinTournamentRequest) returns (google.protobuf.Empty) {
    option (google.api.http).post = "/v2/tournament/{tournament_id}/join";
  }

  // Kick a set of users from a group.
  rpc KickGroupUsers (KickGroupUsersRequest) returns (google.protobuf.Empty) {
    option (google.api.http).post = "/v2/group/{group_id}/kick";
  }

  // Leave a group the user is a member of.
  rpc LeaveGroup (LeaveGroupRequest) returns (google.protobuf.Empty) {
    option (google.api.http).post = "/v2/group/{group_id}/leave";
  }

  // Add a custom ID to the social profiles on the current user's account.
  rpc LinkCustom (AccountCustom) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/v2/account/link/custom",
      body: "*"
    };
  }

  // Add a device ID to the social profiles on the current user's account.
  rpc LinkDevice (AccountDevice) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/v2/account/link/device",
      body: "*"
    };
  }

  // Add an email+password to the social profiles on the current user's account.
  rpc LinkEmail (AccountEmail) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/v2/account/link/email",
      body: "*"
    };
  }

  // Add Facebook to the social profiles on the current user's account.
  rpc LinkFacebook (LinkFacebookRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/v2/account/link/facebook",
      body: "account"
    };
  }

  // Add Apple's GameCenter to the social profiles on the current user's account.
  rpc LinkGameCenter (AccountGameCenter) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/v2/account/link/gamecenter",
      body: "*"
    };
  }

  // Add Google to the social profiles on the current user's account.
  rpc LinkGoogle (AccountGoogle) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/v2/account/link/google",
      body: "*"
    };
  }

  // Add Steam to the social profiles on the current user's account.
  rpc LinkSteam (AccountSteam) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/v2/account/link/steam",
      body: "*"
    };
  }

  // List a channel's message history.
  rpc ListChannelMessages (ListChannelMessagesRequest) returns (ChannelMessageList) {
    option (google.api.http).get = "/v2/channel/{channel_id}";
  }

  // List all friends for the current user.
  rpc ListFriends (google.protobuf.Empty) returns (Friends) {
    option (google.api.http).get = "/v2/friend";
  }

  // List groups based on given filters.
  rpc ListGroups (ListGroupsRequest) returns (GroupList) {
    option (google.api.http).get = "/v2/group";
  }

  // List all users that are part of a group.
  rpc ListGroupUsers (ListGroupUsersRequest) returns (GroupUserList) {
    option (google.api.http).get = "/v2/group/{group_id}/user";
  }

  // List leaderboard records.
  rpc ListLeaderboardRecords (ListLeaderboardRecordsRequest) returns (LeaderboardRecordList) {
    option (google.api.http).get = "/v2/leaderboard/{leaderboard_id}";
  }

  rpc ListLeaderboardRecordsAroundOwner (ListLeaderboardRecordsAroundOwnerRequest) returns (LeaderboardRecordList) {
    option (google.api.http).get = "/v2/leaderboard/{leaderboard_id}/owner/{owner_id}";
  }

  // Fetch list of running matches.
  rpc ListMatches (ListMatchesRequest) returns (MatchList) {
    option (google.api.http).get = "/v2/match";
  }

  // Fetch list of notifications.
  rpc ListNotifications (ListNotificationsRequest) returns (NotificationList) {
    option (google.api.http).get = "/v2/notification";
  }

  // List publicly readable storage objects in a given collection.
  rpc ListStorageObjects (ListStorageObjectsRequest) returns (StorageObjectList) {
    option (google.api.http) = {
      get: "/v2/storage/{collection}",
      additional_bindings {
        get: "/v2/storage/{collection}/{user_id}"
      }
    };
  }

  // List current or upcoming tournaments.
  rpc ListTournaments (ListTournamentsRequest) returns (TournamentList) {
    option (google.api.http).get = "/v2/tournament";
  }

  // List tournament records.
  rpc ListTournamentRecords (ListTournamentRecordsRequest) returns (TournamentRecordList) {
    option (google.api.http).get = "/v2/tournament/{tournament_id}";
  }

  rpc ListTournamentRecordsAroundOwner (ListTournamentRecordsAroundOwnerRequest) returns (TournamentRecordList) {
    option (google.api.http).get = "/v2/tournament/{tournament_id}/owner/{owner_id}";
  }

  // List groups the current user belongs to.
  rpc ListUserGroups (ListUserGroupsRequest) returns (UserGroupList) {
    option (google.api.http).get = "/v2/user/{user_id}/group";
  }

  // Promote a set of users in a group to the next role up.
  rpc PromoteGroupUsers (PromoteGroupUsersRequest) returns (google.protobuf.Empty) {
    option (google.api.http).post = "/v2/group/{group_id}/promote";
  }

  // Get storage objects.
  rpc ReadStorageObjects (ReadStorageObjectsRequest) returns (StorageObjects) {
    option (google.api.http) = {
      post: "/v2/storage",
      body: "*"
    };
  }

  // Execute a Lua function on the server.
  rpc RpcFunc (Rpc) returns (Rpc) {
    option (google.api.http) = {
      post: "/v2/rpc/{id}",
      body: "payload",
      additional_bindings {
        get: "/v2/rpc/{id}"
      }
    };
    option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = {
      // Either HTTP key in query param or Bearer authentication.
      security: {
        security_requirement: {
          key: "HttpKeyAuth";
          value: {};
        }
        security_requirement: {
          key: "BearerJwt";
          value: {};
        }
      }
    };
  }

  // Remove the custom ID from the social profiles on the current user's account.
  rpc UnlinkCustom (AccountCustom) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/v2/account/unlink/custom",
      body: "*"
    };
  }

  // Remove the device ID from the social profiles on the current user's account.
  rpc UnlinkDevice (AccountDevice) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/v2/account/unlink/device",
      body: "*"
    };
  }

  // Remove the email+password from the social profiles on the current user's account.
  rpc UnlinkEmail (AccountEmail) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/v2/account/unlink/email",
      body: "*"
    };
  }

  // Remove Facebook from the social profiles on the current user's account.
  rpc UnlinkFacebook (AccountFacebook) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/v2/account/unlink/facebook",
      body: "*"
    };
  }

  // Remove Apple's GameCenter from the social profiles on the current user's account.
  rpc UnlinkGameCenter (AccountGameCenter) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/v2/account/unlink/gamecenter",
      body: "*"
    };
  }

  // Remove Google from the social profiles on the current user's account.
  rpc UnlinkGoogle (AccountGoogle) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/v2/account/unlink/google",
      body: "*"
    };
  }

  // Remove Steam from the social profiles on the current user's account.
  rpc UnlinkSteam (AccountSteam) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/v2/account/unlink/steam",
      body: "*"
    };
  }

  // Update fields in the current user's account.
  rpc UpdateAccount (UpdateAccountRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      put: "/v2/account",
      body: "*"
    };
  }

  // Update fields in a given group.
  rpc UpdateGroup (UpdateGroupRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      put: "/v2/group/{group_id}",
      body: "*"
    };
  }

  // Write a record to a leaderboard.
  rpc WriteLeaderboardRecord (WriteLeaderboardRecordRequest) returns (LeaderboardRecord) {
    option (google.api.http) = {
      post: "/v2/leaderboard/{leaderboard_id}",
      body: "record"
    };
  }

  // Write objects into the storage engine.
  rpc WriteStorageObjects (WriteStorageObjectsRequest) returns (StorageObjectAcks) {
    option (google.api.http) = {
      put: "/v2/storage",
      body: "*"
    };
  }

  // Write a record to a tournament.
  rpc WriteTournamentRecord (WriteTournamentRecordRequest) returns (LeaderboardRecord) {
    option (google.api.http) = {
      put: "/v2/tournament/{tournament_id}",
      body: "record"
    };
  }
}

// A user with additional account details. Always the current user.
message Account {
  // The user object.

apigrpc/apigrpc.pb.go

0 → 100644
+2256 −0

File added.

Preview size limit exceeded, changes collapsed.

+62 −61

File changed and moved.

Preview size limit exceeded, changes collapsed.

apigrpc/apigrpc.proto

0 → 100644
+554 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading