Documentation ¶
Index ¶
- func CheckResponse(r *http.Response) error
- type Client
- func (c *Client) AddGroupMember(group string, user string) error
- func (c *Client) BaseURL() *url.URL
- func (c *Client) DeleteGroup(name string) error
- func (c *Client) DeleteUser(name string) error
- func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)
- func (c *Client) GetGroup(name string) (*Group, error)
- func (c *Client) GetUser(name string) (*User, error)
- func (c *Client) GetUserByEmail(email string) (*User, error)
- func (c *Client) GetUserGroups(name string) ([]string, error)
- func (c *Client) GetUsersByEmail(email string) ([]User, error)
- func (c *Client) ListGroups() ([]string, error)
- func (c *Client) ListUsers(prefix string) ([]string, error)
- func (c *Client) LockUser(name string) error
- func (c *Client) NewGroup(name string) error
- func (c *Client) NewRequest(method, path string, opt interface{}, body interface{}) (*http.Request, error)
- func (c *Client) RemoveGroupMember(group string, user string) error
- func (c *Client) SetGroupEmail(group string, email string) error
- func (c *Client) SetUserPassword(name string, password string) error
- func (c *Client) UpdateGroup(g *Group) error
- type ClientOptionFunc
- type ErrorResponse
- type Group
- type ProjectRef
- type SearchOptions
- type User
- type UserOptions
- type UserRef
- type XPathPredicate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present.
Types ¶
type Client ¶
type Client struct { // User agent used when communicating with the OBS API. UserAgent string // Don’t verify server’s TLS certificates InsecureSkipVerify bool // contains filtered or unexported fields }
func NewClient ¶
func NewClient(username, password string, options ...ClientOptionFunc) (*Client, error)
NewAPI returns a new OBS API client. To use API methods which require authentication, provide a valid username and password.
func (*Client) AddGroupMember ¶
AddGroupMember adds a user to a group.
func (*Client) DeleteGroup ¶
DeleteGroup deletes a group of users. On some OBS versions the group must be empty before it can be deleted.
func (*Client) DeleteUser ¶
DeleteUser marks the user as deleted and deletes their projects.
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is XML-decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.
func (*Client) GetUserByEmail ¶
GetUserByEmail returns the details of the only user matching given email address If more than one user with given email address exist, an error is returned.
func (*Client) GetUserGroups ¶
GetUserGroups retrieves a list of groups the user is a member of.
func (*Client) GetUsersByEmail ¶
GetUsersByEmail returns the details of the users matching given email address.
func (*Client) ListGroups ¶
ListGroups gets a list of names of all groups. Use GetGroup to retrieve the details of each group.
func (*Client) ListUsers ¶
ListUsers gets a list of names of all users. Use GetUser to retrieve the details of each user.
func (*Client) NewRequest ¶
func (c *Client) NewRequest(method, path string, opt interface{}, body interface{}) (*http.Request, error)
NewRequest creates an API request. A relative URL path can be provided in path, in which case it is resolved relative to the base URL of the Client. If specified, the value pointed to by body is XML-encoded and included as the request body.
func (*Client) RemoveGroupMember ¶
RemoveGroupMember removes a user from a group.
func (*Client) SetGroupEmail ¶
SetGroupEmail sets the email address of a group.
func (*Client) SetUserPassword ¶
SetUserPassword sets the password of the user.
func (*Client) UpdateGroup ¶
UpdateGroup updates an existing group. The user calling this must have necessary access rights to be able to perform this call.
type ClientOptionFunc ¶
func WithBaseURL ¶
func WithBaseURL(urlStr string) ClientOptionFunc
WithBaseURL sets the base URL for API requests to a custom endpoint.
type ErrorResponse ¶
type ErrorResponse struct { Body []byte `xml:"-"` Response *http.Response `xml:"-"` Message string `xml:"summary"` Code string `xml:"code,attr"` XMLName xml.Name `xml:"status"` }
An ErrorResponse reports one or more errors caused by an API request.
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
type Group ¶
type Group struct { XMLName xml.Name `xml:"group" json:"-"` ID string `xml:"title" json:"name"` Email string `xml:"email,omitempty" json:"email,omitempty"` Maintainer UserRef `xml:"maintainer" json:"maintainer"` Members []UserRef `xml:"person>person" json:"members"` }
Group represents a named group of users.
type ProjectRef ¶
type ProjectRef struct {
Name string `xml:"name,attr" json:"name"`
}
ProjectRef represents a project referred by its name. This is used e.g. to represent a project in a watchlist.
type SearchOptions ¶
type SearchOptions struct {
Match string `url:"match,omitempty"`
}
type User ¶
type User struct { XMLName xml.Name `xml:"person" json:"-"` ID string `xml:"login" json:"username"` Email string `xml:"email" json:"email"` Realname string `xml:"realname" json:"realname"` State string `xml:"state" json:"state"` Owner *UserRef `xml:"owner,omitempty" json:"owner,omitempty"` Roles []string `xml:"globalrole,omitempty" json:"globalrole,omitempty"` Watchlist []ProjectRef `xml:"watchlist>project" json:"watchlist,omitempty"` }
User represents a user (a person in OBS terminology).
type UserOptions ¶
type UserRef ¶
type UserRef struct {
ID string `xml:"userid,attr" json:"username"`
}
UserRef represents a user referred by their username. This is used e.g. to represent members of a group.
func (UserRef) MarshalJSON ¶
func (UserRef) MarshalXML ¶
type XPathPredicate ¶
type XPathPredicate struct {
// contains filtered or unexported fields
}
func XPathAttrEquals ¶
func XPathAttrEquals(name string, value string) *XPathPredicate
func (*XPathPredicate) String ¶
func (p *XPathPredicate) String() string