plugeth/vendor/github.com/cloudflare/cloudflare-go/access_organization.go
Felix Lange 0568e81701
p2p/dnsdisc: add implementation of EIP-1459 (#20094)
This adds an implementation of node discovery via DNS TXT records to the
go-ethereum library. The implementation doesn't match EIP-1459 exactly,
the main difference being that this implementation uses separate merkle
trees for tree links and ENRs. The EIP will be updated to match p2p/dnsdisc.

To maintain DNS trees, cmd/devp2p provides a frontend for the p2p/dnsdisc
library. The new 'dns' subcommands can be used to create, sign and deploy DNS
discovery trees.
2019-09-25 11:38:13 +02:00

102 lines
3.6 KiB
Go

package cloudflare
import (
"encoding/json"
"time"
"github.com/pkg/errors"
)
// AccessOrganization represents an Access organization.
type AccessOrganization struct {
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
Name string `json:"name"`
AuthDomain string `json:"auth_domain"`
LoginDesign AccessOrganizationLoginDesign `json:"login_design"`
}
// AccessOrganizationLoginDesign represents the login design options.
type AccessOrganizationLoginDesign struct {
BackgroundColor string `json:"background_color"`
TextColor string `json:"text_color"`
LogoPath string `json:"logo_path"`
}
// AccessOrganizationListResponse represents the response from the list
// access organization endpoint.
type AccessOrganizationListResponse struct {
Result AccessOrganization `json:"result"`
Response
ResultInfo `json:"result_info"`
}
// AccessOrganizationDetailResponse is the API response, containing a
// single access organization.
type AccessOrganizationDetailResponse struct {
Success bool `json:"success"`
Errors []string `json:"errors"`
Messages []string `json:"messages"`
Result AccessOrganization `json:"result"`
}
// AccessOrganization returns the Access organisation details.
//
// API reference: https://api.cloudflare.com/#access-organizations-access-organization-details
func (api *API) AccessOrganization(accountID string) (AccessOrganization, ResultInfo, error) {
uri := "/accounts/" + accountID + "/access/organizations"
res, err := api.makeRequest("GET", uri, nil)
if err != nil {
return AccessOrganization{}, ResultInfo{}, errors.Wrap(err, errMakeRequestError)
}
var accessOrganizationListResponse AccessOrganizationListResponse
err = json.Unmarshal(res, &accessOrganizationListResponse)
if err != nil {
return AccessOrganization{}, ResultInfo{}, errors.Wrap(err, errUnmarshalError)
}
return accessOrganizationListResponse.Result, accessOrganizationListResponse.ResultInfo, nil
}
// CreateAccessOrganization creates the Access organisation details.
//
// API reference: https://api.cloudflare.com/#access-organizations-create-access-organization
func (api *API) CreateAccessOrganization(accountID string, accessOrganization AccessOrganization) (AccessOrganization, error) {
uri := "/accounts/" + accountID + "/access/organizations"
res, err := api.makeRequest("POST", uri, accessOrganization)
if err != nil {
return AccessOrganization{}, errors.Wrap(err, errMakeRequestError)
}
var accessOrganizationDetailResponse AccessOrganizationDetailResponse
err = json.Unmarshal(res, &accessOrganizationDetailResponse)
if err != nil {
return AccessOrganization{}, errors.Wrap(err, errUnmarshalError)
}
return accessOrganizationDetailResponse.Result, nil
}
// UpdateAccessOrganization creates the Access organisation details.
//
// API reference: https://api.cloudflare.com/#access-organizations-update-access-organization
func (api *API) UpdateAccessOrganization(accountID string, accessOrganization AccessOrganization) (AccessOrganization, error) {
uri := "/accounts/" + accountID + "/access/organizations"
res, err := api.makeRequest("PUT", uri, accessOrganization)
if err != nil {
return AccessOrganization{}, errors.Wrap(err, errMakeRequestError)
}
var accessOrganizationDetailResponse AccessOrganizationDetailResponse
err = json.Unmarshal(res, &accessOrganizationDetailResponse)
if err != nil {
return AccessOrganization{}, errors.Wrap(err, errUnmarshalError)
}
return accessOrganizationDetailResponse.Result, nil
}