swagger: "2.0"
info:
  title: api/v1/common.proto
  version: version not set
tags:
  - name: UserService
  - name: AuthService
  - name: CollectionService
  - name: ShortcutService
  - name: SubscriptionService
  - name: UserSettingService
  - name: WorkspaceService
consumes:
  - application/json
produces:
  - application/json
paths:
  /api/v1/auth/signin:
    post:
      summary: SignIn signs in the user with the given username and password.
      operationId: AuthService_SignIn
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/v1User'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: email
          in: query
          required: false
          type: string
        - name: password
          in: query
          required: false
          type: string
      tags:
        - AuthService
  /api/v1/auth/signin/sso:
    post:
      summary: SignInWithSSO signs in the user with the given SSO code.
      operationId: AuthService_SignInWithSSO
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/v1User'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: idpId
          description: The id of the SSO provider.
          in: query
          required: false
          type: string
        - name: code
          description: The code to sign in with.
          in: query
          required: false
          type: string
        - name: redirectUri
          description: The redirect URI.
          in: query
          required: false
          type: string
      tags:
        - AuthService
  /api/v1/auth/signout:
    post:
      summary: SignOut signs out the user.
      operationId: AuthService_SignOut
      responses:
        "200":
          description: A successful response.
          schema:
            type: object
            properties: {}
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      tags:
        - AuthService
  /api/v1/auth/signup:
    post:
      summary: SignUp signs up the user with the given username and password.
      operationId: AuthService_SignUp
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/v1User'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: email
          in: query
          required: false
          type: string
        - name: nickname
          in: query
          required: false
          type: string
        - name: password
          in: query
          required: false
          type: string
      tags:
        - AuthService
  /api/v1/auth/status:
    post:
      summary: GetAuthStatus returns the current auth status of the user.
      operationId: AuthService_GetAuthStatus
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/v1User'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      tags:
        - AuthService
  /api/v1/collections:
    get:
      summary: ListCollections returns a list of collections.
      operationId: CollectionService_ListCollections
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/v1ListCollectionsResponse'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      tags:
        - CollectionService
    post:
      summary: CreateCollection creates a collection.
      operationId: CollectionService_CreateCollection
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/apiv1Collection'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: collection
          in: body
          required: true
          schema:
            $ref: '#/definitions/apiv1Collection'
      tags:
        - CollectionService
  /api/v1/collections/{collection.id}:
    put:
      summary: UpdateCollection updates a collection.
      operationId: CollectionService_UpdateCollection
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/apiv1Collection'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: collection.id
          in: path
          required: true
          type: integer
          format: int32
        - name: collection
          in: body
          required: true
          schema:
            type: object
            properties:
              creatorId:
                type: integer
                format: int32
              createdTime:
                type: string
                format: date-time
              updatedTime:
                type: string
                format: date-time
              name:
                type: string
              title:
                type: string
              description:
                type: string
              shortcutIds:
                type: array
                items:
                  type: integer
                  format: int32
              visibility:
                $ref: '#/definitions/apiv1Visibility'
        - name: updateMask
          in: query
          required: false
          type: string
      tags:
        - CollectionService
  /api/v1/collections/{id}:
    get:
      summary: GetCollection returns a collection by id.
      operationId: CollectionService_GetCollection
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/apiv1Collection'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: id
          in: path
          required: true
          type: integer
          format: int32
      tags:
        - CollectionService
    delete:
      summary: DeleteCollection deletes a collection by id.
      operationId: CollectionService_DeleteCollection
      responses:
        "200":
          description: A successful response.
          schema:
            type: object
            properties: {}
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: id
          in: path
          required: true
          type: integer
          format: int32
      tags:
        - CollectionService
  /api/v1/shortcuts:
    get:
      summary: ListShortcuts returns a list of shortcuts.
      operationId: ShortcutService_ListShortcuts
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/v1ListShortcutsResponse'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      tags:
        - ShortcutService
    post:
      summary: CreateShortcut creates a shortcut.
      operationId: ShortcutService_CreateShortcut
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/apiv1Shortcut'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: shortcut
          in: body
          required: true
          schema:
            $ref: '#/definitions/apiv1Shortcut'
      tags:
        - ShortcutService
  /api/v1/shortcuts/{id}:
    get:
      summary: GetShortcut returns a shortcut by id.
      operationId: ShortcutService_GetShortcut
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/apiv1Shortcut'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: id
          in: path
          required: true
          type: integer
          format: int32
      tags:
        - ShortcutService
    delete:
      summary: DeleteShortcut deletes a shortcut by name.
      operationId: ShortcutService_DeleteShortcut
      responses:
        "200":
          description: A successful response.
          schema:
            type: object
            properties: {}
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: id
          in: path
          required: true
          type: integer
          format: int32
      tags:
        - ShortcutService
  /api/v1/shortcuts/{id}/analytics:
    get:
      summary: GetShortcutAnalytics returns the analytics for a shortcut.
      operationId: ShortcutService_GetShortcutAnalytics
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/v1GetShortcutAnalyticsResponse'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: id
          in: path
          required: true
          type: integer
          format: int32
      tags:
        - ShortcutService
  /api/v1/shortcuts/{shortcut.id}:
    put:
      summary: UpdateShortcut updates a shortcut.
      operationId: ShortcutService_UpdateShortcut
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/apiv1Shortcut'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: shortcut.id
          in: path
          required: true
          type: integer
          format: int32
        - name: shortcut
          in: body
          required: true
          schema:
            type: object
            properties:
              creatorId:
                type: integer
                format: int32
              createdTime:
                type: string
                format: date-time
              updatedTime:
                type: string
                format: date-time
              name:
                type: string
              link:
                type: string
              title:
                type: string
              tags:
                type: array
                items:
                  type: string
              description:
                type: string
              visibility:
                $ref: '#/definitions/apiv1Visibility'
              viewCount:
                type: integer
                format: int32
              ogMetadata:
                $ref: '#/definitions/v1ShortcutOpenGraphMetadata'
        - name: updateMask
          in: query
          required: false
          type: string
      tags:
        - ShortcutService
  /api/v1/users:
    get:
      summary: ListUsers returns a list of users.
      operationId: UserService_ListUsers
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/v1ListUsersResponse'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      tags:
        - UserService
    post:
      summary: CreateUser creates a new user.
      operationId: UserService_CreateUser
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/v1User'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: user
          in: body
          required: true
          schema:
            $ref: '#/definitions/v1User'
      tags:
        - UserService
  /api/v1/users/{id}:
    get:
      summary: GetUser returns a user by id.
      operationId: UserService_GetUser
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/v1User'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: id
          in: path
          required: true
          type: integer
          format: int32
      tags:
        - UserService
    delete:
      summary: DeleteUser deletes a user by id.
      operationId: UserService_DeleteUser
      responses:
        "200":
          description: A successful response.
          schema:
            type: object
            properties: {}
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: id
          in: path
          required: true
          type: integer
          format: int32
      tags:
        - UserService
  /api/v1/users/{id}/access_tokens:
    get:
      summary: ListUserAccessTokens returns a list of access tokens for a user.
      operationId: UserService_ListUserAccessTokens
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/v1ListUserAccessTokensResponse'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: id
          description: id is the user id.
          in: path
          required: true
          type: integer
          format: int32
      tags:
        - UserService
    post:
      summary: CreateUserAccessToken creates a new access token for a user.
      operationId: UserService_CreateUserAccessToken
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/v1UserAccessToken'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: id
          description: id is the user id.
          in: path
          required: true
          type: integer
          format: int32
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/UserServiceCreateUserAccessTokenBody'
      tags:
        - UserService
  /api/v1/users/{id}/access_tokens/{accessToken}:
    delete:
      summary: DeleteUserAccessToken deletes an access token for a user.
      operationId: UserService_DeleteUserAccessToken
      responses:
        "200":
          description: A successful response.
          schema:
            type: object
            properties: {}
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: id
          description: id is the user id.
          in: path
          required: true
          type: integer
          format: int32
        - name: accessToken
          description: access_token is the access token to delete.
          in: path
          required: true
          type: string
      tags:
        - UserService
  /api/v1/users/{id}/settings:
    get:
      summary: GetUserSetting returns the user setting.
      operationId: UserSettingService_GetUserSetting
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/apiv1UserSetting'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: id
          description: id is the user id.
          in: path
          required: true
          type: integer
          format: int32
      tags:
        - UserSettingService
    patch:
      summary: UpdateUserSetting updates the user setting.
      operationId: UserSettingService_UpdateUserSetting
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/apiv1UserSetting'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: id
          description: id is the user id.
          in: path
          required: true
          type: integer
          format: int32
        - name: userSetting
          description: user_setting is the user setting to update.
          in: body
          required: true
          schema:
            $ref: '#/definitions/apiv1UserSetting'
      tags:
        - UserSettingService
  /api/v1/users/{user.id}:
    patch:
      operationId: UserService_UpdateUser
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/v1User'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: user.id
          in: path
          required: true
          type: integer
          format: int32
        - name: user
          in: body
          required: true
          schema:
            type: object
            properties:
              state:
                $ref: '#/definitions/v1State'
              createdTime:
                type: string
                format: date-time
              updatedTime:
                type: string
                format: date-time
              role:
                $ref: '#/definitions/v1Role'
              email:
                type: string
              nickname:
                type: string
              password:
                type: string
      tags:
        - UserService
  /api/v1/workspace/profile:
    get:
      operationId: WorkspaceService_GetWorkspaceProfile
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/v1WorkspaceProfile'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      tags:
        - WorkspaceService
  /api/v1/workspace/setting:
    get:
      operationId: WorkspaceService_GetWorkspaceSetting
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/apiv1WorkspaceSetting'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      tags:
        - WorkspaceService
    patch:
      operationId: WorkspaceService_UpdateWorkspaceSetting
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/apiv1WorkspaceSetting'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: setting
          description: The user setting.
          in: body
          required: true
          schema:
            $ref: '#/definitions/apiv1WorkspaceSetting'
      tags:
        - WorkspaceService
  /v1/subscription:
    get:
      summary: GetSubscription gets the current subscription of Slash instance.
      operationId: SubscriptionService_GetSubscription
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/v1Subscription'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      tags:
        - SubscriptionService
    delete:
      summary: DeleteSubscription deletes the subscription.
      operationId: SubscriptionService_DeleteSubscription
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/v1Subscription'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      tags:
        - SubscriptionService
    patch:
      summary: UpdateSubscription updates the subscription.
      operationId: SubscriptionService_UpdateSubscription
      responses:
        "200":
          description: A successful response.
          schema:
            $ref: '#/definitions/v1Subscription'
        default:
          description: An unexpected error response.
          schema:
            $ref: '#/definitions/rpcStatus'
      parameters:
        - name: body
          in: body
          required: true
          schema:
            $ref: '#/definitions/v1UpdateSubscriptionRequest'
      tags:
        - SubscriptionService
definitions:
  GetShortcutAnalyticsResponseAnalyticsItem:
    type: object
    properties:
      name:
        type: string
      count:
        type: integer
        format: int32
  UserServiceCreateUserAccessTokenBody:
    type: object
    properties:
      description:
        type: string
        description: description is the description of the access token.
      expiresAt:
        type: string
        format: date-time
        description: |-
          expires_at is the expiration time of the access token.
          If expires_at is not set, the access token will never expire.
  apiv1Collection:
    type: object
    properties:
      id:
        type: integer
        format: int32
      creatorId:
        type: integer
        format: int32
      createdTime:
        type: string
        format: date-time
      updatedTime:
        type: string
        format: date-time
      name:
        type: string
      title:
        type: string
      description:
        type: string
      shortcutIds:
        type: array
        items:
          type: integer
          format: int32
      visibility:
        $ref: '#/definitions/apiv1Visibility'
  apiv1IdentityProvider:
    type: object
    properties:
      id:
        type: string
        description: The unique identifier of the identity provider.
      title:
        type: string
      type:
        $ref: '#/definitions/apiv1IdentityProviderType'
      config:
        $ref: '#/definitions/apiv1IdentityProviderConfig'
  apiv1IdentityProviderConfig:
    type: object
    properties:
      oauth2:
        $ref: '#/definitions/apiv1IdentityProviderConfigOAuth2Config'
  apiv1IdentityProviderConfigFieldMapping:
    type: object
    properties:
      identifier:
        type: string
      displayName:
        type: string
  apiv1IdentityProviderConfigOAuth2Config:
    type: object
    properties:
      clientId:
        type: string
      clientSecret:
        type: string
      authUrl:
        type: string
      tokenUrl:
        type: string
      userInfoUrl:
        type: string
      scopes:
        type: array
        items:
          type: string
      fieldMapping:
        $ref: '#/definitions/apiv1IdentityProviderConfigFieldMapping'
  apiv1IdentityProviderType:
    type: string
    enum:
      - TYPE_UNSPECIFIED
      - OAUTH2
    default: TYPE_UNSPECIFIED
  apiv1Shortcut:
    type: object
    properties:
      id:
        type: integer
        format: int32
      creatorId:
        type: integer
        format: int32
      createdTime:
        type: string
        format: date-time
      updatedTime:
        type: string
        format: date-time
      name:
        type: string
      link:
        type: string
      title:
        type: string
      tags:
        type: array
        items:
          type: string
      description:
        type: string
      visibility:
        $ref: '#/definitions/apiv1Visibility'
      viewCount:
        type: integer
        format: int32
      ogMetadata:
        $ref: '#/definitions/v1ShortcutOpenGraphMetadata'
  apiv1UserSetting:
    type: object
    properties:
      userId:
        type: integer
        format: int32
      general:
        $ref: '#/definitions/apiv1UserSettingGeneralSetting'
      accessTokens:
        $ref: '#/definitions/apiv1UserSettingAccessTokensSetting'
  apiv1UserSettingAccessTokensSetting:
    type: object
    properties:
      accessTokens:
        type: array
        items:
          type: object
          $ref: '#/definitions/apiv1UserSettingAccessTokensSettingAccessToken'
        title: Nested repeated field
  apiv1UserSettingAccessTokensSettingAccessToken:
    type: object
    properties:
      accessToken:
        type: string
        description: The access token is a JWT token, including expiration time, issuer, etc.
      description:
        type: string
        description: A description for the access token.
  apiv1UserSettingGeneralSetting:
    type: object
    properties:
      locale:
        type: string
      colorTheme:
        type: string
  apiv1Visibility:
    type: string
    enum:
      - VISIBILITY_UNSPECIFIED
      - WORKSPACE
      - PUBLIC
    default: VISIBILITY_UNSPECIFIED
  apiv1WorkspaceSetting:
    type: object
    properties:
      instanceUrl:
        type: string
        description: The url of instance.
      branding:
        type: string
        format: byte
        description: The workspace custome branding.
      customStyle:
        type: string
        description: The custom style.
      defaultVisibility:
        $ref: '#/definitions/apiv1Visibility'
        description: The default visibility of shortcuts and collections.
      identityProviders:
        type: array
        items:
          type: object
          $ref: '#/definitions/apiv1IdentityProvider'
        description: The identity providers.
      disallowUserRegistration:
        type: boolean
        description: Whether to disallow user registration by email&password.
      disallowPasswordAuth:
        type: boolean
        description: Whether to disallow password authentication.
  protobufAny:
    type: object
    properties:
      '@type':
        type: string
    additionalProperties: {}
  rpcStatus:
    type: object
    properties:
      code:
        type: integer
        format: int32
      message:
        type: string
      details:
        type: array
        items:
          type: object
          $ref: '#/definitions/protobufAny'
  v1GetShortcutAnalyticsResponse:
    type: object
    properties:
      references:
        type: array
        items:
          type: object
          $ref: '#/definitions/GetShortcutAnalyticsResponseAnalyticsItem'
      devices:
        type: array
        items:
          type: object
          $ref: '#/definitions/GetShortcutAnalyticsResponseAnalyticsItem'
      browsers:
        type: array
        items:
          type: object
          $ref: '#/definitions/GetShortcutAnalyticsResponseAnalyticsItem'
  v1ListCollectionsResponse:
    type: object
    properties:
      collections:
        type: array
        items:
          type: object
          $ref: '#/definitions/apiv1Collection'
  v1ListShortcutsResponse:
    type: object
    properties:
      shortcuts:
        type: array
        items:
          type: object
          $ref: '#/definitions/apiv1Shortcut'
  v1ListUserAccessTokensResponse:
    type: object
    properties:
      accessTokens:
        type: array
        items:
          type: object
          $ref: '#/definitions/v1UserAccessToken'
  v1ListUsersResponse:
    type: object
    properties:
      users:
        type: array
        items:
          type: object
          $ref: '#/definitions/v1User'
  v1PlanType:
    type: string
    enum:
      - PLAN_TYPE_UNSPECIFIED
      - FREE
      - PRO
      - ENTERPRISE
    default: PLAN_TYPE_UNSPECIFIED
  v1Role:
    type: string
    enum:
      - ROLE_UNSPECIFIED
      - ADMIN
      - USER
    default: ROLE_UNSPECIFIED
  v1ShortcutOpenGraphMetadata:
    type: object
    properties:
      title:
        type: string
      description:
        type: string
      image:
        type: string
  v1State:
    type: string
    enum:
      - STATE_UNSPECIFIED
      - ACTIVE
      - INACTIVE
    default: STATE_UNSPECIFIED
  v1Subscription:
    type: object
    properties:
      plan:
        $ref: '#/definitions/v1PlanType'
        readOnly: true
      startedTime:
        type: string
        format: date-time
        readOnly: true
      expiresTime:
        type: string
        format: date-time
        readOnly: true
      features:
        type: array
        items:
          type: string
        readOnly: true
      seats:
        type: integer
        format: int32
        readOnly: true
      shortcutsLimit:
        type: integer
        format: int32
        readOnly: true
      collectionsLimit:
        type: integer
        format: int32
        readOnly: true
  v1UpdateSubscriptionRequest:
    type: object
    properties:
      licenseKey:
        type: string
    required:
      - licenseKey
  v1User:
    type: object
    properties:
      id:
        type: integer
        format: int32
      state:
        $ref: '#/definitions/v1State'
      createdTime:
        type: string
        format: date-time
      updatedTime:
        type: string
        format: date-time
      role:
        $ref: '#/definitions/v1Role'
      email:
        type: string
      nickname:
        type: string
      password:
        type: string
  v1UserAccessToken:
    type: object
    properties:
      accessToken:
        type: string
      description:
        type: string
      issuedAt:
        type: string
        format: date-time
      expiresAt:
        type: string
        format: date-time
  v1WorkspaceProfile:
    type: object
    properties:
      mode:
        type: string
        description: 'Current workspace mode: dev, prod.'
      version:
        type: string
        description: Current workspace version.
      owner:
        type: string
        title: |-
          The owner name.
          Format: "users/{id}"
      subscription:
        $ref: '#/definitions/v1Subscription'
        description: The workspace subscription.
      customStyle:
        type: string
        description: The custom style.
      branding:
        type: string
        format: byte
        description: The workspace branding.
