mirror of
https://github.com/go-acme/lego.git
synced 2024-12-23 09:15:11 +02:00
e7a90b9471
- chore: update dependencies: use version with go modules. - chore: remove dep. - chore: update backoff imports. - chore: init go module. - chore: update CI. - chore: mod v3 - chore: update docker image.
35 lines
826 B
Go
35 lines
826 B
Go
package api
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/go-acme/lego/v3/acme"
|
|
)
|
|
|
|
type AuthorizationService service
|
|
|
|
// Get Gets an authorization.
|
|
func (c *AuthorizationService) Get(authzURL string) (acme.Authorization, error) {
|
|
if len(authzURL) == 0 {
|
|
return acme.Authorization{}, errors.New("authorization[get]: empty URL")
|
|
}
|
|
|
|
var authz acme.Authorization
|
|
_, err := c.core.postAsGet(authzURL, &authz)
|
|
if err != nil {
|
|
return acme.Authorization{}, err
|
|
}
|
|
return authz, nil
|
|
}
|
|
|
|
// Deactivate Deactivates an authorization.
|
|
func (c *AuthorizationService) Deactivate(authzURL string) error {
|
|
if len(authzURL) == 0 {
|
|
return errors.New("authorization[deactivate]: empty URL")
|
|
}
|
|
|
|
var disabledAuth acme.Authorization
|
|
_, err := c.core.post(authzURL, acme.Authorization{Status: acme.StatusDeactivated}, &disabledAuth)
|
|
return err
|
|
}
|