Giter Site home page Giter Site logo

goprsc's Introduction

Goprsc

Goprsc is a GO client library for accessing the Postfix Rest Server V1 API.

Goprsc currently implements all Postfix Rest Server APIs (domains, accounts, aliases, automatic sender and recipient BCC).

Usage

import "github.com/lyubenblagoev/goprsc"

Create a new client and use the exposed services to access different parts of the Postfix Rest Server API.

Use the DefaultClient:

client := goprsc.DefaultClient

Create a new Client using NewClient(*http.Client):

var httpClient *http.Client

...

client := goprsc.NewClient(httpClient)

Create a new client using NewClientWithOptions(*http.Client, ...ClientOption):

client := goprsc.NewClientWithOptions(nil, HTTPSProtocolOption())

Client options allow changing the default protocol, host, port and user agent string using HTTPSProtocolOption(), HostOption(), PortOption() and UserAgentOption() functions. These functions return a ClientOption which changes the corresponding option in the client.

Examples

To create a new domain:

client := goprsc.DefaultClient

domainName := "example.com"

if err := client.Domains.Create(domainName); err != nil {
    fmt.Printf("Unable to create domain %s\n\n", domainName)
    return err
}

To get a list of all accounts in a domain:

client := goprsc.DefaultClient

domainName := "example.com"

accounts, err := client.Accounts.List(domainName)
if err != nil {
    fmt.Printf("Unable to list accounts for domain %s\n\n", domainName)
    return err
}

Similarly you can manage other entities.

For more usage examples, you may wish to take a look at emailctl (a CLI for the Postfix Rest Server).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.