readme

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 15 Imported by: 2

Documentation

Overview

ReadMe API Client for Go is for performing API operations with ReadMe.com.

Refer to https://docs.readme.com/main/reference/intro/getting-started for more information about the ReadMe API.

Index

Constants

View Source
const (
	// PaginationHeader is the name of the HTTP response header with pagination links.
	PaginationHeader = "link"

	// ReadmeAPIURL is the default base URL for the ReadMe API.
	ReadmeAPIURL = "https://dash.readme.com/api/v1"

	// TotalCountHeader is the name of the HTTP response header with the total count in results.
	TotalCountHeader = "x-total-count"

	// UserAgent is the name of the HTTP UserAgent when making requests.
	UserAgent = "readme-api-go-client"
)
View Source
const APIRegistryEndpoint = "/api-registry"

APIRegistryEndpoint is the ReadMe API URL endpoint for the API registry.

View Source
const APISpecificationEndpoint = "/api-specification"

APISpecificationEndpoint is the ReadMe API Endpoint for API Specifications.

View Source
const APISpecificationFormField = "spec"

APISpecificationFormField is the name of the form field for uploading API Specifications.

View Source
const ApplyEndpoint = "/apply"

ApplyEndpoint is the ReadMe API URL endpoint for listing open positions at ReadMe and applying for a them.

View Source
const CategoryEndpoint = "/categories"

CategoryEndpoint is the ReadMe API endpoint for categories.

View Source
const ChangelogEndpoint = "/changelogs"

ChangelogEndpoint is ReadMe API Endpoint for changelogs.

View Source
const CustomPageEndpoint = "/custompages"

CustomPageEndpoint is the ReadMe API Endpoint for custom pages.

View Source
const DocEndpoint = "/docs"

DocEndpoint is the ReadMe API endpoint for docs.

View Source
const ImageAPIURL = "https://dash.readme.com/api/images"

ImageAPIURL is the base URL for the images endpoint of the ReadMe API. This endpoint is used for uploading images to ReadMe and is not part of the documented 'v1' API.

View Source
const OutboundIPEndpoint = "/outbound-ips"

OutboundIPEndpoint is the ReadMe API URL endpoint for retrieving ReadMe's outbound IP addresses.

View Source
const ProjectEndpoint = "/"

ProjectEndpoint is the ReadMe API URL endpoint for Project metadata.

View Source
const VersionEndpoint = "/version"

VersionEndpoint is the ReadMe API URL endpoint for Version metadata.

Variables

View Source
var IDValidCharacters = regexp.MustCompile("^[0-9a-zA-Z]+$")

IDValidCharacters is a compiled RegEx pattern that matches valid characters in an object ID or API Registry UUID.

Functions

func HasNextPage added in v0.2.0

func HasNextPage(links string) (bool, error)

HasNextPage checks if a "next" link is provided in the "links" response header for pagination, indicating the request has a next page.

This does a rudimentary parsing of the header value, splitting on the comma-separated links and parsing the value of "rel".

A link header looks like: </api-specification?page=2>; rel="next", <>; rel="prev", <>; rel="last"

func ParseID added in v0.2.0

func ParseID(id string) (bool, string)

ParseID checks a string to determine if it appears to be a valid ReadMe API object ID.

The provided parameter should be a ReadMe API object ID prefixed with "id:".

NOTE: The min and max lengths aren't certain or documented in the API.

func ParseUUID added in v0.2.0

func ParseUUID(uuid string) (bool, string)

ParseUUID checks a string to determine if it appears to be a valid ReadMe API Registry UUID.

The provided parameter should be a ReadMe API Registry UUID prefixed with "uuid:".

NOTE: The min and max lengths aren't certain or documented in the API. The UUID length varies.

func ValidateID added in v0.2.0

func ValidateID(id, prefix string, min_len, max_len int) (bool, string)

ValidateID is a helper script for parseID() and parseUUID() that checks a string to determine if it appears to be a valid ReadMe API object ID or Registry UUID.

Types

type APIErrorResponse

type APIErrorResponse struct {
	// Docs is a ReadMe Metrics log URL where more information about the request can be retrieved.
	// If metrics URLs are unavailable for the request, this URL will be a URL to the ReadMe API Reference.
	Docs string `json:"docs"`
	// Error is an error code unique to the error received.
	Error string `json:"error"`
	// Help is information on where additional assistance from the ReadMe support team can be obtained.
	Help string `json:"help"`
	// Message is the reason why the error occurred.
	Message string `json:"message"`
	// Poem is a short poem about the error.
	Poem []string `json:"poem"`
	// Suggestion is a helpful suggestion for how to alleviate the error.
	Suggestion string `json:"suggestion"`
}

APIErrorResponse represents the response ReadMe provides in the body of requests that failed.

type APIRegistryClient

type APIRegistryClient struct {
	// contains filtered or unexported fields
}

APIRegistryClient handles communication with the Registry related methods of the ReadMe.com API.

func (APIRegistryClient) Create

func (c APIRegistryClient) Create(definition string, version ...string) (APIRegistrySaved, *APIResponse, error)

Create a new API registry on ReadMe.

The response returns the UUID and the specification definition.

NOTE: This is an undocumented endpoint on ReadMe and was discovered by inspecting the ReadMe CLI application.

The registry UUID is required for retrieving the remote specification. A typical workflow will be to create the registry with this method and follow-up with a call to APISpecification.Create() with the UUID returned from this response.

func (APIRegistryClient) Get

func (c APIRegistryClient) Get(uuid string) (string, *APIResponse, error)

Get retrieves an API definition from the ReadMe.com API registry with a provided UUID and returns it as a string.

API Reference: https://docs.readme.com/main/reference/getapiregistry

type APIRegistrySaved

type APIRegistrySaved struct {
	Definition   map[string]interface{} `json:"definition"`
	RegistryUUID string                 `json:"registryUUID"`
}

APIRegistrySaved represents the API response when an API Registry is created.

type APIRegistryService

type APIRegistryService interface {
	// Create a new API registry on ReadMe.
	//
	// The response returns the UUID and the specification definition.
	//
	// NOTE: This is an undocumented endpoint on ReadMe and was discovered by inspecting the ReadMe
	// CLI application. The registry UUID is required for retrieving the remote specification.
	// A typical workflow will be to create the registry with this method and follow-up with a call
	// to APISpecification.Create() with the UUID returned from this response.
	Create(definition string, version ...string) (APIRegistrySaved, *APIResponse, error)

	// Get retrieves an API definition from the ReadMe.com API registry with a provided UUID and
	// returns it as a string.
	//
	// API Reference: https://docs.readme.com/main/reference/getapiregistry
	Get(uuid string) (string, *APIResponse, error)
}

APIRegistryService is an interface for interacting with the API Registry endpoints of the ReadMe.com API.

type APIRequest

type APIRequest struct {
	// Endpoint is the API endpoint (after the base URL) for the request.
	Endpoint string

	// Headers lists HTTP headers to send in the request, in addition to the implicit headers.
	Headers []RequestHeader

	// Slice of HTTP status codes that are considered 'ok'.
	// Any other status code in the response results in an error.
	OkStatusCode []int

	// Method is the HTTP method to use for the request.
	Method string

	// An optional payload, in bytes, for the request.
	Payload []byte

	// Optional options for a request, including headers, version and pagination options.
	RequestOptions

	// Interface of a struct to map the response body to.
	Response interface{}

	// UseAuth toggles whether the request should use authentication or not.
	UseAuth bool

	// URL is a full URL string to use for the request as an alternative to Endpoint.
	URL string
}

APIRequest represents a request to the ReadMe.com API.

type APIResponse

type APIResponse struct {
	// APIErrorResponse is a structured error from the ReadMe API when a request results in error.
	APIErrorResponse APIErrorResponse
	// Body is the response body in bytes.
	Body []byte
	// HTTPResponse is the stdlib http.Response type.
	HTTPResponse *http.Response
	// Request is the APIRequest struct used to create the request.
	Request *APIRequest
}

APIResponse represents the response from a request to the ReadMe API.

type APISpecification

type APISpecification struct {
	Category   CategorySummary `json:"category"`
	ID         string          `json:"id"`
	LastSynced string          `json:"lastSynced"`
	Source     string          `json:"source"`
	Title      string          `json:"title"`
	Type       string          `json:"type"`
	Version    string          `json:"version"`
}

APISpecification represents an API specification on ReadMe.com.

type APISpecificationClient

type APISpecificationClient struct {
	// contains filtered or unexported fields
}

APISpecificationClient handles communication with the API specification related methods of the ReadMe.com API.

func (APISpecificationClient) Create

func (c APISpecificationClient) Create(
	definition string,
	options ...RequestOptions,
) (APISpecificationSaved, *APIResponse, error)

Create a new API specification on ReadMe by uploading a specification definition provided as a JSON string or by associating an existing definition in the API registry by providing a registry UUID as a parameter.

The `definition` parameter can be a JSON string of the full definition or a string with the UUID of an API registry in ReadMe prefixed with "uuid:". A UUID can be obtained from the APIRegistry.Create() method's response.

NOTE: specifying the definition as a UUID is an *undocumented* feature of the API.

See https://docs.readme.com/reference/uploadapispecification

func (APISpecificationClient) Delete

func (c APISpecificationClient) Delete(specID string) (bool, *APIResponse, error)

Delete an API Specification by ID. It returns true if it successfully deletes an API Specification.

API Reference: https://docs.readme.com/reference/deleteapispecification

func (APISpecificationClient) Get

Get a single API specification with a provided ID.

Requesting a single API specification isn't included in the API. The client uses GetAll() to retrieve the full list and matches the requested ID to the list.

An error is returned if the specification wasn't found.

See https://docs.readme.com/reference/getapispecification

func (APISpecificationClient) GetAll

GetAll retrieves and returns all API specifications on ReadMe.com.

API Reference: https://docs.readme.com/reference/getapispecification

func (APISpecificationClient) Update

func (c APISpecificationClient) Update(
	specID, definition string,
) (APISpecificationSaved, *APIResponse, error)

Update an existing API specification on ReadMe by uploading a specification definition provided as a JSON string or by associating an existing definition in the API registry by providing a registry UUID as a parameter.

The `definition` parameter can be a JSON string of the full definition or a string with the UUID of an API registry in ReadMe prefixed with "uuid:". A UUID can be obtained from the APIRegistry.Create() method's response.

NOTE: specifying the definition as a UUID is an *undocumented* feature of the API.

API Reference: https://docs.readme.com/reference/updateapispecification

func (APISpecificationClient) UploadDefinition added in v0.2.0

func (c APISpecificationClient) UploadDefinition(
	method, definition, url, version string,
	response interface{},
) (interface{}, *APIResponse, error)

UploadDefinition uploads an API specification definition by making a request that submits form data with the specification definition provided as a string.

APISpecification.Create() should be used in most cases instead of calling this directly.

type APISpecificationSaved

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

APISpecificationSaved represents a successful response to creating an API specification on ReadMe.com.

type APISpecificationService

type APISpecificationService interface {
	// Create a new API specification on ReadMe by uploading a specification definition provided as
	// a JSON string or by associating an existing definition in the API registry by providing a
	// registry UUID as a parameter.
	//
	// The `definition` parameter can be a JSON string of the full definition or a string with the
	// UUID of an API registry in ReadMe prefixed with "uuid:". A UUID can be obtained from the
	// APIRegistry.Create() method's response.
	//
	// NOTE: specifying the definition as a UUID is an *undocumented* feature of the API.
	//
	// API Reference: https://docs.readme.com/reference/uploadapispecification
	Create(definition string, options ...RequestOptions) (APISpecificationSaved, *APIResponse, error)

	// Delete an API Specification by ID.
	// It returns true if it successfully deletes an API Specification.
	//
	// API Reference: https://docs.readme.com/reference/deleteapispecification
	Delete(specID string) (bool, *APIResponse, error)

	// Get a single API specification with a provided ID.
	//
	// Requesting a single API specification isn't included in the API. The client uses GetAll() to
	// retrieve the full list and matches the requested ID to the list.
	//
	// An error is returned if the specification wasn't found.
	//
	// API Reference: https://docs.readme.com/reference/getapispecification
	Get(specID string, options ...RequestOptions) (APISpecification, *APIResponse, error)

	// GetAll retrieves and returns all API specifications on ReadMe.com.
	//
	// API Reference: https://docs.readme.com/reference/getapispecification
	GetAll(...RequestOptions) ([]APISpecification, *APIResponse, error)

	// Update an existing API specification on ReadMe by uploading a specification definition
	// provided as a JSON string or by associating an existing definition in the API registry by
	// providing a registry UUID as a parameter.
	//
	// The `definition` parameter can be a JSON string of the full definition or a string with the
	// UUID of an API registry in ReadMe prefixed with "uuid:". A UUID can be obtained from the
	// APIRegistry.Create() method's response.
	//
	// NOTE: specifying the definition as a UUID is an *undocumented* feature of the API.
	//
	// API Reference: https://docs.readme.com/reference/updateapispecification
	Update(specID, definition string) (APISpecificationSaved, *APIResponse, error)

	// UploadDefinition uploads an API specification definition by making a request that submits
	// form data with the specification definition provided as a string.
	// APISpecification.Create() should be used in most cases instead of calling this directly.
	UploadDefinition(method, content, url, version string, response interface{}) (interface{}, *APIResponse, error)
}

APISpecificationService is an interface for using the API Specification endpoints of the ReadMe.com API.

type Application

type Application struct {
	// CoverLetter is additional information for the application.
	CoverLetter string `json:"coverLetter,omitempty"`
	// DontReallyApply toggles actually applying or just trying out the API. Set
	// this to 'true' to test without applying.
	// API default is `false`.
	DontReallyApply *bool `json:"dontReallyApply"`
	// Email is a valid email we can reach you at.
	// This is *required* when submitting an application.
	Email string `json:"email"`
	// GitHub is a URL for GitHub, Bitbucket, Gitlab or anywhere else your code is hosted!
	GitHub string `json:"github,omitempty"`
	// Job is the job you're looking to apply for.
	// This is *required* when submitting an application.
	Job string `json:"job"`
	// LinkedIn is a link to a LinkedIn profile.
	LinkedIn string `json:"linkedin,omitempty"`
	// Name is your full name.
	// This is *required* when submitting an application.
	Name string `json:"name"`
	// Pronouns is a list pronouns an applicant uses.
	Pronouns string `json:"pronouns,omitempty"`
}

Application represents the parameters used for submitting an application to ReadMe.

type ApplyClient

type ApplyClient struct {
	// contains filtered or unexported fields
}

ApplyClient handles communication with the Apply related methods of the ReadMe.com API.

func (ApplyClient) Apply

func (c ApplyClient) Apply(application Application) (ApplyResponse, *APIResponse, error)

Apply for an open role at ReadMe.

API Reference: https://docs.readme.com/main/reference/applytoreadme

func (ApplyClient) Get

func (c ApplyClient) Get() ([]OpenRole, *APIResponse, error)

Get a list of open roles at ReadMe.

API Reference: https://docs.readme.com/main/reference/getopenroles

type ApplyResponse

type ApplyResponse struct {
	Careers   string   `json:"careers"`
	Keyvalues string   `json:"keyvalues"`
	Message   string   `json:"message"`
	Poem      []string `json:"poem"`
	Questions string   `json:"questions?"`
}

ApplyResponse represents the API response when an application is submitted.

type ApplyService

type ApplyService interface {
	// Apply for an open role at ReadMe.
	//
	// API Reference: https://docs.readme.com/main/reference/applytoreadme
	Apply(application Application) (ApplyResponse, *APIResponse, error)

	// Get a list of open roles at ReadMe.
	//
	// API Reference: https://docs.readme.com/main/reference/getopenroles
	Get() ([]OpenRole, *APIResponse, error)
}

ApplyService is an interface for interacting with the Apply endpoints of the ReadMe.com API.

API Reference: https://docs.readme.com/main/reference/getopenroles

type Category

type Category struct {
	CategoryType string `json:"categoryType"`
	CreatedAt    string `json:"createdAt"`
	ID           string `json:"id"`
	Order        int    `json:"order"`
	Project      string `json:"project"`
	Reference    bool   `json:"reference"`
	Slug         string `json:"slug"`
	Title        string `json:"title"`
	Type         string `json:"type"`
	Version      string `json:"version"`
}

Category represents a single category in ReadMe.

type CategoryClient

type CategoryClient struct {
	// contains filtered or unexported fields
}

CategoryClient handles communication with the categories related methods of the ReadMe.com API.

func (CategoryClient) Create

func (c CategoryClient) Create(
	response any,
	params CategoryParams,
	options ...RequestOptions,
) (*APIResponse, error)

Create a new category in ReadMe.

API Reference: https://docs.readme.com/main/reference/createcategory

func (CategoryClient) Delete

func (c CategoryClient) Delete(slug string, options ...RequestOptions) (bool, *APIResponse, error)

Delete an existing category in ReadMe.

API Reference: https://docs.readme.com/reference/deletecategory

func (CategoryClient) Get

func (c CategoryClient) Get(category string, options ...RequestOptions) (Category, *APIResponse, error)

Get a single category on ReadMe.com.

The `category` parameter may be a slug or category ID prefixed with "id:". The slug is preferred, since it's a more direct request while the ID requires iterating over the list of all categories for a matching ID.

API Reference: https://docs.readme.com/reference/getcategory

func (CategoryClient) GetAll

func (c CategoryClient) GetAll(options ...RequestOptions) ([]Category, *APIResponse, error)

GetAll retrieves and returns all categories on ReadMe.com.

API Reference: https://docs.readme.com/reference/getcategories

func (CategoryClient) GetDocs

func (c CategoryClient) GetDocs(slug string, options ...RequestOptions) ([]CategoryDocs, *APIResponse, error)

GetDocs a list of docs metadata for a category on ReadMe.

API Reference: https://docs.readme.com/main/reference/getcategorydocs

func (CategoryClient) Update

func (c CategoryClient) Update(
	slug string,
	params CategoryParams,
	options ...RequestOptions,
) (Category, *APIResponse, error)

Update an existing category in ReadMe.

API Reference: https://docs.readme.com/main/reference/updatecategory

type CategoryDocs

type CategoryDocs struct {
	Children []CategoryDocs `json:"children"` // Children is limited by ReadMe to a depth of 2.
	Hidden   bool           `json:"hidden"`
	ID       string         `json:"_id"`
	Order    int            `json:"order"`
	Slug     string         `json:"slug"`
	Title    string         `json:"title"`
}

CategoryDocs represents a document within a category.

type CategoryParams

type CategoryParams struct {
	// Title is a *required* short title for the category. This is what will show in the sidebar.
	Title string `json:"title"`
	// Type is the type of category, which can be "reference" or "guide".
	Type string `json:"type"`
}

CategoryParams represents the parameters to create or update a category in ReadMe.

type CategorySaved

type CategorySaved struct {
	CreatedAt string  `json:"createdAt"`
	ID        string  `json:"id"`
	Order     int     `json:"order"`
	Project   string  `json:"project"`
	Reference bool    `json:"reference"`
	Slug      string  `json:"slug"`
	Title     string  `json:"title"`
	Type      string  `json:"type"`
	Version   Version `json:"version"`
}

CategorySaved represents the ReadMe API response when a category is created or updated.

type CategoryService

type CategoryService interface {
	// Create a new category in ReadMe.
	//
	// The `response` parameter should be a to a `CategorySaved` or `CategoryVersionSaved`
	// interface. When specifying a `Version` in the `options` parameter, the API responds with
	// `CategoryVersionSaved`. When a version isn't specified, it responds with `CategorySaved`.
	//
	// Without a version:
	//
	//	category := &readme.CategorySaved{}
	//	apiResponse, err := rdme.Category.Create(category, {params...})
	//
	// With a version:
	//
	//	options := readme.RequestOptions{Version: "1.2.0"}
	//	category := &readme.CategoryVersionSaved{}
	//	apiResponse, err := rdme.Category.Create(category, {params...}, options)
	//
	// API Reference: https://docs.readme.com/main/reference/createcategory
	Create(response any, params CategoryParams, options ...RequestOptions) (*APIResponse, error)

	// Delete an existing category in ReadMe.
	//
	// API Reference: https://docs.readme.com/reference/deletecategory
	Delete(slug string, options ...RequestOptions) (bool, *APIResponse, error)

	// Get a single category on ReadMe.com.
	//
	// The `category` parameter may be a slug or category ID prefixed with "id:".
	// The slug is preferred, since it's a more direct request while the ID requires
	// iterating over the list of all categories for a matching ID.
	//
	// API Reference: https://docs.readme.com/reference/getcategory
	Get(category string, options ...RequestOptions) (Category, *APIResponse, error)

	// GetAll retrieves and returns all categories on ReadMe.com.
	//
	// API Reference: https://docs.readme.com/reference/getcategories
	GetAll(options ...RequestOptions) ([]Category, *APIResponse, error)

	// GetDocs a list of docs metadata for a category on ReadMe.
	//
	// API Reference: https://docs.readme.com/main/reference/getcategorydocs
	GetDocs(slug string, options ...RequestOptions) ([]CategoryDocs, *APIResponse, error)

	// Update an existing category in ReadMe.
	//
	// Note that Update() returns a Category struct type while Create() returns
	// CategorySaved or CategoryVersionSaved.
	//
	// API Reference: https://docs.readme.com/main/reference/updatecategory
	Update(slug string, params CategoryParams, options ...RequestOptions) (Category, *APIResponse, error)
}

CategoryService is an interface for using the category endpoints of the ReadMe.com API.

API Reference: https://docs.readme.com/main/reference/getcategories

type CategorySummary

type CategorySummary struct {
	ID    string `json:"id"`
	Order int    `json:"order"`
	Slug  string `json:"slug"`
	Title string `json:"title"`
	Type  string `json:"type"`
}

CategorySummary represents basic information about a category. This is used in the response for API specification metadata.

type CategoryVersion

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

type CategoryVersionForkedFrom

type CategoryVersionForkedFrom struct {
	ID      string `json:"_id"`
	Version string `json:"version"`
}

type CategoryVersionSaved

type CategoryVersionSaved struct {
	CreatedAt string          `json:"createdAt"`
	ID        string          `json:"id"`
	Order     int             `json:"order"`
	Project   string          `json:"project"`
	Reference bool            `json:"reference"`
	Slug      string          `json:"slug"`
	Title     string          `json:"title"`
	Type      string          `json:"type"`
	Version   CategoryVersion `json:"version"`
}

type Changelog

type Changelog struct {
	Algolia   DocAlgolia  `json:"algolia"`
	Body      string      `json:"body"`
	CreatedAt string      `json:"createdAt"`
	HTML      string      `json:"html"`
	Hidden    bool        `json:"hidden"`
	ID        string      `json:"_id"`
	Metadata  DocMetadata `json:"metadata"`
	Project   string      `json:"project,omitempty"`
	Revision  int         `json:"revision"`
	Slug      string      `json:"slug"`
	Title     string      `json:"title"`
	Type      string      `json:"type"`
	UpdatedAt string      `json:"updatedAt"`
	User      DocUser     `json:"user,omitempty"`
}

Changelog represents a Changelog object on ReadMe.

This is the struct for retrieving and creating Changelog.

type ChangelogClient

type ChangelogClient struct {
	// contains filtered or unexported fields
}

ChangelogClient handles communication with the docs related methods of the ReadMe.com API.

func (ChangelogClient) Create

Create a new changelog in ReadMe.

API Reference: https://docs.readme.com/main/reference/createchangelog

func (ChangelogClient) Delete

func (c ChangelogClient) Delete(slug string) (bool, *APIResponse, error)

Delete a changelog in ReadMe.

API Reference: https://docs.readme.com/main/reference/deletechangelog

func (ChangelogClient) Get

Get retrieves a single changelog from ReadMe.

API Reference: https://docs.readme.com/main/reference/getchangelog

func (ChangelogClient) GetAll

func (c ChangelogClient) GetAll(options ...RequestOptions) ([]Changelog, *APIResponse, error)

GetAll retrieves a list of changelogs from ReadMe.

API Reference: https://docs.readme.com/main/reference/getchangelogs

func (ChangelogClient) Update

func (c ChangelogClient) Update(slug string, params ChangelogParams) (Changelog, *APIResponse, error)

Update an existing changelog in ReadMe.

API Reference: https://docs.readme.com/main/reference/updatechangelog

type ChangelogParams

type ChangelogParams struct {
	// Body content of the changelog.
	// This is *required* when creating or updating a changelog.
	Body string `json:"body"`
	// Hidden toggles the visibility of the changelog.
	// API default is `true`.
	Hidden *bool `json:"hidden"`
	// Title of the changelog.
	// This is *required* when creating or updating a changelog.
	Title string `json:"title"`
	// Type of the changelog.
	Type string `json:"type,omitempty"`
}

ChangelogParams represents the parameters for creating and updating a Changelog on ReadMe.

API Reference: https://docs.readme.com/main/reference/createchangelog

type ChangelogService

type ChangelogService interface {
	// Create a new changelog in ReadMe.
	//
	// API Reference: https://docs.readme.com/main/reference/createchangelog
	Create(params ChangelogParams) (Changelog, *APIResponse, error)

	// Delete a changelog in ReadMe.
	//
	// API Reference: https://docs.readme.com/main/reference/deletechangelog
	Delete(slug string) (bool, *APIResponse, error)

	// Get a changelog from ReadMe.
	//
	// API Reference: https://docs.readme.com/main/reference/getchangelogs
	Get(slug string) (Changelog, *APIResponse, error)

	// GetAll retrieves a list of changelogs from ReadMe.
	//
	// API Reference: https://docs.readme.com/main/reference/getchangelogs
	GetAll(options ...RequestOptions) ([]Changelog, *APIResponse, error)

	// Update an existing changelog in ReadMe.
	//
	// API Reference: https://docs.readme.com/main/reference/updatechangelog
	Update(slug string, params ChangelogParams) (Changelog, *APIResponse, error)
}

ChangelogService is an interface for using the changelog endpoints of the ReadMe.com API.

API Reference: https://docs.readme.com/main/reference/getchangelogs

type Client

type Client struct {
	// APIURL is the base URL for the ReadMe API.
	APIURL string
	// HTTPClient is the initialized HTTP client.
	HTTPClient *http.Client
	// Token is the API token for authenticating with ReadMe.
	Token string

	// APIRegistry implements the ReadMe API Registry API for managing API definitions.
	APIRegistry APIRegistryService
	// APISpecification implements the ReadMe API Specification API for managing API specifications.
	APISpecification APISpecificationService
	// Apply implements the ReadMe API Apply API for retrieving and applying for positions at ReadMe.
	Apply ApplyService
	// Category implements the ReadMe Category API for managing categories.
	Category CategoryService
	// Changelog implements the ReadMe Changelog API for managing changelogs.
	Changelog ChangelogService
	// CustomPage implements the ReadMe CustomPage API for managing custom pages.
	CustomPage CustomPageService
	// Doc implements the ReadMe Docs API for managing docs.
	Doc DocService
	// Image implements the ReadMe Image API for uploading images.
	Image ImageService
	// OutboundIP implements the ReadMe OutboundIP API for retrieving outbound IP addresses.
	OutboundIP OutboundIPService
	// Project implements the ReadMe Project API for retrieving metadata about the project.
	Project ProjectService
	// Version implements the ReadMe Version API for managing versions.
	Version VersionService
}

Client sets up the API HTTP client with authentication and exposes the API interfaces.

func NewClient

func NewClient(token string, apiURL ...string) (*Client, error)

NewClient initializes the API client configuration and returns the HTTP client with an auth token and URL set.

Optionally provide a custom API URL as a second parameter.

func (*Client) APIRequest

func (c *Client) APIRequest(request *APIRequest) (*APIResponse, error)

APIRequest performs a request to the ReadMe API and handles parsing the response and API errors.

This function is called directly by the receiver functions used to implement each endpoint.

type CustomPage

type CustomPage struct {
	Algolia    DocAlgolia  `json:"algolia"`
	Body       string      `json:"body"`
	CreatedAt  string      `json:"createdAt"`
	Fullscreen bool        `json:"fullscreen"`
	HTML       string      `json:"html"`
	Hidden     bool        `json:"hidden"`
	HTMLMode   bool        `json:"htmlmode"`
	ID         string      `json:"_id"`
	Metadata   DocMetadata `json:"metadata"`
	Revision   int         `json:"revision"`
	Slug       string      `json:"slug"`
	Title      string      `json:"title"`
	UpdatedAt  string      `json:"updatedAt"`
}

CustomPage represents a custom page in ReadMe.

type CustomPageClient

type CustomPageClient struct {
	// contains filtered or unexported fields
}

CustomPageClient handles communication with the custom page related methods of the ReadMe API.

func (CustomPageClient) Create

Create a new custom page in ReadMe.

API Reference: https://docs.readme.com/main/reference/createcustompage

func (CustomPageClient) Delete

func (c CustomPageClient) Delete(slug string) (bool, *APIResponse, error)

Delete a custom page in ReadMe.

API Reference: https://docs.readme.com/reference/deletecustompages

func (CustomPageClient) Get

Get a single custom page's data from ReadMe.

API Reference: https://docs.readme.com/main/reference/getcustompage

func (CustomPageClient) GetAll

func (c CustomPageClient) GetAll(options ...RequestOptions) ([]CustomPage, *APIResponse, error)

GetAll retrieves a list of custom pages and their data from ReadMe.

Pagination options may be specified with the `options` parameter.

API Reference: https://docs.readme.com/main/reference/getcustompages

func (CustomPageClient) Update

Update an existing custom page in ReadMe.

API Reference: https://docs.readme.com/main/reference/updatecustompage

type CustomPageParams

type CustomPageParams struct {
	// Body formatted in Markdown (displayed by default).
	Body string `json:"body,omitempty"`
	// Hidden toggles the visibility of the custom page.
	// API default is `true`.
	Hidden *bool `json:"hidden"`
	// Body formatted in HTML (sanitized, only displayed if HTMLMode is true).
	HTML string `json:"html,omitempty"`
	// HTMLMode toggles if html should be displayed. Body will be displayed if false.
	// API default is `false`.
	HTMLMode *bool `json:"htmlmode"`
	// Title of the custom page.
	// This is *required* when creating or updating a custom page.
	Title string `json:"title"`
}

CustomPageParams represents the parameters to create or update a custom page in ReadMe.

type CustomPageService

type CustomPageService interface {
	// Create a new custom page in ReadMe.
	//
	// API Reference: https://docs.readme.com/main/reference/createcustompage
	Create(params CustomPageParams) (CustomPage, *APIResponse, error)

	// Delete a custom page in ReadMe.
	//
	// API Reference: https://docs.readme.com/reference/deletecustompages
	Delete(slug string) (bool, *APIResponse, error)

	// Get a single custom page's data from ReadMe.
	//
	// API Reference: https://docs.readme.com/main/reference/getcustompage
	Get(slug string) (CustomPage, *APIResponse, error)

	// GetAll retrieves a list of custom pages and their data from ReadMe.
	//
	// Pagination options may be specified with the `options` parameter.
	//
	// API Reference: https://docs.readme.com/main/reference/getcustompages
	GetAll(options ...RequestOptions) ([]CustomPage, *APIResponse, error)

	// Update an existing custom page in ReadMe.
	//
	// API Reference: https://docs.readme.com/main/reference/updatecustompage
	Update(slug string, params CustomPageParams) (CustomPage, *APIResponse, error)
}

CustomPageService is an interface for using the custom page endpoints of the ReadMe API.

type Doc

type Doc struct {
	Algolia       DocAlgolia     `json:"algolia"`
	API           DocAPI         `json:"api"`
	Body          string         `json:"body"`
	BodyHTML      string         `json:"body_html,omitempty"`
	Category      string         `json:"category"`
	CreatedAt     string         `json:"createdAt"`
	Deprecated    bool           `json:"deprecated"`
	Error         DocErrorObject `json:"error"`
	Excerpt       string         `json:"excerpt"`
	Hidden        bool           `json:"hidden"`
	ID            string         `json:"_id"`
	Icon          string         `json:"icon"`
	IsAPI         bool           `json:"isApi"`
	IsReference   bool           `json:"isReference"`
	LinkExternal  bool           `json:"link_external"`
	LinkURL       string         `json:"link_url"`
	Metadata      DocMetadata    `json:"metadata"`
	Next          DocNext        `json:"next"`
	Order         int            `json:"order"`
	ParentDoc     string         `json:"parentDoc"`
	PreviousSlug  string         `json:"previousSlug"`
	Project       string         `json:"project,omitempty"`
	Revision      int            `json:"revision"`
	Slug          string         `json:"slug"`
	SlugUpdatedAt string         `json:"slugUpdatedAt"`
	Swagger       DocSwagger     `json:"swagger"`
	SyncUnique    string         `json:"sync_unique"`
	Title         string         `json:"title"`
	Type          string         `json:"type"`
	UpdatedAt     string         `json:"updatedAt"`
	// TODO: Verify the data structure and type.
	Updates []any  `json:"updates"`
	User    string `json:"user"`
	Version string `json:"version"`
}

Doc represents a doc in ReadMe.

type DocAPI

type DocAPI struct {
	APISetting string         `json:"apiSetting"`
	Auth       string         `json:"auth"`
	Examples   DocAPIExamples `json:"examples"`
	Method     string         `json:"method"`
	Params     []DocAPIParams `json:"params"`
	Results    DocAPIResults  `json:"results"`
	URL        string         `json:"url"`
}

DocAPI represents a doc's API data in ReadMe.

type DocAPIExamples

type DocAPIExamples struct {
	Codes []DocAPIExamplesCodes `json:"codes"`
}

DocAPIExamples represents the "api:examples" object returned for a doc.

type DocAPIExamplesCodes

type DocAPIExamplesCodes struct {
	Code     string `json:"code"`
	Language string `json:"language"`
}

DocAPIExamplesCodes represents the "api:examples:codes" object returned for a doc.

type DocAPIParams

type DocAPIParams struct {
	Default    string `json:"default"`
	Desc       string `json:"desc"`
	EnumValues string `json:"enumValues"`
	ID         string `json:"_id"`
	In         string `json:"in"`
	Name       string `json:"name"`
	Ref        string `json:"ref"`
	Required   bool   `json:"required"`
	Type       string `json:"type"`
}

DocAPIParams represents the "api:params" object returned for a doc.

type DocAPIResults

type DocAPIResults struct {
	Codes []DocAPIResultsCodes `json:"codes"`
}

DocAPIResults represents the "api:results" object returned for a doc.

type DocAPIResultsCodes

type DocAPIResultsCodes struct {
	Code     string `json:"code"`
	Language string `json:"language"`
	Name     string `json:"name"`
	Status   int    `json:"status"`
}

DocAPIResultsCodes represents the "api:results:codes" object returned for a doc.

type DocAlgolia

type DocAlgolia struct {
	PublishPending bool   `json:"publishPending"`
	RecordCount    int    `json:"recordCount"`
	UpdatedAt      string `json:"updatedAt"`
}

DocAlgolia represents the corresponding 'algolia' key in the API response for a doc.

type DocClient

type DocClient struct {
	// contains filtered or unexported fields
}

DocClient handles communication with the docs related methods of the ReadMe.com API.

func (DocClient) Create

func (c DocClient) Create(params DocParams, options ...RequestOptions) (Doc, *APIResponse, error)

Create a new doc in ReadMe.

API Reference: https://docs.readme.com/main/reference/createdoc

func (DocClient) Delete

func (c DocClient) Delete(slug string, options ...RequestOptions) (bool, *APIResponse, error)

Delete a doc in ReadMe.

API Reference: https://docs.readme.com/reference/deletedoc

func (DocClient) Get

func (c DocClient) Get(doc string, options ...RequestOptions) (Doc, *APIResponse, error)

Get a doc from ReadMe.

The `doc` parameter may be a slug or doc ID prefixed with "id:". The slug is preferred, since it's a more direct request while the ID requires iterating over the search results for the matching ID.

Use the `options` parameter to set `RequestOptions.ProductionDoc` to retrieve a production doc.

API References:

func (DocClient) Search

func (c DocClient) Search(query string, options ...RequestOptions) ([]DocSearchResult, *APIResponse, error)

Search for docs that match the search query parameter.

API Reference: https://docs.readme.com/main/reference/searchdocs

func (DocClient) Update

func (c DocClient) Update(slug string, params DocParams, options ...RequestOptions) (Doc, *APIResponse, error)

Update an existing doc in ReadMe.

API Reference: https://docs.readme.com/main/reference/updatedoc

type DocErrorObject

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

DocErrorObject represents the 'error' key in a doc response.

type DocMetadata

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

DocMetadata represents a doc's metadata in ReadMe. This is used across the different types of docs - changelog, doc (aka guides) and custom pages.

type DocNext

type DocNext struct {
	Description string         `json:"description"`
	Pages       []DocNextPages `json:"pages"`
}

DocNext represents a doc's "next" doc and pages in ReadMe.

type DocNextPages

type DocNextPages struct {
	Category   string `json:"category"`
	Deprecated bool   `json:"deprecated"`
	Icon       string `json:"icon"`
	Name       string `json:"name"`
	Slug       string `json:"slug"`
	Type       string `json:"type"`
}

DocNextPages represents the "next:pages" object returned for a doc.

type DocParams

type DocParams struct {
	// Body content of the page, formatted in ReadMe or GitHub flavored Markdown. Accepts long page
	// content, for example, greater than 100k characters.
	Body string `json:"body,omitempty"`
	// Category ID of the page.
	// This is or 'CategorySlug' is *required* when creating or updating a category.
	Category string `json:"category"`
	// Category Slug of the page.
	// This is or 'Category' is *required* when creating or updating a category.
	CategorySlug string `json:"categorySlug"`
	// Error is an error code for docs with the type set to "error".
	Error DocErrorObject `json:"error,omitempty"`
	// Hidden toggles visibility for the doc.
	// API default is true.
	Hidden *bool `json:"hidden"`
	// Order sets the position of the page in the project sidebar.
	// API default is 999.
	Order *int `json:"order"`
	// ParentDoc is the ID of the parent doc for subpages.
	ParentDoc string `json:"parentDoc,omitempty"`
	// ParentDocSlug is the slug of the parent doc for subpages.
	// This field is an alternative to the ParentDoc field.
	ParentDocSlug string `json:"parentDocSlug,omitempty"`
	// Title of the page.
	// This is *required* when creating or updating a category.
	Title string `json:"title"`
	// Type of the page. The available types all show up under the /docs/ URL path of your docs
	// project (also known as the "guides" section). Can be "basic" (most common), "error" (page
	// describing an API error), or "link" (page that redirects to an external link).
	Type string `json:"type,omitempty"`
}

DocParams represents the parameters for creating a doc on ReadMe.

API Reference: https://docs.readme.com/main/reference/createdoc

type DocSearchResult

type DocSearchResult struct {
	HighlightResult DocSearchResultHighlight `json:"_highlightResult"`
	IndexName       string                   `json:"indexName"`
	InternalLink    string                   `json:"internalLink"`
	IsReference     bool                     `json:"isReference"`
	LinkURL         string                   `json:"link_url"`
	Method          string                   `json:"method"`
	ObjectID        string                   `json:"objectID"`
	Project         string                   `json:"project"`
	ReferenceID     string                   `json:"referenceId"`
	Slug            string                   `json:"slug"`
	SnippetResult   DocSearchResultSnippet   `json:"_snippetResult"`
	Subdomain       string                   `json:"subdomain"`
	Title           string                   `json:"title"`
	Type            string                   `json:"type"`
	URL             string                   `json:"url"`
	Version         string                   `json:"version"`
}

DocSearchResult represents a single item in the list of search results.

type DocSearchResultHighlight

type DocSearchResultHighlight struct {
	Title   DocSearchResultHighlightValue `json:"title"`
	Excerpt DocSearchResultHighlightValue `json:"excerpt"`
	Body    DocSearchResultHighlightValue `json:"body"`
}

DocSearchResultHighlight represents the HighlightResult key in a search result item.

type DocSearchResultHighlightValue

type DocSearchResultHighlightValue struct {
	Value        string   `json:"value"`
	MatchLevel   string   `json:"matchLevel"`
	MatchedWords []string `json:"matchedWords"`
}

DocSearchResultHighlightValue represents the HighlightResult child keys in a search result item.

type DocSearchResultSnippet

type DocSearchResultSnippet struct {
	Title   DocSearchResultSnippetValue `json:"title"`
	Excerpt DocSearchResultSnippetValue `json:"excerpt"`
	Body    DocSearchResultSnippetValue `json:"body"`
}

DocSearchResultSnippet represents the SnippetResult key in a search result item.

type DocSearchResultSnippetValue

type DocSearchResultSnippetValue struct {
	Value      string `json:"value"`
	MatchLevel string `json:"matchLevel"`
}

DocSearchResultSnippetValue represents the SnippetResult child keys in a search result item.

type DocSearchResults

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

DocSearchResults represents the response from searching.

type DocService

type DocService interface {
	// Create a new doc in ReadMe.
	//
	// API Reference: https://docs.readme.com/main/reference/createdoc
	Create(params DocParams, options ...RequestOptions) (Doc, *APIResponse, error)

	// Delete a doc in ReadMe.
	//
	// API Reference: https://docs.readme.com/reference/deletedoc
	Delete(slug string, options ...RequestOptions) (bool, *APIResponse, error)

	// Get a doc from ReadMe.
	//
	// The `doc` parameter may be a slug or doc ID prefixed with "id:".
	// The slug is preferred, since it's a more direct request while the ID requires
	// iterating over the search results for the matching ID.
	//
	// Use the `options` parameter to set `RequestOptions.ProductionDoc` to retrieve a production doc.
	//
	// API References:
	//   - https://docs.readme.com/main/reference/getdoc
	//   - https://docs.readme.com/main/reference/getproductiondoc
	Get(doc string, options ...RequestOptions) (Doc, *APIResponse, error)

	// Search for docs that match the search query parameter.
	//
	// API Reference: https://docs.readme.com/main/reference/searchdocs
	Search(query string, options ...RequestOptions) ([]DocSearchResult, *APIResponse, error)

	// Update an existing doc in ReadMe.
	//
	// API Reference: https://docs.readme.com/main/reference/updatedoc
	Update(slug string, params DocParams, options ...RequestOptions) (Doc, *APIResponse, error)
}

DocService is an interface for using the docs endpoints of the ReadMe.com API.

API Reference: https://docs.readme.com/main/reference/getdoc

type DocSwagger

type DocSwagger struct {
	Path string `json:"path"`
}

DocSwagger represents the optional "swagger" object returned for a doc.

type DocUser

type DocUser struct {
	ID string `json:"_id"`
}

DocUser represents the corresponding key in the API response for a user object on ReadMe. The 'User' field is returned as a string on 'doc' objects, but is returned as an object on 'changelog' objects.

type Image added in v0.1.2

type Image struct {
	URL      string
	Filename string
	Width    int64
	Height   int64
	Color    string
}

Image represents an image uploaded to ReadMe.

type ImageClient added in v0.1.2

type ImageClient struct {
	// contains filtered or unexported fields
}

ImageClient handles uploading images to ReadMe.com.

func (ImageClient) Upload added in v0.1.2

func (c ImageClient) Upload(source []byte, filename ...string) (Image, *APIResponse, error)

Upload an image to ReadMe.

type ImageService added in v0.1.2

type ImageService interface {
	// Upload an image to ReadMe.
	Upload(source []byte, filename ...string) (Image, *APIResponse, error)
}

ImagesService is an interface for using the docs endpoints of the ReadMe.com API.

API Reference: https://docs.readme.com/main/reference/getdoc

type OpenRole

type OpenRole struct {
	Department  string `json:"department"`
	Description string `json:"description"`
	Location    string `json:"location"`
	Pullquote   string `json:"pullquote"`
	Slug        string `json:"slug"`
	Title       string `json:"title"`
	URL         string `json:"url"`
}

OpenRole represents an open role at ReadMe.

type OutboundIP added in v0.2.0

type OutboundIP struct {
	IPAddress string `json:"ipAddress"`
}

OutboundIP represents the response from the ReadMe API when returning outbound IP addresses.

type OutboundIPClient added in v0.2.0

type OutboundIPClient struct {
	// contains filtered or unexported fields
}

OutboundIPClient handles communication with the OutboundIP related methods of the ReadMe.com API.

func (OutboundIPClient) Get added in v0.2.0

Get all of ReadMe’s IP addresses used for outbound webhook requests and the “Try It!” button on the API Explorer.

API Reference: https://docs.readme.com/main/reference/getoutboundips

type OutboundIPService added in v0.2.0

type OutboundIPService interface {
	// Get all of ReadMe’s IP addresses used for outbound webhook requests and the “Try It!” button on the API Explorer.
	//
	// Although ReadMe’s outbound IP addresses may change, the IPs in this API
	// response will be valid for at least 7 days. If you configure your API or
	// webhooks to limit access based on these IPs, you should refresh the IP list
	// from this endpoint weekly.
	//
	// API Reference: https://docs.readme.com/main/reference/getoutboundips
	Get() ([]OutboundIP, *APIResponse, error)
}

OutboundIPService is an interface for using the outbound IPs endpoint of the ReadMe.com API.

API Reference: https://docs.readme.com/main/reference/getoutboundips

type Project

type Project struct {
	// BaseURL is the base URL for the project. If the project is not running under a custom domain,
	// it will be https://projectSubdomain.readme.io, otherwise it can either be https://example.com
	// or, in the case of an enterprise child project https://example.com/projectSubdomain.
	BaseURL string `json:"baseUrl"`
	// JWTSecret is the JSON Web Token used for the project.
	JWTSecret string `json:"jwtSecret"`
	// Name of the project.
	Name string `json:"name"`
	// Plan is the subscription plan of the project on ReadMe.
	Plan string `json:"plan"`
	// SubDomain for the project on ReadMe.com.
	SubDomain string `json:"subdomain"`
}

Project represents the response from the ReadMe API when returning project metadata.

type ProjectClient

type ProjectClient struct {
	// contains filtered or unexported fields
}

ProjectClient handles communication with the Project related methods of the ReadMe.com API.

func (ProjectClient) Get

func (c ProjectClient) Get() (Project, *APIResponse, error)

Get retrieves project metadata from the ReadMe.com API.

API Reference: https://docs.readme.com/main/reference/getproject

type ProjectService

type ProjectService interface {
	// Get retrieves project metadata from the ReadMe.com API.
	//
	// API Reference: https://docs.readme.com/main/reference/getproject
	Get() (Project, *APIResponse, error)
}

ProjectService is an interface for using the projects endpoints of the ReadMe.com API.

API Reference: https://docs.readme.com/main/reference/getproject

type RequestHeader

type RequestHeader map[string]string

RequestHeader represents an HTTP header set on requests.

type RequestOptions

type RequestOptions struct {
	// Headers is a list of additional headers to add to the request.
	Headers []RequestHeader
	// PerPage is the number of items to return in each request when using pagination.
	// The maximum and default is 100.
	PerPage int
	// Page is the page number to request when using pagination.
	Page int
	// ProductionDoc is used by readme.Docs.Get() to indicate whether the requested document is a
	// 'production' doc.
	ProductionDoc bool
	// Version number of a ReadMe project, for example, v3.0. By default the main project version is used.
	Version string
}

RequestOptions is used for specifying options for requests, such as pagination options.

type Version

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

Version represents the details of a specific version.

type VersionClient

type VersionClient struct {
	// contains filtered or unexported fields
}

VersionClient handles communication with the Project related methods of the ReadMe.com API.

func (VersionClient) Create

func (c VersionClient) Create(params VersionParams) (Version, *APIResponse, error)

Create a new version within a project.

API Reference: https://docs.readme.com/main/reference/createversion

func (VersionClient) Delete

func (c VersionClient) Delete(version string) (bool, *APIResponse, error)

Delete a version.

The version may be provided using either the semver identifier for the project version ('1.0.0') or an API ID for the version prefixed with 'id' ('id:63ac899d11c4680047ec5970').

When using the semantic version identifier, use the formatted VersionClean value listed in the response from the GetAll() function for best results.

API Reference: https://docs.readme.com/main/reference/deleteversion

func (VersionClient) Get

func (c VersionClient) Get(version string) (Version, *APIResponse, error)

Get a single version.

The version may be provided using either the semver identifier for the project version ('1.0.0') or an API ID for the version prefixed with 'id' ('id:63ac899d11c4680047ec5970').

When using the semantic version identifier, use the formatted VersionClean value listed in the response from the GetAll() function for best results.

API Reference: https://docs.readme.com/main/reference/getversion

func (VersionClient) GetAll

func (c VersionClient) GetAll() ([]VersionSummary, *APIResponse, error)

GetAll retrieves a list of versions associated with an API key.

API Reference: https://docs.readme.com/main/reference/getversions

func (VersionClient) GetVersion added in v0.2.0

func (c VersionClient) GetVersion(version string) (string, error)

GetVersion parses a provided string to determine if it it's a semantic version identifier (1.0.0) or an API version identifier (id:63ac899d11c4680047ec5970). If it's an API version identifier, the value is compared with the results from GetAll() to return the semantic version that's used for API requests. If the specified version is already a semantic version string, it will be returned as-is.

func (VersionClient) Update

func (c VersionClient) Update(version string, params VersionParams) (Version, *APIResponse, error)

Update an existing version.

The version may be provided using either the semver identifier for the project version ('1.0.0') or an API ID for the version prefixed with 'id' ('id:63ac899d11c4680047ec5970').

When using the semantic version identifier, use the formatted VersionClean value listed in the response from the GetAll() function for best results.

API Reference: https://docs.readme.com/main/reference/updateversion

type VersionParams

type VersionParams struct {
	// Codename is the dubbed name of version.
	Codename string `json:"codename,omitempty"`
	// From is the semantic Version to use as the base fork.
	// This is *required* when creating or updating a version.
	From string `json:"from"`
	// IsBeta toggles whether the version is a beta release.
	// API default is `false`.
	IsBeta *bool `json:"is_beta"`
	// IsDeprecated toggles whether the version is deprecated. Only allowed when updating.
	// API default is `false`.
	IsDeprecated *bool `json:"is_deprecated"`
	// IsHidden toggles public accessibility.
	// API default is `false`.
	IsHidden *bool `json:"is_hidden"`
	// IsStable toggles whether the version should be the project's main version.
	// API default is `false`.
	IsStable *bool `json:"is_stable"`
	// Version is the number.
	// This is *required* when creating or updating a version.
	Version string `json:"version"`
}

VersionParams represents the request parameters used when creating or updating a version.

type VersionService

type VersionService interface {
	// Create a new version within a project.
	//
	// API Reference: https://docs.readme.com/main/reference/createversion
	Create(prams VersionParams) (Version, *APIResponse, error)

	// Delete a version.
	//
	// The version may be provided using either the semver identifier for the project version
	// ('1.0.0') or an API ID for the version prefixed with 'id' ('id:63ac899d11c4680047ec5970').
	//
	// When using the semantic version identifier, use the formatted VersionClean value listed in
	// the response from the GetAll() function for best results.
	//
	// API Reference: https://docs.readme.com/main/reference/deleteversion
	Delete(version string) (bool, *APIResponse, error)

	// Get a single version.
	//
	// The version may be provided using either the semver identifier for the project version
	// ('1.0.0') or an API ID for the version prefixed with 'id' ('id:63ac899d11c4680047ec5970').
	//
	// When using the semantic version identifier, use the formatted VersionClean value listed in
	// the response from the GetAll() function for best results.
	//
	// API Reference: https://docs.readme.com/main/reference/getversion
	Get(version string) (Version, *APIResponse, error)

	// GetAll retrieves a list of versions associated with an API key.
	//
	// API Reference: https://docs.readme.com/main/reference/getversions
	GetAll() ([]VersionSummary, *APIResponse, error)

	// Update an existing version.
	//
	// The version may be provided using either the semver identifier for the project version
	// ('1.0.0') or an API ID for the version prefixed with 'id' ('id:63ac899d11c4680047ec5970').
	//
	// When using the semantic version identifier, use the formatted VersionClean value listed in
	// the response from the GetAll() function for best results.
	//
	// API Reference: https://docs.readme.com/main/reference/updateversion
	Update(version string, params VersionParams) (Version, *APIResponse, error)

	// GetVersion parses a provided string to determine if it it's a semantic version identifier (1.0.0)
	// or an API version identifier (id:63ac899d11c4680047ec5970). If it's an API version identifier,
	// the value is compared with the results from GetAll() to return the semantic version that's used
	// for API requests. If the specified version is already a semantic version string, it will be
	// returned as-is.
	GetVersion(version string) (string, error)
}

VersionService is an interface for using the version endpoints of the ReadMe.com API.

See: https://docs.readme.com/main/reference/getproject

type VersionSummary

type VersionSummary struct {
	Codename     string `json:"codename"`
	CreatedAt    string `json:"createdAt"`
	ForkedFrom   string `json:"forked_from"`
	ID           string `json:"_id"`
	IsBeta       bool   `json:"is_beta"`
	IsDeprecated bool   `json:"is_deprecated"`
	IsHidden     bool   `json:"is_hidden"`
	IsStable     bool   `json:"is_stable"`
	Version      string `json:"version"`
	VersionClean string `json:"version_clean"`
}

VersionSummary represents the response from the ReadMe API when retrieving a list of versions with GetAll().

Jump to

Keyboard shortcuts

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