lego/vendor/github.com/sacloud/libsacloud/api/newsfeed.go
Ludovic Fernandez 42941ccea6
Refactor the core of the lib (#700)
- Packages
- Isolate code used by the CLI into the package `cmd`
- (experimental) Add e2e tests for HTTP01, TLS-ALPN-01 and DNS-01, use [Pebble](https://github.com/letsencrypt/pebble) and [challtestsrv](https://github.com/letsencrypt/boulder/tree/master/test/challtestsrv) 
- Support non-ascii domain name (punnycode)
- Check all challenges in a predictable order
- No more global exported variables
- Archive revoked certificates
- Fixes revocation for subdomains and non-ascii domains
- Disable pending authorizations
- use pointer for RemoteError/ProblemDetails
- Poll authz URL instead of challenge URL
- The ability for a DNS provider to solve the challenge sequentially
- Check all nameservers in a predictable order
- Option to disable the complete propagation Requirement
- CLI, support for renew with CSR
- CLI, add SAN on renew
- Add command to list certificates.
- Logs every iteration of waiting for the propagation
- update DNSimple client
- update github.com/miekg/dns
2018-12-06 22:50:17 +01:00

51 lines
1.1 KiB
Go

package api
import (
"encoding/json"
"github.com/sacloud/libsacloud/sacloud"
)
// NewsFeedAPI フィード(障害/メンテナンス情報)API
type NewsFeedAPI struct {
client *Client
}
// NewsFeedURL フィード取得URL
var NewsFeedURL = "https://secure.sakura.ad.jp/rss/sakuranews/getfeeds.php?service=cloud&format=json"
// NewNewsFeedAPI フィード(障害/メンテナンス情報)API
func NewNewsFeedAPI(client *Client) *NewsFeedAPI {
return &NewsFeedAPI{
client: client,
}
}
// GetFeed フィード全件取得
func (api *NewsFeedAPI) GetFeed() ([]sacloud.NewsFeed, error) {
var res = []sacloud.NewsFeed{}
data, err := api.client.newRequest("GET", NewsFeedURL, nil)
if err != nil {
return res, err
}
if err := json.Unmarshal(data, &res); err != nil {
return nil, err
}
return res, nil
}
// GetFeedByURL 指定のURLを持つフィードを取得
func (api *NewsFeedAPI) GetFeedByURL(url string) (*sacloud.NewsFeed, error) {
res, err := api.GetFeed()
if err != nil {
return nil, err
}
for _, r := range res {
if r.URL == url {
return &r, nil
}
}
return nil, nil
}