{
    "swagger": "2.0",
    "info": {
        "description": "This is the members related API.",
        "title": "Account System Members OPENAPI",
        "contact": {},
        "version": "v1beta1"
    },
    "host": "iam.tidbapi.com",
    "basePath": "/v1beta1",
    "paths": {
        "/members": {
            "get": {
                "description": "List members in the organization with optional filters for email, roles, statuses, project and instance.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Member"
                ],
                "summary": "List members",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "Page size",
                        "name": "pageSize",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Page token for pagination",
                        "name": "pageToken",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Filter by email",
                        "name": "email",
                        "in": "query"
                    },
                    {
                        "type": "array",
                        "items": {
                            "enum": [
                                "org:owner",
                                "org:member",
                                "org:billing_admin",
                                "org:billing_viewer",
                                "org:audit_admin",
                                "project:owner",
                                "project:dev",
                                "project:readonly",
                                "project:ctl_plane_viewer",
                                "cluster:admin",
                                "cluster:viewer"
                            ],
                            "type": "string"
                        },
                        "collectionFormat": "multi",
                        "description": "Filter by roles",
                        "name": "roles",
                        "in": "query"
                    },
                    {
                        "type": "array",
                        "items": {
                            "enum": [
                                "Active",
                                "Pending"
                            ],
                            "type": "string"
                        },
                        "collectionFormat": "multi",
                        "description": "Filter by statuses",
                        "name": "statuses",
                        "in": "query"
                    },
                    {
                        "enum": [
                            "email asc",
                            "email desc",
                            "invite_time asc",
                            "invite_time desc",
                            "login_time asc",
                            "login_time desc"
                        ],
                        "type": "string",
                        "description": "Order by field and direction, e.g. 'email desc'",
                        "name": "orderBy",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Filter by project ID",
                        "name": "projectId",
                        "in": "query"
                    },
                    {
                        "type": "string",
                        "description": "Filter by instance ID",
                        "name": "instanceId",
                        "in": "query"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiListUsersRsp"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    }
                }
            },
            "post": {
                "description": "Invite one or more members to the organization with specified org, project and instance roles.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Member"
                ],
                "summary": "Invite members",
                "parameters": [
                    {
                        "description": "invite members request",
                        "name": "body",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiInviteUsersReq"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiInviteUsersRsp"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    }
                }
            }
        },
        "/members/batchUpdate": {
            "post": {
                "description": "Batch update multiple members' org, project and instance roles in a single request (max 100 users per request).",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Member"
                ],
                "summary": "Batch update members",
                "parameters": [
                    {
                        "description": "batch update members request",
                        "name": "body",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/api.openApiBatchUpdateUsersReqDoc"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiBatchUpdateUsersRsp"
                        }
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    }
                }
            }
        },
        "/members/{user_id}": {
            "delete": {
                "description": "Remove a member from the organization. The member will lose all roles within the org.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Member"
                ],
                "summary": "Delete a member",
                "parameters": [
                    {
                        "type": "string",
                        "description": "User ID",
                        "name": "user_id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    }
                }
            },
            "patch": {
                "description": "Update a member's org role, project roles and instance roles. Project roles and instance roles are fully replaced when provided.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Member"
                ],
                "summary": "Update a member",
                "parameters": [
                    {
                        "type": "string",
                        "description": "User ID",
                        "name": "user_id",
                        "in": "path",
                        "required": true
                    },
                    {
                        "description": "update member request",
                        "name": "body",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/api.openApiUpdateUserReqDoc"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    }
                }
            }
        },
        "/members/{user_id}/resendInvitation": {
            "post": {
                "description": "Resend invitation email to a member who has not yet accepted the invitation.",
                "consumes": [
                    "application/json"
                ],
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "Member"
                ],
                "summary": "Resend invitation",
                "parameters": [
                    {
                        "type": "string",
                        "description": "User ID",
                        "name": "user_id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    },
                    "400": {
                        "description": "Bad Request",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    },
                    "401": {
                        "description": "Unauthorized",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    },
                    "403": {
                        "description": "Forbidden",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "schema": {
                            "$ref": "#/definitions/api.OpenApiError"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "api.OpenApiBatchUpdateError": {
            "type": "object",
            "properties": {
                "code": {
                    "description": "Error code",
                    "type": "string"
                },
                "message": {
                    "description": "Error message",
                    "type": "string"
                }
            }
        },
        "api.OpenApiBatchUpdateUserResult": {
            "type": "object",
            "properties": {
                "error": {
                    "description": "Error details if the update failed",
                    "allOf": [
                        {
                            "$ref": "#/definitions/api.OpenApiBatchUpdateError"
                        }
                    ]
                },
                "success": {
                    "description": "Whether the update was successful",
                    "type": "boolean"
                },
                "userId": {
                    "description": "Unique identifier of the user",
                    "type": "string"
                }
            }
        },
        "api.OpenApiBatchUpdateUsersRsp": {
            "type": "object",
            "properties": {
                "results": {
                    "description": "List of batch update results",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/api.OpenApiBatchUpdateUserResult"
                    }
                }
            }
        },
        "api.OpenApiError": {
            "type": "object",
            "properties": {
                "code": {
                    "description": "Error code",
                    "type": "string"
                },
                "error": {},
                "msgPrefix": {
                    "description": "Error message prefix",
                    "type": "string"
                },
                "status": {
                    "description": "HTTP status code",
                    "type": "integer"
                }
            }
        },
        "api.OpenApiInstanceRole": {
            "type": "object",
            "properties": {
                "rbacRole": {
                    "description": "Instance role",
                    "type": "string",
                    "enum": [
                        "cluster:admin",
                        "cluster:viewer"
                    ],
                    "example": "cluster:admin"
                },
                "scopeId": {
                    "description": "Instance ID",
                    "type": "string"
                }
            }
        },
        "api.OpenApiInviteUserResult": {
            "type": "object",
            "properties": {
                "email": {
                    "description": "Email address of the invited user",
                    "type": "string"
                },
                "userId": {
                    "description": "Unique identifier of the invited user",
                    "type": "string"
                }
            }
        },
        "api.OpenApiInviteUsersReq": {
            "type": "object",
            "required": [
                "emails",
                "orgRole"
            ],
            "properties": {
                "emails": {
                    "description": "Email addresses of the users to invite",
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "instanceRoles": {
                    "description": "Instance roles to assign to the invited users",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/api.OpenApiInstanceRole"
                    }
                },
                "orgRole": {
                    "description": "Organization role to assign to the invited users",
                    "allOf": [
                        {
                            "$ref": "#/definitions/api.OpenApiOrgRole"
                        }
                    ]
                },
                "projectRoles": {
                    "description": "Project roles to assign to the invited users",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/api.OpenApiProjectRole"
                    }
                }
            }
        },
        "api.OpenApiInviteUsersRsp": {
            "type": "object",
            "properties": {
                "message": {
                    "description": "Response message",
                    "type": "string"
                },
                "success": {
                    "description": "Whether the invitation was successful",
                    "type": "boolean"
                },
                "users": {
                    "description": "List of invited user results",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/api.OpenApiInviteUserResult"
                    }
                }
            }
        },
        "api.OpenApiListUsersRsp": {
            "type": "object",
            "properties": {
                "nextPageToken": {
                    "description": "Token to retrieve the next page of results",
                    "type": "string",
                    "example": ""
                },
                "totalSize": {
                    "description": "Total number of users matching the query",
                    "type": "integer",
                    "example": 10
                },
                "users": {
                    "description": "List of users",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/api.OpenApiUser"
                    }
                }
            }
        },
        "api.OpenApiOrgRole": {
            "type": "object",
            "properties": {
                "rbacRole": {
                    "description": "Organization role",
                    "type": "string",
                    "enum": [
                        "org:owner",
                        "org:member",
                        "org:billing_admin",
                        "org:billing_viewer",
                        "org:audit_admin"
                    ],
                    "example": "org:owner"
                },
                "scopeId": {
                    "description": "Organization ID",
                    "type": "string"
                }
            }
        },
        "api.OpenApiProjectRole": {
            "type": "object",
            "properties": {
                "rbacRole": {
                    "description": "Project role",
                    "type": "string",
                    "enum": [
                        "project:owner",
                        "project:dev",
                        "project:readonly",
                        "project:ctl_plane_viewer"
                    ],
                    "example": "project:owner"
                },
                "scopeId": {
                    "description": "Project ID",
                    "type": "string"
                }
            }
        },
        "api.OpenApiUser": {
            "type": "object",
            "properties": {
                "email": {
                    "description": "Email address of the user",
                    "type": "string",
                    "example": "user@example.com"
                },
                "firstName": {
                    "description": "First name of the user",
                    "type": "string",
                    "example": "John"
                },
                "instanceRoles": {
                    "description": "Instance roles of the user",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/api.OpenApiInstanceRole"
                    }
                },
                "inviteTime": {
                    "description": "Time when the user was invited",
                    "type": "string",
                    "example": "2024-01-01T00:00:00Z"
                },
                "lastLoginTime": {
                    "description": "Time when the user last logged in",
                    "type": "string",
                    "example": "2024-01-01T00:00:00Z"
                },
                "lastName": {
                    "description": "Last name of the user",
                    "type": "string",
                    "example": "Doe"
                },
                "orgRole": {
                    "description": "Organization role of the user",
                    "allOf": [
                        {
                            "$ref": "#/definitions/api.OpenApiOrgRole"
                        }
                    ]
                },
                "projectRoles": {
                    "description": "Project roles of the user",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/api.OpenApiProjectRole"
                    }
                },
                "status": {
                    "description": "Status of the user",
                    "type": "string",
                    "example": "active"
                },
                "userId": {
                    "description": "Unique identifier of the user",
                    "type": "string",
                    "example": "123456"
                }
            }
        },
        "api.openApiBatchUpdateUserEntryDoc": {
            "type": "object",
            "required": [
                "userId"
            ],
            "properties": {
                "instanceRoles": {
                    "description": "Instance roles to update",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/api.OpenApiInstanceRole"
                    }
                },
                "orgRole": {
                    "description": "Organization role to update",
                    "allOf": [
                        {
                            "$ref": "#/definitions/api.OpenApiOrgRole"
                        }
                    ]
                },
                "projectRoles": {
                    "description": "Project roles to update",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/api.OpenApiProjectRole"
                    }
                },
                "userId": {
                    "description": "Unique identifier of the user",
                    "type": "string"
                }
            }
        },
        "api.openApiBatchUpdateUsersReqDoc": {
            "type": "object",
            "properties": {
                "users": {
                    "description": "List of users to update",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/api.openApiBatchUpdateUserEntryDoc"
                    }
                }
            }
        },
        "api.openApiUpdateUserReqDoc": {
            "type": "object",
            "properties": {
                "instanceRoles": {
                    "description": "Instance roles to update",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/api.OpenApiInstanceRole"
                    }
                },
                "orgRole": {
                    "description": "Organization role to update",
                    "allOf": [
                        {
                            "$ref": "#/definitions/api.OpenApiOrgRole"
                        }
                    ]
                },
                "projectRoles": {
                    "description": "Project roles to update",
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/api.OpenApiProjectRole"
                    }
                }
            }
        }
    }
}