name = "chat/channels"
version = "1.0.0"

"""
Get Channels
Retrieve paginated list of channels, e.g. text channels in slack or discord
"""
usecase GetChannels {
  input {
    """
    Workspace
    Representation of a workspace. Can be guild or workspace, depending on the provider capability.
    """
    workspace string

    """
    Channel Visibility Filter
    Limit the listing to either public or private channels; all channels are listed by default.
    """
    visibility enum {
      private
      public
    }

    """
    Limit
    Maximum number of channels to retrieve
    """
    limit number

    """
    Page
    Identification of page with paginated results (cursor)
    """
    page string
  }

  result {
    """
    Channels
    List of retrieved channels
    """
    channels! [Channel]

    """
    Next Page
    Cursor to the next page of listing
    """
    nextPage string

    """
    Rate Limit
    Rate limit details
    """
    rateLimit RateLimit
  }

  error Error

  example Successful {
    input {
      visibility = 'public',
      limit = 2
    }

    result {
      channels = [
        {
          id = '1'
          createdAt = 1546167104
          name = 'random'
          membersCount = 100
        }
        {
          id = '2'
          createdAt = 1546167104
          membersCount = 100
        }
      ]
    }
  }

  example Failed {
    input {
      workspace = 'not-existing-workspace'
    }

    error {
      title = 'workspace_not_found'
    }
  }
}

model Channel {
  """
  Id
  Unique identifier of the channel
  """
  id! string!

  """
  Created At
  UNIX timestamp (e.g. 1095379198.75) when the channel was created
  """
  createdAt! number!

  """
  Name
  Name of the retrieved channel
  """
  name string

  """
  Description
  Description of the channel. Can describe purpose or use of the channel.
  """
  description string

  """
  Members Count
  Number of members of the retrieved channel
  """
  membersCount number
}   

model Error {
  """
  Title
  A short, human-readable summary of the problem type.
  """
  title!

  """
  Detail
  A human-readable explanation specific to this occurrence of the problem.
  """
  detail

  """
  Rate Limit
  Rate limit details
  """
  rateLimit RateLimit
}

model RateLimit {
  """
  Bucket
  Different parts of API may have different rate limits.
  Bucket identifies to which part of API the rate limits apply.
  """
  bucket string

  """
  Total Requests
  Total requests available in the time window.
  """
  totalRequests number

  """
  Remaining Requests
  Remaining requests available in the time window.
  """
  remainingRequests number

  """
  Remaining Requests available in percents
  Remaining requests available in the time window in percents.
  """
  remainingRequestsPercentage number

  """
  Reset Timestamp
  Timestamp when the rate limits will reset (in  Unix Timestamp format).
  """
  resetTimestamp number

  """
  Reset After
  Number of seconds until reset of rate limit
  """
  resetAfter number

  """
  Retry After
  Number of seconds until user can retry the request
  """
  retryAfter number
}