Documentation ¶
Overview ¶
Package client contains generic client structs and methods that are designed to be used by specific PHPIPAM services and resources.
Index ¶
- func SetLevel(level log.Level)
- type Client
- func (c *Client) GetCustomFields(id int, controller string) (out map[string]interface{}, err error)
- func (c *Client) GetCustomFieldsSchema(controller string) (out map[string]phpipam.CustomField, err error)
- func (c *Client) SendRequest(method, uri string, in, out interface{}) error
- func (c *Client) UpdateCustomFields(id int, in map[string]interface{}, controller string) (message string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
Client encompasses a generic client object that is further extended by services. Any common configuration and functionality goes here.
func (*Client) GetCustomFields ¶
GetCustomFields GETs the custom fields for a resource, and returns them as a map[string]interface{}. A call out to GetCustomFields is performed first, and then a GET is performed on the subnet resource with only the custom fields returned.
Note that due to how PHPIPAM stringifies most output, this will, in most cases, mean that attribute values will be strings and will need to be convereted externally. This function does not explicitly lock to map[string]string to allow for possible cases where this is not the case, and to also allow for future de-stringification of the JSON.
This function is called out to in a controller to implement this functionality in a specific pacakge.
func (*Client) GetCustomFieldsSchema ¶
func (c *Client) GetCustomFieldsSchema(controller string) (out map[string]phpipam.CustomField, err error)
GetCustomFieldsSchema GETs the custom fields for the supplied controller name and returns them as a map[string]phpipam.CustomField.
This function is called out to in a controller to implement this functionality in a specific pacakge.
func (*Client) SendRequest ¶
SendRequest sends a request to a request.Request object. It's expected that references to specific data types are passed - no checking is done to make sure that references are passed.
This function also wraps session management into the workflow, logging in and refreshing session tokens as needed.
func (*Client) UpdateCustomFields ¶
func (c *Client) UpdateCustomFields(id int, in map[string]interface{}, controller string) (message string, err error)
UpdateCustomFields uses PATCH on a resource controller to update a specific resoruce ID with the custom fields provided in the key/value map defined by in.
Internal validation is preformed first to ensure that this field is not setting a custom field that is *not* defined in the schema. This is to prevent abuse - if this was not in place, this function could technically be used to update *any* field, as PHPIPAM does not maintain a separate subtype for custom fields.
This function is called out to in a controller to implement this functionality in a specific pacakge.