Documentation ¶
Index ¶
- Constants
- func PostQueryDate(property PostQueryDateName, year, month, day int) string
- func PostQueryDateFrom(property PostQueryDateName, year, month, day int) string
- func PostQueryDateRange(property PostQueryDateName, year1, month1, day1, year2, month2, day2 int) string
- func PostQueryDateTo(property PostQueryDateName, year, month, day int) string
- func PostQueryHasStar() string
- func PostQueryIsDraft() string
- func PostQueryIsShared() string
- func PostQueryIsUnread() string
- func PostQueryMissing(property PostQueryMissingName) string
- func PostQueryOr() string
- func PostQueryProperty(property PostQueryPropertyName, keyword string) string
- func PostQuerySort(property PostQuerySortName, asc bool) string
- func Version() string
- type AttachmentService
- type Client
- func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*Response, error)
- func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)
- func (c *Client) NewUploadRequest(urlStr string, reader io.Reader, size int64, mediaType string) (*http.Request, error)
- type Comment
- type CommentID
- type CommentListOptions
- type CommentService
- type CreatePostOptions
- type Domain
- type Error
- type ErrorResponse
- type Group
- type GroupID
- type GroupListOptions
- type GroupService
- type ListOptions
- type Meta
- type Post
- type PostEditRequest
- type PostID
- type PostListOptions
- type PostQueryDateName
- type PostQueryMissingName
- type PostQueryPropertyName
- type PostQuerySortName
- type PostService
- func (s *PostService) Create(ctx context.Context, domain Domain, post *CreatePostOptions) (*Post, *Response, error)
- func (s *PostService) Delete(ctx context.Context, domain Domain, id PostID) (*Response, error)
- func (s *PostService) Edit(ctx context.Context, domain Domain, id PostID, post *PostEditRequest) (*Post, *Response, error)
- func (s *PostService) Get(ctx context.Context, domain Domain, id PostID) (*Post, *Response, error)
- func (s *PostService) List(ctx context.Context, domain Domain, opt *PostListOptions) ([]Post, *Response, error)
- type Rate
- type RateLimitError
- type Response
- type Scope
- type Tag
- type TagListOptions
- type TagService
- type Team
- type TeamListOptions
- type TeamService
- type Timestamp
- type TokenTransport
- type UploadOptions
- type User
- type UserID
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") )
const ( PostQuerySortNameScore = PostQuerySortName("score") PostQuerySortNameChangedAt = PostQuerySortName("changed_at") PostQuerySortNameCreatedAt = PostQuerySortName("created_at") PostQuerySortNameStars = PostQuerySortName("stars") PostQuerySortNameComments = PostQuerySortName("comments") PostQuerySortNameLikes = PostQuerySortName("likes") )
Concrete properties to sort posts.
const ( PostQueryPropertyNameTitle = PostQueryPropertyName("title") PostQueryPropertyNameBody = PostQueryPropertyName("body") PostQueryPropertyNameComments = PostQueryPropertyName("comments") PostQueryPropertyNameAttachments = PostQueryPropertyName("attachments") PostQueryPropertyNameAuthor = PostQueryPropertyName("author") PostQueryPropertyNameCommentedBy = PostQueryPropertyName("commented_by") PostQueryPropertyNameLikedBy = PostQueryPropertyName("liked_by") PostQueryPropertyNameTag = PostQueryPropertyName("tag") PostQueryPropertyNameGroup = PostQueryPropertyName("group") )
Concrete properties to search the keyword from posts
const ( PostQueryDateNameCreatedAt = PostQueryDateName("created_at") PostQueryDateNameChangedAt = PostQueryDateName("changed_at") )
Concrete properties to search the keyword from posts
const (
PostQueryMissingNameTag = PostQueryMissingName("tag")
)
Concrete properties to search the keyword from posts
Variables ¶
This section is empty.
Functions ¶
func PostQueryDate ¶
func PostQueryDate(property PostQueryDateName, year, month, day int) string
PostQueryDate specifies the date with property name to search posts
func PostQueryDateFrom ¶
func PostQueryDateFrom(property PostQueryDateName, year, month, day int) string
PostQueryDateFrom specifies the start date with property name to search posts
func PostQueryDateRange ¶
func PostQueryDateRange(property PostQueryDateName, year1, month1, day1, year2, month2, day2 int) string
PostQueryDateRange specifies the date range with property name to search posts
func PostQueryDateTo ¶
func PostQueryDateTo(property PostQueryDateName, year, month, day int) string
PostQueryDateTo specifies the end date with property name to search posts
func PostQueryMissing ¶
func PostQueryMissing(property PostQueryMissingName) string
PostQueryMissing specifies a property to search posts which is not filled
func PostQueryProperty ¶
func PostQueryProperty(property PostQueryPropertyName, keyword string) string
PostQueryProperty specifies a property to search the keyword from posts
func PostQuerySort ¶
func PostQuerySort(property PostQuerySortName, asc bool) string
PostQuerySort specifies sort order to get posts.
Types ¶
type AttachmentService ¶
type AttachmentService service
AttachmentService provides access to the installation related functions in the Docbase API.
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. Team *TeamService Tag *TagService Group *GroupService Post *PostService Comment *CommentService Attachment *AttachmentService // contains filtered or unexported fields }
A Client manages communication with the Docbase API.
func NewClient ¶
NewClient returns a new Docbase API client. If a nil httpClient is provided, http.DefaultClient will be used. To use API methods which require authentication, provide an http.Client that will perform the authentication for you (such as that provided by the golang.org/x/oauth2 library).
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.
func (*Client) NewUploadRequest ¶
func (c *Client) NewUploadRequest(urlStr string, reader io.Reader, size int64, mediaType string) (*http.Request, error)
NewUploadRequest creates an upload request. A relative URL can be provided in urlStr, in which case it is resolved relative to the UploadURL of the Client. Relative URLs should always be specified without a preceding slash.
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 CommentListOptions ¶
type CommentListOptions struct {
ListOptions
}
CommentListOptions specifies the optional parameters to the CommentService.List methods.
type CommentService ¶
type CommentService service
CommentService handles communication with the Comment related methods of the Docbase API.
func (*CommentService) Create ¶
func (s *CommentService) Create(ctx context.Context, domain Domain, postID PostID, comment *Comment) (*Comment, *Response, error)
Create a comment for a post.
Docbase API docs: https://help.docbase.io/posts/216289
func (*CommentService) Delete ¶
Delete a comment.
Docbase API docs: https://help.docbase.io/posts/216290
type CreatePostOptions ¶
type CreatePostOptions struct { // Required. Title string `json:"title"` Body string `json:"body"` // Option. Draft bool `json:"draft,omitempty"` Groups []GroupID `json:"groups,omitempty"` Scope Scope `json:"scope,omitempty"` Tags []string `json:"tags,omitempty"` Notice bool `json:"notice,omitempty"` // Parameters that only owners can use. AuthorID *UserID `json:"author_id,omitempty"` PublishedAt *time.Time `json:"published_at,omitempty"` }
CreatePostOptions represents a Docbase Post.
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 GroupListOptions ¶
type GroupListOptions struct {
ListOptions
}
GroupListOptions specifies the optional parameters to the GroupService.List methods.
type GroupService ¶
type GroupService service
GroupService provides access to the installation related functions in the Docbase API.
func (*GroupService) List ¶
func (s *GroupService) List(ctx context.Context, domain Domain, opt *GroupListOptions) ([]*Group, *Response, error)
List groups for a domain.
Docbase API docs: https://help.docbase.io/posts/92978
type ListOptions ¶
type ListOptions struct { // For paginated result sets, page of results to retrieve. Page int `url:"page,omitempty"` // For paginated result sets, the number of results to include per page. PerPage int `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 { Body string `json:"body"` Comments []Comment `json:"comments"` CreatedAt string `json:"created_at"` Draft bool `json:"draft"` Groups []Group `json:"groups"` ID PostID `json:"id"` Scope Scope `json:"scope"` Tags []Tag `json:"tags"` Title string `json:"title"` URL string `json:"url"` User User `json:"user"` }
Post represents a Docbase Post.
type PostEditRequest ¶
type PostEditRequest struct { Body *string `json:"body,omitempty"` Draft *bool `json:"draft,omitempty"` Groups []GroupID `json:"groups,omitempty"` Scope *Scope `json:"scope,omitempty"` Tags []string `json:"tags,omitempty"` Title *string `json:"title,omitempty"` }
PostEditRequest represents a request body for `Edit` function.
type PostListOptions ¶
type PostListOptions struct { // Query filters Post. // // docs: https://help.docbase.io/posts/59432?list=%2Fsearch&q=%E6%A4%9C%E7%B4%A2#%E6%A4%9C%E7%B4%A2%E3%82%AA%E3%83%97%E3%82%B7%E3%83%A7%E3%83%B3 Query string `url:"q,omitempty"` ListOptions }
PostListOptions specifies the optional parameters to the PostService.List method.
type PostQueryDateName ¶
type PostQueryDateName string
PostQueryDateName specifies a property to search the keyword from posts
func (PostQueryDateName) String ¶
func (s PostQueryDateName) String() string
type PostQueryMissingName ¶
type PostQueryMissingName string
PostQueryMissingName specifies a property to search the keyword from posts
func (PostQueryMissingName) String ¶
func (s PostQueryMissingName) String() string
type PostQueryPropertyName ¶
type PostQueryPropertyName string
PostQueryPropertyName specifies a property to search the keyword from posts
func (PostQueryPropertyName) String ¶
func (s PostQueryPropertyName) String() string
type PostQuerySortName ¶
type PostQuerySortName string
PostQuerySortName specifies a property to sort posts.
func (PostQuerySortName) String ¶
func (s PostQuerySortName) String() string
type PostService ¶
type PostService service
PostService handles communication with the Post related methods of the Docbase API.
func (*PostService) Create ¶
func (s *PostService) Create(ctx context.Context, domain Domain, post *CreatePostOptions) (*Post, *Response, error)
Create a post for a domain.
Docbase API docs: https://help.docbase.io/posts/92980
func (*PostService) Edit ¶
func (s *PostService) Edit(ctx context.Context, domain Domain, id PostID, post *PostEditRequest) (*Post, *Response, error)
Edit a post.
Docbase API docs: https://help.docbase.io/posts/92981
func (*PostService) List ¶
func (s *PostService) List(ctx context.Context, domain Domain, opt *PostListOptions) ([]Post, *Response, error)
List posts in a domain. To build query, use PostQueryXXX functions.
Docbase API docs: https://help.docbase.io/posts/92984 Docbase query docs: https://help.docbase.io/posts/59432
type Rate ¶
type Rate struct { // The number of requests per hour the client is currently limited to. Limit int // The number of remaining requests the client can make this hour. Remaining int // 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 TagListOptions ¶
type TagListOptions struct {
ListOptions
}
TagListOptions specifies the optional parameters to the TagService.List methods.
type TagService ¶
type TagService service
TagService provides access to the installation related functions in the Docbase API.
func (*TagService) List ¶
func (s *TagService) List(ctx context.Context, domain Domain, opt *TagListOptions) ([]*Tag, *Response, error)
List tags for a domain.
Docbase API docs: https://help.docbase.io/posts/92979
type TeamListOptions ¶
type TeamListOptions struct {
ListOptions
}
TeamListOptions specifies the optional parameters to the TeamService.List methods.
type TeamService ¶
type TeamService service
TeamService provides access to the installation related functions in the Docbase API.
func (*TeamService) List ¶
func (s *TeamService) List(ctx context.Context, opt *TeamListOptions) ([]*Team, *Response, error)
List teams.
Docbase API docs: https://help.docbase.io/posts/92977
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 UploadOptions ¶
type UploadOptions struct {
Name string `url:"name,omitempty"`
}
UploadOptions specifies the parameters to methods that support uploads.