Documentation ¶
Index ¶
- Constants
- func Version() string
- type Attachment
- type AttachmentID
- type Client
- type Comment
- type CommentID
- type Error
- type ErrorResponse
- type Group
- type GroupID
- type ListOptions
- type Meta
- type Post
- type PostID
- type Rate
- type RateLimitError
- type Response
- type Scope
- type Tag
- type Timestamp
- type TokenTransport
- type User
- type UserID
- type UserRole
Constants ¶
const ( // ScopeEveryone specifies that a post is published for everybody in the team. ScopeEveryone = Scope("everyone") // ScopeGroup specifies that a post is published for members in specified groups. ScopeGroup = Scope("group") // ScopePrivate specifies that a post is just for me. ScopePrivate = Scope("private") )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attachment ¶
type AttachmentID ¶
type AttachmentID int64
type Client ¶
type Client struct { // User agent used when communicating with the Docbase API. UserAgent string // Services used for talking to different parts of the Docbase API. User *userService Tag *tagService Group *groupService Post *postService Comment *commentService Attachment *attachmentService // contains filtered or unexported fields }
A Client manages communication with the Docbase API.
func NewAuthClient ¶
func NewClient ¶
NewClient returns a new Docbase API client. If a nil httpClient is provided, http.DefaultClient will be used. But it is not authenticated, using methods which requires authentication, raises error. To use API methods which require authentication, provide an http.Client that will perform the authentication for you (such as that provided by the docbase.TokenTransport).
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it. If rate limit is exceeded and reset time is in the future, Do returns *RateLimitError immediately without making a network API call.
The provided ctx must be non-nil. If it is canceled or times out, ctx.Err() will be returned.
func (*Client) NewRequest ¶
NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
type Comment ¶
type Comment struct { Body string `json:"body"` CreatedAt string `json:"created_at"` ID CommentID `json:"id"` User User `json:"user"` }
Comment represents a Docbase Comment.
type Error ¶
type Error struct { Resource string `json:"resource"` // resource on which the error occurred Field string `json:"field"` // field on which the error occurred Code string `json:"code"` // validation error code Message string `json:"message"` // Message describing the error. Errors with Code == "custom" will always have this set. }
An Error reports more details on an individual error in an ErrorResponse. These are the possible validation error codes:
missing: resource does not exist missing_field: a required field on a resource has not been set invalid: the formatting of a field is invalid already_exists: another resource has the same valid as this field custom: some resources return this (e.g. github.User.CreateKey()), additional information is set in the Message field of the Error
Docbase API docs: https://developer.github.com/v3/#client-errors
type ErrorResponse ¶
type ErrorResponse struct { Response *http.Response // HTTP response that caused this error Messages []string `json:"messages"` // more detail on individual errors Value string `json:"error"` // error message }
An ErrorResponse reports one or more errors caused by an API request.
Docbase API docs: https://developer.github.com/v3/#client-errors
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type Group ¶
type Group struct { ID GroupID `json:"id"` Name string `json:"name"` Description string `json:"description"` PostsCount int64 `json:"posts_count"` LastActivityAt time.Time `json:"last_activity_at"` CreatedAt time.Time `json:"created_at"` Users []User }
Group represents a Docbase Group.
type ListOptions ¶
type ListOptions struct { // For paginated result sets, page of results to retrieve. Page *int64 `url:"page,omitempty"` // For paginated result sets, the number of results to include per page. PerPage *int64 `url:"per_page,omitempty"` }
ListOptions specifies the optional parameters to various List methods that support pagination.
type Meta ¶
type Meta struct { NextPage string `json:"next_page"` PreviousPage string `json:"previous_page"` Total int64 `json:"total"` }
Meta provides the page values for paginating through a set of results. Any or all of these may be set to the zero value for responses that are not part of a paginated set, or for which there are no additional pages.
func (Meta) Next ¶
func (m Meta) Next() *ListOptions
Next will get a ListOptions for the next page. If there's no next page, it will be nil.
func (Meta) Previous ¶
func (m Meta) Previous() *ListOptions
Previous will get a ListOptions for the previous page. If there's no previous page, it will be nil.
type Post ¶
type Post struct { ID PostID `json:"id"` Title string `json:"title"` Body string `json:"body"` Draft bool `json:"draft"` Archived bool `json:"archived"` URL string `json:"url"` CreatedAt string `json:"created_at"` Scope Scope `json:"scope"` SharingURL string `json:"sharing_url"` Tags []Tag `json:"tags"` User User `json:"user"` StarsCount int64 `json:"stars_count"` GoodJobsCount int64 `json:"good_jobs_count"` Comments []Comment `json:"comments"` Groups []Group `json:"groups"` }
Post represents a Docbase Post.
type Rate ¶
type Rate struct { // The number of requests per hour the client is currently limited to. Limit int64 // The number of remaining requests the client can make this hour. Remaining int64 // The time at which the current rate limit will reset. Reset Timestamp }
Rate represents the rate limit for the current client.
type RateLimitError ¶
type RateLimitError struct { Rate Rate // Rate specifies last known rate limit for the client Response *http.Response // HTTP response that caused this error Messages []string `json:"messages"` // error message }
RateLimitError occurs when Docbase returns 429 Too many requests response with a rate limit remaining value of 0.
func (*RateLimitError) Error ¶
func (r *RateLimitError) Error() string
type Response ¶
Response is a Docbase API response. This wraps the standard http.Response returned from Docbase and provides convenient access to things like pagination links.
type Timestamp ¶
Timestamp represents a time that can be unmarshalled from a JSON string formatted as either an RFC3339 or Unix timestamp. This is necessary for some fields since the GitHub API is inconsistent in how it represents times. All exported methods of time.Time can be called on Timestamp.
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. Time is expected in RFC3339 or Unix format.
type TokenTransport ¶
type TokenTransport struct { Token string // Transport is the underlying HTTP transport to use when making requests. // It will default to http.DefaultTransport if nil. Transport http.RoundTripper }
TokenTransport is an http.RoundTripper that authenticates all requests with the provided access token.
func (*TokenTransport) Client ¶
func (t *TokenTransport) Client() *http.Client
Client returns an *http.Client that makes requests that are authenticated with the provided access token.
type User ¶
type User struct { ID UserID `json:"id"` Name string `json:"name"` Username string `json:"username"` ProfileImageURL string `json:"profile_image_url"` Role UserRole `json:"role"` PostsCount int64 `json:"posts_count"` LastAccessTime time.Time `json:"last_access_time"` TwoStepAuthentication bool `json:"two_step_authentication"` Groups []Group `json:"groups"` }
User represents a Docbase User.