Commit d0d3ca42 authored by Chris Molozian's avatar Chris Molozian Committed by Mo Firouz
Browse files

Add developer console.

The developer console adds the ability to:

1. See server status.
2. See running configuration.
3. List users, and modify their detail.
4. List, update, delete, export and bulk import Storage records.
parent 6bf1d996
Loading
Loading
Loading
Loading
+17 −15

File changed.

Preview size limit exceeded, changes collapsed.

+242 −179

File changed.

Preview size limit exceeded, changes collapsed.

+17 −17
Original line number Diff line number Diff line
@@ -818,14 +818,18 @@ func request_Console_UnlinkSteam_0(ctx context.Context, marshaler runtime.Marsha

}

var (
	filter_Console_UpdateAccount_0 = &utilities.DoubleArray{Encoding: map[string]int{"id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}}
)

func request_Console_UpdateAccount_0(ctx context.Context, marshaler runtime.Marshaler, client ConsoleClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
	var protoReq UpdateAccountRequest
	var metadata runtime.ServerMetadata

	newReader, berr := utilities.IOReaderFactory(req.Body)
	if berr != nil {
		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
	}
	if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
	}

	var (
		val string
		ok  bool
@@ -844,23 +848,23 @@ func request_Console_UpdateAccount_0(ctx context.Context, marshaler runtime.Mars
		return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
	}

	if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_Console_UpdateAccount_0); err != nil {
		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
	}

	msg, err := client.UpdateAccount(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
	return msg, metadata, err

}

var (
	filter_Console_WriteStorageObject_0 = &utilities.DoubleArray{Encoding: map[string]int{"collection": 0, "key": 1, "user_id": 2}, Base: []int{1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 1, 1, 2, 3, 4}}
)

func request_Console_WriteStorageObject_0(ctx context.Context, marshaler runtime.Marshaler, client ConsoleClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
	var protoReq WriteStorageObjectRequest
	var metadata runtime.ServerMetadata

	newReader, berr := utilities.IOReaderFactory(req.Body)
	if berr != nil {
		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
	}
	if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
	}

	var (
		val string
		ok  bool
@@ -901,10 +905,6 @@ func request_Console_WriteStorageObject_0(ctx context.Context, marshaler runtime
		return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user_id", err)
	}

	if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_Console_WriteStorageObject_0); err != nil {
		return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
	}

	msg, err := client.WriteStorageObject(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
	return msg, metadata, err

@@ -1528,7 +1528,7 @@ func RegisterConsoleHandlerClient(ctx context.Context, mux *runtime.ServeMux, cl

	})

	mux.Handle("POST", pattern_Console_WriteStorageObject_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
	mux.Handle("PUT", pattern_Console_WriteStorageObject_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
		ctx, cancel := context.WithCancel(req.Context())
		defer cancel()
		inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
+19 −3
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ service Console {
  }

  // Get detailed account information for a single user.
  rpc GetAccount (AccountId) returns (nakama.api.Account) {
  rpc GetAccount (AccountId) returns (Account) {
    option (google.api.http).get = "/v2/console/account/{id}";
  }

@@ -217,13 +217,27 @@ service Console {

  // Update one or more fields on a user account.
  rpc UpdateAccount (UpdateAccountRequest) returns (google.protobuf.Empty) {
    option (google.api.http).post = "/v2/console/account/{id}";
    option (google.api.http) = {
      post: "/v2/console/account/{id}",
      body: "*"
    };
  }

  // Write a new storage object or replace an existing one.
  rpc WriteStorageObject (WriteStorageObjectRequest) returns (nakama.api.StorageObjectAck) {
    option (google.api.http).post = "/v2/console/storage/{collection}/{key}/{user_id}";
    option (google.api.http) = {
      put: "/v2/console/storage/{collection}/{key}/{user_id}",
      body: "*"
    };
  }
}

// Account information.
message Account {
  // The user's account details.
  nakama.api.Account account = 1;
  // The UNIX time when the account was disabled.
  google.protobuf.Timestamp disable_time = 2;
}

// Delete a user account.
@@ -282,6 +296,8 @@ message Config {
  string config = 1;
  // Any warnings about the current config.
  repeated Warning warnings = 2;
  // Server version
  string server_version = 3;
}

// A console user session.
+165 −37
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/apiAccount"
              "$ref": "#/definitions/nakamaconsoleAccount"
            }
          }
        },
@@ -95,6 +95,14 @@
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/nakamaconsoleUpdateAccountRequest"
            }
          }
        ],
        "tags": [
@@ -730,7 +738,7 @@
          "Console"
        ]
      },
      "post": {
      "put": {
        "summary": "Write a new storage object or replace an existing one.",
        "operationId": "WriteStorageObject",
        "responses": {
@@ -762,6 +770,14 @@
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "$ref": "#/definitions/consoleWriteStorageObjectRequest"
            }
          }
        ],
        "tags": [
@@ -959,40 +975,6 @@
      },
      "description": "A single group-role pair."
    },
    "apiAccount": {
      "type": "object",
      "properties": {
        "user": {
          "$ref": "#/definitions/apiUser",
          "description": "The user object."
        },
        "wallet": {
          "type": "string",
          "description": "The user's wallet data."
        },
        "email": {
          "type": "string",
          "description": "The email address of the user."
        },
        "devices": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/apiAccountDevice"
          },
          "description": "The devices which belong to the user's account."
        },
        "custom_id": {
          "type": "string",
          "description": "The custom id in the user's account."
        },
        "verify_time": {
          "type": "string",
          "format": "date-time",
          "description": "The UNIX time when the user's email was verified."
        }
      },
      "description": "A user with additional account details. Always the current user."
    },
    "apiAccountDevice": {
      "type": "object",
      "properties": {
@@ -1394,7 +1376,7 @@
      "type": "object",
      "properties": {
        "account": {
          "$ref": "#/definitions/apiAccount",
          "$ref": "#/definitions/nakamaapiAccount",
          "description": "The user's account details."
        },
        "objects": {
@@ -1476,6 +1458,10 @@
            "$ref": "#/definitions/ConfigWarning"
          },
          "description": "Any warnings about the current config."
        },
        "server_version": {
          "type": "string",
          "title": "Server version"
        }
      },
      "description": "The current server configuration and any associated warnings."
@@ -1583,6 +1569,148 @@
        }
      },
      "description": "List of wallet ledger items for a particular user."
    },
    "consoleWriteStorageObjectRequest": {
      "type": "object",
      "properties": {
        "collection": {
          "type": "string",
          "description": "Collection."
        },
        "key": {
          "type": "string",
          "description": "Key."
        },
        "user_id": {
          "type": "string",
          "description": "Owner user ID."
        },
        "value": {
          "type": "string",
          "description": "Value."
        },
        "version": {
          "type": "string",
          "description": "Version for OCC."
        },
        "permission_read": {
          "type": "integer",
          "format": "int32",
          "description": "Read permission value."
        },
        "permission_write": {
          "type": "integer",
          "format": "int32",
          "description": "Write permission value."
        }
      },
      "description": "Write a new storage object or update an existing one."
    },
    "nakamaapiAccount": {
      "type": "object",
      "properties": {
        "user": {
          "$ref": "#/definitions/apiUser",
          "description": "The user object."
        },
        "wallet": {
          "type": "string",
          "description": "The user's wallet data."
        },
        "email": {
          "type": "string",
          "description": "The email address of the user."
        },
        "devices": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/apiAccountDevice"
          },
          "description": "The devices which belong to the user's account."
        },
        "custom_id": {
          "type": "string",
          "description": "The custom id in the user's account."
        },
        "verify_time": {
          "type": "string",
          "format": "date-time",
          "description": "The UNIX time when the user's email was verified."
        }
      },
      "description": "A user with additional account details. Always the current user."
    },
    "nakamaconsoleAccount": {
      "type": "object",
      "properties": {
        "account": {
          "$ref": "#/definitions/nakamaapiAccount",
          "description": "The user's account details."
        },
        "disable_time": {
          "type": "string",
          "format": "date-time",
          "description": "The UNIX time when the account was disabled."
        }
      },
      "description": "Account information."
    },
    "nakamaconsoleUpdateAccountRequest": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "User ID to update."
        },
        "username": {
          "type": "string",
          "description": "Username."
        },
        "display_name": {
          "type": "string",
          "description": "Display name."
        },
        "metadata": {
          "type": "string",
          "description": "Metadata."
        },
        "avatar_url": {
          "type": "string",
          "description": "Avatar URL."
        },
        "lang_tag": {
          "type": "string",
          "description": "Langtag."
        },
        "location": {
          "type": "string",
          "description": "Location."
        },
        "timezone": {
          "type": "string",
          "description": "Timezone."
        },
        "custom_id": {
          "type": "string",
          "description": "Custom ID."
        },
        "email": {
          "type": "string",
          "description": "Email."
        },
        "device_ids": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Device ID modifications."
        },
        "wallet": {
          "type": "string",
          "description": "Wallet."
        }
      },
      "description": "Update user account information."
    }
  },
  "securityDefinitions": {
Loading