readme

package module
v0.0.0-...-721a260 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2021 License: MIT Imports: 17 Imported by: 0

README

go-readme


A go HTTP client for interacting with the readme.com API

Example
client, err := readme.NewClient(&Config{
  ApiKey: "12345",
})

response, err := client.ApiSpecifications.Upload(context.Background(), readme.ApiSpecificationUploadOptions{
  SpecPath: "./helloOpenAPI.json",
  Version: "1.0"
})

Documentation

Index

Constants

View Source
const (
	// ChangelogTypeAdded represents an "added" change type
	ChangelogTypeAdded = "added"

	// ChangelogTypeAdded represents a "fixed" change type
	ChangelogTypeFixed = "fixed"

	// ChangelogTypeAdded represents an "improved" change type
	ChangelogTypeImproved = "improved"

	// ChangelogTypeAdded represents a "deprecated" change type
	ChangelogTypeDeprecated = "deprecated"

	// ChangelogTypeAdded represents a "removed" change type
	ChangelogTypeRemoved = "removed"
)
View Source
const (
	DocTypeBasic = "basic"
	DocTypeError = "error"
	DocTypeLink  = "link"
)
View Source
const (

	// DefaultAddress is the default host of the readme API
	DefaultAddress = "https://dash.readme.com"

	// DefaultAddress is the default base path for all reqeusts
	DefaultBasePath = "/api/v1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiSpecification

type ApiSpecification struct {
	Title      string                    `json:"title"`
	Source     string                    `json:"source"`
	Version    string                    `json:"version"`
	LastSynced string                    `json:"lastSynced"`
	Category   *ApiSpecificationCategory `json:"category"`
	Type       string                    `json:"oas"`
	ID         string                    `json:"id"`
}

ApiSpecification represents the metadata details from an api specification

type ApiSpecificationCategory

type ApiSpecificationCategory struct {
	Title string `json:"title"`
	Slug  string `json:"slug"`
	Order int    `json:"order"`
	ID    string `json:"_id"`
}

ApiSpecificationCategory is the category created for uploaded api specifications

type ApiSpecificationList

type ApiSpecificationList struct {
	Pagination *Pagination
	Items      []*ApiSpecification
}

ApiSpecificationList is the result from the api-specifications list endpoint

type ApiSpecificationListOptions

type ApiSpecificationListOptions struct {
	PerPage int `url:"perPage,omitempty"`
	Page    int `url:"page,omitempty"`
}

ApiSpecificationListOptions is the options available for the list endpoint of the api-specifications

type ApiSpecificationStub

type ApiSpecificationStub struct {
	Title string `json:"title"`
	ID    string `json:"_id"`
}

ApiSpecificationStub is the result of the upload and update endpoints when interacting with api specifications

type ApiSpecificationUpdateOptions

type ApiSpecificationUpdateOptions struct {
	SpecPath string
}

ApiSpecificationUpdateOptions are the options available when updating an existing api specification

type ApiSpecificationUploadOptions

type ApiSpecificationUploadOptions struct {
	SpecPath string
	Version  string
}

ApiSpecificationUploadOptions are the options available when uploading a new api specification

type ApiSpecifications

ApiSpecifications describes the API methods available for the api-specifications API https://docs.readme.com/reference/getapispecification

type Categories

type Categories interface {
	List(ctx context.Context, options CategoriesListOptions) (*CategoriesList, error)
	Get(ctx context.Context, slug string) (*Category, error)
}

Categories describes the API methods available for the Categories API https://docs.readme.com/reference/getcategories

type CategoriesList

type CategoriesList struct {
	Pagination *Pagination
	Items      []*Category
}

CategoriesList is the API response details of the List method

type CategoriesListOptions

type CategoriesListOptions struct {
	PerPage int `url:"perPage,omitempty"`
	Page    int `url:"page,omitempty"`
}

CategoriesListOptions is a url-encodable data structure for options you can provide to the List endpoint

type Category

type Category struct {
	Title     string `json:"title"`
	Slug      string `json:"slug"`
	Order     int    `json:"order"`
	Reference bool   `json:"reference"`
	IsAPI     bool   `json:"isAPI"`
	Version   string `json:"version"`
	Project   string `json:"project"`
	CreatedAt string `json:"createdAt"`
	ID        string `json:"_id"`
}

type Changelog

type Changelog struct {
	Metadata              Metadata `json:"metadata"`
	Title                 string   `json:"title"`
	Slug                  string   `json:"slug"`
	Body                  string   `json:"body"`
	Type                  string   `json:"type"`
	Hidden                bool     `json:"hidden"`
	PendingAlgoliaPublish bool     `json:"pendingAlgoliaPublish"`
	CreatedAt             string   `json:"createdAt"`
	Html                  string   `json:"html"`
}

Changelog contains the details of each Changelog

type ChangelogCreateOptions

type ChangelogCreateOptions struct {
	Title    string   `json:"title"`
	Body     string   `json:"body"`
	Type     string   `json:"type,omitempty"`
	Hidden   *bool    `json:"hidden,omitempty"`
	Metadata Metadata `json:"metadata,omitempty"`
}

ChangelogCreateOptions is the API request body when creating a Changelog

type ChangelogUpdateOptions

type ChangelogUpdateOptions struct {
	Title  string `json:"title,omitempty"`
	Body   string `json:"body,omitempty"`
	Type   string `json:"type,omitempty"`
	Hidden *bool  `json:"hidden,omitempty"`
}

ChangelogUpdateOptions is the API request body when updating a Changelog

type Changelogs

type Changelogs interface {
	List(ctx context.Context, options ChangelogsListOptions) (*ChangelogsList, error)
	Create(ctx context.Context, changelog ChangelogCreateOptions) (*Changelog, error)
	Update(ctx context.Context, slug string, changelog ChangelogUpdateOptions) (*Changelog, error)
	Delete(ctx context.Context, slug string) error
}

Changelogs describes the API methods available for the Changelogs API https://docs.readme.com/reference/getchangelogs

type ChangelogsList

type ChangelogsList struct {
	Pagination *Pagination
	Items      []*Changelog
}

ChangelogsList is the API response details of the List method

type ChangelogsListOptions

type ChangelogsListOptions struct {
	PerPage int `url:"perPage,omitempty"`
	Page    int `url:"page,omitempty"`
}

ChangelogsListOptions is a url-encodable data structure for options you can provide to the List endpoint

type Client

type Client struct {

	// Changelogs allows interactions with Changelog API resources
	Changelogs Changelogs

	// CustomPages allows interactions with CustomPages API resources
	CustomPages CustomPages

	// Docs allows interactions with Docs API resources
	Docs Docs

	// Categories allows interactions with Categories API resources
	Categories Categories

	// Project allows fetching metadata about the current project
	Project Project

	// Versions allows interactions with the Versions API resources
	Versions Versions

	// ApiSpecification allows interactions with ApiSpecification API resources
	ApiSpecifications ApiSpecifications
	// contains filtered or unexported fields
}

Client is the primary object used to interact with the readme API

func NewClient

func NewClient(cfg *Config) (*Client, error)

NewClient creates a new Client that can be used to interact with all readme.com APIs

type Config

type Config struct {
	// Address is the host of the readme API
	Address string

	// ApiKey to authenticate requests
	ApiKey string

	// Headers are the request headers sent with all requests
	Headers http.Header

	// HttpClient is a default pooled http client
	HttpClient *http.Client
}

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a default config using environment settings if available

type CustomPage

type CustomPage struct {
	Metadata              Metadata `json:"metadata"`
	Title                 string   `json:"title"`
	Slug                  string   `json:"slug"`
	Body                  string   `json:"body"`
	Hidden                bool     `json:"hidden"`
	Fullscreen            bool     `json:"fullscreen"`
	Html                  string   `json:"html"`
	HtmlMode              bool     `json:"htmlmode"`
	CreatedAt             string   `json:"createdAt"`
	PendingAlgoliaPublish bool     `json:"pendingAlgoliaPublish"`
}

Changelog contains the details of each Changelog

type CustomPageCreateOptions

type CustomPageCreateOptions struct {
	Title    string   `json:"title"`
	Body     string   `json:"body"`
	Html     string   `json:"html"`
	HtmlMode *bool    `json:"htmlmode,omitempty"`
	Hidden   *bool    `json:"hidden,omitempty"`
	Metadata Metadata `json:"metadata,omitempty"`
}

ChangelogCreateOptions is the API request body when creating a Changelog

type CustomPageUpdateOptions

type CustomPageUpdateOptions struct {
	Title    string   `json:"title,omitempty"`
	Body     string   `json:"body,omitempty"`
	Html     string   `json:"html"`
	HtmlMode *bool    `json:"htmlmode,omitempty"`
	Hidden   *bool    `json:"hidden,omitempty"`
	Metadata Metadata `json:"metadata,omitempty"`
}

ChangelogUpdateOptions is the API request body when updating a Changelog

type CustomPages

type CustomPages interface {
	List(ctx context.Context, options CustomPagesListOptions) (*CustomPagesList, error)
	Get(ctx context.Context, slug string) (*CustomPage, error)
	Create(ctx context.Context, changelog CustomPageCreateOptions) (*CustomPage, error)
	Update(ctx context.Context, slug string, changelog CustomPageUpdateOptions) (*CustomPage, error)
	Delete(ctx context.Context, slug string) error
}

Changelogs describes the API methods available for the Changelogs API https://docs.readme.com/reference/getcustompages

type CustomPagesList

type CustomPagesList struct {
	Pagination *Pagination
	Items      []*CustomPage
}

ChangelogsList is the API response details of the List method

type CustomPagesListOptions

type CustomPagesListOptions struct {
	PerPage int `url:"perPage,omitempty"`
	Page    int `url:"page,omitempty"`
}

ChangelogsListOptions is a url-encodable data structure for options you can provide to the List endpoint

type Doc

type Doc struct {
	Metadata              Metadata `json:"metadata"`
	Title                 string   `json:"title"`
	Type                  string   `json:"type"`
	Slug                  string   `json:"slug"`
	Excerpt               string   `json:"excerpt"`
	Body                  string   `json:"body"`
	Order                 int      `json:"order"`
	IsReference           bool     `json:"isReference"`
	Hidden                bool     `json:"hidden"`
	LinkURL               string   `json:"link_url"`
	LinkExternal          bool     `json:"link_external"`
	PendingAlgoliaPublish bool     `json:"pendingAlgoliaPublish"`
	PreviousSlug          string   `json:"previousSlug"`
	SlugUpdatedAt         string   `json:"slugUpdatedAt"`
	User                  string   `json:"user"`
	Project               string   `json:"project"`
	Category              string   `json:"category"`
	CreatedAt             string   `json:"createdAt"`
	UpdatedAt             string   `json:"updatedAt"`
	Version               string   `json:"version"`
	IsAPI                 bool     `json:"isApi"`
	ID                    string   `json:"id"`
	BodyHTML              string   `json:"body_html"`
}

type DocCreateOptions

type DocCreateOptions struct {
	Title     string    `json:"title"`
	Category  string    `json:"category"`
	Type      string    `json:"type,omitempty"`
	Hidden    *bool     `json:"hidden,omitempty"`
	Order     *int      `json:"order,omitempty"`
	ParentDoc string    `json:"parentDoc,omitempty"`
	Error     *DocError `json:"error,omitempty"`
}

type DocError

type DocError struct {
	Code string `json:"code"`
}

type DocSearchResult

type DocSearchResult struct {
	IndexName    string `json:"indexName"`
	Title        string `json:"title"`
	Slug         string `json:"slug"`
	Project      string `json:"project"`
	ReferenceID  string `json:"referenceId"`
	Subdomain    string `json:"subdomain"`
	InternalLink string `json:"internalLink"`
	ObjectID     string `json:"objectID"`
	URL          string `json:"url"`
}

type DocSearchResults

type DocSearchResults struct {
	Results []*DocSearchResult `json:"results"`
}

type DocUpdateOptions

type DocUpdateOptions struct {
	Title     string    `json:"title"`
	Category  string    `json:"category"`
	Type      string    `json:"type,omitempty"`
	Hidden    *bool     `json:"hidden,omitempty"`
	Order     *int      `json:"order,omitempty"`
	ParentDoc string    `json:"parentDoc,omitempty"`
	Error     *DocError `json:"error,omitempty"`
}

type Docs

type Docs interface {
	Get(ctx context.Context, slug string) (*Doc, error)
	Create(ctx context.Context, doc DocCreateOptions) (*Doc, error)
	Update(ctx context.Context, slug string, doc DocUpdateOptions) (*Doc, error)
	Delete(ctx context.Context, slug string) error
	Search(ctx context.Context, search string) (*DocSearchResults, error)
}

Changelogs describes the API methods available for the Changelogs API https://docs.readme.com/reference/getcustompages

type Metadata

type Metadata struct {
	Image       []string `json:"image"`
	Title       string   `json:"title"`
	Description string   `json:"description"`
}

Metadata contains the metadata details of each page

type Pagination

type Pagination struct {
	// TotalCount is the total number of records available
	TotalCount int

	// Next is the API path of the next page
	Next string

	// Prev is the API path of the previous page
	Prev string

	// Last is the API path of the last page
	Last string
}

Pagination holds pagination response data

type Project

type Project interface {
	Get(ctx context.Context) (*ProjectMetadata, error)
}

Project allows interaction with the Project API resource

type ProjectMetadata

type ProjectMetadata struct {
	Name      string `json:"name"`
	Subdomain string `json:"subdomain"`
	JwtSecret string `json:"jwtSecret"`
	BaseURL   string `json:"baseUrl"`
	Plan      string `json:"plan"`
}

ProjectMetadata is information about the project associated with the API Key/

type Version

type Version struct {
	Version      string   `json:"version"`
	VersionClean string   `json:"version_clean"`
	Categories   []string `json:"categories"`
	CodeName     string   `json:"codename"`
	IsStable     bool     `json:"is_stable"`
	IsBeta       bool     `json:"is_beta"`
	IsHidden     bool     `json:"is_hidden"`
	IsDeprecated bool     `json:"is_deprecated"`
	ID           string   `json:"_id"`
	CreatedAt    string   `json:"createdAt"`
	ForkedFrom   string   `json:"forked_from"`
	ReleaseDate  string   `json:"releaseDate"`
	Project      string   `json:"project"`
}

Version contains the details of each Version from the List endpoint

type VersionCreateOptions

type VersionCreateOptions struct {
	Version      string `json:"version"`
	CodeName     string `json:"codename,omitempty"`
	From         string `json:"from"`
	IsStable     *bool  `json:"is_stable,omitempty"`
	IsBeta       *bool  `json:"is_beta,omitempty"`
	IsHidden     *bool  `json:"is_hidden,omitempty"`
	IsDeprecated *bool  `json:"is_deprecated,omitempty"`
}

VersionCreateOptions is the API request body when creating a Version

type VersionListItem

type VersionListItem struct {
	Version      string `json:"version"`
	CodeName     string `json:"codename"`
	IsStable     bool   `json:"is_stable"`
	IsBeta       bool   `json:"is_beta"`
	IsHidden     bool   `json:"is_hidden"`
	IsDeprecated bool   `json:"is_deprecated"`
	ID           string `json:"_id"`
	CreatedAt    string `json:"createdAt"`
}

VersionListItem contains the details of each Version from the List endpoint

type VersionUpdateOptions

type VersionUpdateOptions struct {
	Version      string `json:"version"`
	CodeName     string `json:"codename,omitempty"`
	From         string `json:"from"`
	IsStable     *bool  `json:"is_stable,omitempty"`
	IsBeta       *bool  `json:"is_beta,omitempty"`
	IsHidden     *bool  `json:"is_hidden,omitempty"`
	IsDeprecated *bool  `json:"is_deprecated,omitempty"`
}

VersionUpdateOptions is the API request body when updating a Version

type Versions

type Versions interface {
	List(ctx context.Context) (*VersionsList, error)
	Get(ctx context.Context, versionId string) (*Version, error)
	Create(ctx context.Context, version VersionCreateOptions) (*Version, error)
	Update(ctx context.Context, versionId string, version VersionUpdateOptions) (*Version, error)
	Delete(ctx context.Context, versionId string) error
}

Changelogs describes the API methods available for the Changelogs API https://docs.readme.com/reference/getcustompages

type VersionsList

type VersionsList struct {
	Items []*VersionListItem
}

VersionsList is the API response details of the List method

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL