Documentation ¶
Index ¶
- Constants
- type BMCBoot
- type BMCPower
- type Client
- func (c *Client) CreateArchitecture(a *ForemanArchitecture) (*ForemanArchitecture, error)
- func (c *Client) CreateDomain(d *ForemanDomain) (*ForemanDomain, error)
- func (c *Client) CreateEnvironment(e *ForemanEnvironment) (*ForemanEnvironment, error)
- func (c *Client) CreateHost(h *ForemanHost, retryCount int) (*ForemanHost, error)
- func (c *Client) CreateHostgroup(h *ForemanHostgroup) (*ForemanHostgroup, error)
- func (c *Client) CreateMedia(m *ForemanMedia) (*ForemanMedia, error)
- func (c *Client) CreateModel(m *ForemanModel) (*ForemanModel, error)
- func (c *Client) CreateOperatingSystem(o *ForemanOperatingSystem) (*ForemanOperatingSystem, error)
- func (c *Client) CreatePartitionTable(t *ForemanPartitionTable) (*ForemanPartitionTable, error)
- func (c *Client) CreateProvisioningTemplate(t *ForemanProvisioningTemplate) (*ForemanProvisioningTemplate, error)
- func (c *Client) CreateSmartProxy(s *ForemanSmartProxy) (*ForemanSmartProxy, error)
- func (c *Client) CreateSubnet(s *ForemanSubnet) (*ForemanSubnet, error)
- func (c *Client) DeleteArchitecture(id int) error
- func (c *Client) DeleteDomain(id int) error
- func (c *Client) DeleteEnvironment(id int) error
- func (c *Client) DeleteHost(id int) error
- func (c *Client) DeleteHostgroup(id int) error
- func (c *Client) DeleteMedia(id int) error
- func (c *Client) DeleteModel(id int) error
- func (c *Client) DeleteOperatingSystem(id int) error
- func (c *Client) DeletePartitionTable(id int) error
- func (c *Client) DeleteProvisioningTemplate(id int) error
- func (c *Client) DeleteSmartProxy(id int) error
- func (c *Client) DeleteSubnet(id int) error
- func (client *Client) NewRequest(method string, endpoint string, body io.Reader) (*http.Request, error)
- func (c *Client) QueryArchitecture(a *ForemanArchitecture) (QueryResponse, error)
- func (c *Client) QueryDomain(d *ForemanDomain) (QueryResponse, error)
- func (c *Client) QueryEnvironment(e *ForemanEnvironment) (QueryResponse, error)
- func (c *Client) QueryHostgroup(h *ForemanHostgroup) (QueryResponse, error)
- func (c *Client) QueryMedia(m *ForemanMedia) (QueryResponse, error)
- func (c *Client) QueryModel(m *ForemanModel) (QueryResponse, error)
- func (c *Client) QueryOperatingSystem(o *ForemanOperatingSystem) (QueryResponse, error)
- func (c *Client) QueryPartitionTable(t *ForemanPartitionTable) (QueryResponse, error)
- func (c *Client) QueryProvisioningTemplate(t *ForemanProvisioningTemplate) (QueryResponse, error)
- func (c *Client) QuerySmartProxy(s *ForemanSmartProxy) (QueryResponse, error)
- func (c *Client) QuerySubnet(s *ForemanSubnet) (QueryResponse, error)
- func (c *Client) QueryTemplateKind(t *ForemanTemplateKind) (QueryResponse, error)
- func (c *Client) ReadArchitecture(id int) (*ForemanArchitecture, error)
- func (c *Client) ReadDomain(id int) (*ForemanDomain, error)
- func (c *Client) ReadEnvironment(id int) (*ForemanEnvironment, error)
- func (c *Client) ReadHost(id int) (*ForemanHost, error)
- func (c *Client) ReadHostgroup(id int) (*ForemanHostgroup, error)
- func (c *Client) ReadMedia(id int) (*ForemanMedia, error)
- func (c *Client) ReadModel(id int) (*ForemanModel, error)
- func (c *Client) ReadOperatingSystem(id int) (*ForemanOperatingSystem, error)
- func (c *Client) ReadPartitionTable(id int) (*ForemanPartitionTable, error)
- func (c *Client) ReadProvisioningTemplate(id int) (*ForemanProvisioningTemplate, error)
- func (c *Client) ReadSmartProxy(id int) (*ForemanSmartProxy, error)
- func (c *Client) ReadSubnet(id int) (*ForemanSubnet, error)
- func (c *Client) ReadTemplateKind(id int) (*ForemanTemplateKind, error)
- func (client *Client) Send(request *http.Request) (int, []byte, error)
- func (client *Client) SendAndParse(req *http.Request, obj interface{}) error
- func (c *Client) SendBMCCommand(h *ForemanHost, cmd interface{}, retryCount int) error
- func (c *Client) UpdateArchitecture(a *ForemanArchitecture) (*ForemanArchitecture, error)
- func (c *Client) UpdateDomain(d *ForemanDomain) (*ForemanDomain, error)
- func (c *Client) UpdateEnvironment(e *ForemanEnvironment) (*ForemanEnvironment, error)
- func (c *Client) UpdateHost(h *ForemanHost, retryCount int) (*ForemanHost, error)
- func (c *Client) UpdateHostgroup(h *ForemanHostgroup) (*ForemanHostgroup, error)
- func (c *Client) UpdateMedia(m *ForemanMedia) (*ForemanMedia, error)
- func (c *Client) UpdateModel(m *ForemanModel) (*ForemanModel, error)
- func (c *Client) UpdateOperatingSystem(o *ForemanOperatingSystem) (*ForemanOperatingSystem, error)
- func (c *Client) UpdatePartitionTable(t *ForemanPartitionTable) (*ForemanPartitionTable, error)
- func (c *Client) UpdateProvisioningTemplate(t *ForemanProvisioningTemplate) (*ForemanProvisioningTemplate, error)
- func (c *Client) UpdateSmartProxy(s *ForemanSmartProxy) (*ForemanSmartProxy, error)
- func (c *Client) UpdateSubnet(s *ForemanSubnet) (*ForemanSubnet, error)
- type ClientConfig
- type ClientCredentials
- type ForemanArchitecture
- type ForemanDomain
- type ForemanEnvironment
- type ForemanHost
- type ForemanHostgroup
- type ForemanInterfacesAttribute
- type ForemanMedia
- type ForemanModel
- type ForemanObject
- type ForemanOperatingSystem
- type ForemanPartitionTable
- type ForemanProvisioningTemplate
- type ForemanSmartProxy
- type ForemanSubnet
- type ForemanTemplateCombinationAttribute
- type ForemanTemplateKind
- type QueryResponse
- type QueryResponseSort
- type Server
Constants ¶
const ( // Every Foreman API call has the following prefix to the path component // of the URL. The client hepler functions utilize this to automatically // create endpoint URLs. FOREMAN_API_URL_PREFIX = "/api" // The Foreman API allows you to request a specific API version in the // Accept header of the HTTP request. The two supported versions (at // the time of writing) are 1 and 2, which version 1 planning on being // deprecated after version 1.17. FOREMAN_API_VERSION = "2" )
const ( // HostEndpointPrefix : Prefix appended to API url for hosts HostEndpointPrefix = "hosts" // BmcPowerSuffix : Suffix appended to API url for power operations BmcPowerSuffix = "power" // BmcPowerOn : Power on operation BmcPowerOn = "on" // BmcPowerOff : Power off operation BmcPowerOff = "off" // BmcPowerSoft : Power reboot operation (soft) BmcPowerSoft = "soft" // BmcPowerCycle : Power reset operation (hard) BmcPowerCycle = "cycle" // BmcPowerState : Power state check operation BmcPowerState = "state" // BmcBootSuffix : Suffix appended to API url for power operations BmcBootSuffix = "boot" // BmcBootDisk : Boot to Disk BmcBootDisk = "disk" // BmcBootCdrom : Boot to CDROM BmcBootCdrom = "cdrom" // BmcBootPxe : Boot to PXE BmcBootPxe = "pxe" // BmcPowerBios : Boot to BIOS BmcPowerBios = "bios" )
const (
ArchitectureEndpointPrefix = "architectures"
)
const (
DomainEndpointPrefix = "domains"
)
const (
EnvironmentEndpointPrefix = "environments"
)
const (
HostgroupEndpointPrefix = "hostgroups"
)
const (
MediaEndpointPrefix = "media"
)
const (
ModelEndpointPrefix = "models"
)
const (
OperatingSystemEndpointPrefix = "operatingsystems"
)
const (
PartitionTableEndpointPrefix = "ptables"
)
const (
ProvisioningTemplateEndpointPrefix = "provisioning_templates"
)
const (
SmartProxyEndpointPrefix = "smart_proxies"
)
const (
SubnetEndpointPrefix = "subnets"
)
const (
TemplateKindEndpointPrefix = "template_kinds"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BMCBoot ¶
type BMCBoot struct { Device string `json:"device,omitempty"` Boot struct { Action string `json:"action,omitempty"` Result bool `json:"result,omitempty"` } `json:"boot,omitempty"` }
BMCBoot struct used for marshal/unmarshal of BMC boot device valid boot devices are disk, cdrom, pxe, bios `omitempty“ lets use the same struct for boot operations.BMCCommand
type BMCPower ¶
type BMCPower struct { PowerAction string `json:"power_action,omitempty"` Power bool `json:"power,omitempty"` }
BMCPower struct for marshal/unmarshal of BMC power state valid states are on, off, soft, cycle, state `omitempty“ lets use the same struct for power operations.BMCCommand
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(s Server, c ClientCredentials, cfg ClientConfig) *Client
NewClient creates a new instance of the REST client for communication with the API gateway.
func (*Client) CreateArchitecture ¶
func (c *Client) CreateArchitecture(a *ForemanArchitecture) (*ForemanArchitecture, error)
CreateArchitecture creates a new ForemanArchitecture with the attributes of the supplied ForemanArchitecture reference and returns the created ForemanArchitecture reference. The returned reference will have its ID and other API default values set by this function.
func (*Client) CreateDomain ¶
func (c *Client) CreateDomain(d *ForemanDomain) (*ForemanDomain, error)
CreateDomain creates a new ForemanDomain with the attributes of the supplied ForemanDomain reference and returns the created ForemanDomain reference. The returned reference will have its ID and other API default values set by this function.
func (*Client) CreateEnvironment ¶
func (c *Client) CreateEnvironment(e *ForemanEnvironment) (*ForemanEnvironment, error)
CreateEnvironment creates a new ForemanEnvironment with the attributes of the supplied ForemanEnvironment reference and returns the created ForemanEnvironment reference. The returned reference will have its ID and other API default values set by this function.
func (*Client) CreateHost ¶
func (c *Client) CreateHost(h *ForemanHost, retryCount int) (*ForemanHost, error)
CreateHost creates a new ForemanHost with the attributes of the supplied ForemanHost reference and returns the created ForemanHost reference. The returned reference will have its ID and other API default values set by this function.
func (*Client) CreateHostgroup ¶
func (c *Client) CreateHostgroup(h *ForemanHostgroup) (*ForemanHostgroup, error)
CreateHostgroup creates a new ForemanHostgroup with the attributes of the supplied ForemanHostgroup reference and returns the created ForemanHostgroup reference. The returned reference will have its ID and other API default values set by this function.
func (*Client) CreateMedia ¶
func (c *Client) CreateMedia(m *ForemanMedia) (*ForemanMedia, error)
CreateMedia creates a new ForemanMedia with the attributes of the supplied ForemanMedia reference and returns the created ForemanMedia reference. The returned reference will have its ID and other API default values set by this function.
func (*Client) CreateModel ¶
func (c *Client) CreateModel(m *ForemanModel) (*ForemanModel, error)
CreateModel creates a new ForemanModel with the attributes of the supplied ForemanModel reference and returns the created ForemanModel reference. The returned reference will have its ID and other API default values set by this function.
func (*Client) CreateOperatingSystem ¶
func (c *Client) CreateOperatingSystem(o *ForemanOperatingSystem) (*ForemanOperatingSystem, error)
CreateOperatingSystem creates a new ForemanOperatingSystem with the attributes of the supplied ForemanOperatingSystem reference and returns the created ForemanOperatingSystem reference. The returned reference will have its ID and other API default values set by this function.
func (*Client) CreatePartitionTable ¶
func (c *Client) CreatePartitionTable(t *ForemanPartitionTable) (*ForemanPartitionTable, error)
CreatePartitionTable creates a new ForemanPartitionTable with the attributes of the supplied ForemanPartitionTable reference and returns the created ForemanPartitionTable reference. The returned reference will have its ID and other API default values set by this function.
func (*Client) CreateProvisioningTemplate ¶
func (c *Client) CreateProvisioningTemplate(t *ForemanProvisioningTemplate) (*ForemanProvisioningTemplate, error)
CreateProvisioningTemplate creates a new ForemanProvisioningTemplate with the attributes of the supplied ForemanProvisioningTemplate reference and returns the created ForemanProvisioningTemplate reference. The returned reference will have its ID and other API default values set by this function.
func (*Client) CreateSmartProxy ¶
func (c *Client) CreateSmartProxy(s *ForemanSmartProxy) (*ForemanSmartProxy, error)
CreateSmartProxy creates a new ForemanSmartProxy with the attributes of the supplied ForemanSmartProxy reference and returns the created ForemanSmartProxy reference. The returned reference will have its ID and other API default values set by this function.
func (*Client) CreateSubnet ¶
func (c *Client) CreateSubnet(s *ForemanSubnet) (*ForemanSubnet, error)
CreateSubnet creates a new ForemanSubnet with the attributes of the supplied ForemanSubnet reference and returns the created ForemanSubnet reference. The returned reference will have its ID and other API default values set by this function.
func (*Client) DeleteArchitecture ¶
DeleteArchitecture deletes the ForemanArchitecture identified by the supplied ID
func (*Client) DeleteDomain ¶
DeleteDomain deletes the ForemanDomain identified by the supplied ID
func (*Client) DeleteEnvironment ¶
DeleteEnvironment deletes the ForemanEnvironment identified by the supplied ID
func (*Client) DeleteHost ¶
DeleteHost deletes the ForemanHost identified by the supplied ID
func (*Client) DeleteHostgroup ¶
DeleteHostgroup deletes the ForemanHostgroup identified by the supplied ID
func (*Client) DeleteMedia ¶
DeleteMedia deletes the ForemanMedia identified by the supplied ID
func (*Client) DeleteModel ¶
DeleteModel deletes the ForemanModel identified by the supplied ID
func (*Client) DeleteOperatingSystem ¶
DeleteOperatingSystem deletes the ForemanOperatingSystem identified by the supplied ID
func (*Client) DeletePartitionTable ¶
DeletePartitionTable deletes the ForemanPartitionTable identified by the supplied ID
func (*Client) DeleteProvisioningTemplate ¶
DeleteProvisioningTemplate deletes the ForemanProvisioningTemplate identified by the supplied ID
func (*Client) DeleteSmartProxy ¶
DeleteSmartProxy deletes the ForemanSmartProxy identified by the supplied ID
func (*Client) DeleteSubnet ¶
DeleteSubnet deletes the ForemanSubnet identified by the supplied ID
func (*Client) NewRequest ¶
func (client *Client) NewRequest(method string, endpoint string, body io.Reader) (*http.Request, error)
NewRequest constructs an HTTP request using the client configuration. Common request functionality is abstracted and wrapped into this function (ie: headers, cookies, MIME-info, etc). The client should never interact with the underlying HTTP client or request object directly.
If the user provides an invalid HTTP method, the function returns 'nil' for the request and will return an Error.
The following headers are added and set automatically:
User-Agent ACCEPT Content-Type Authorization
method
The HTTP Verb to use. This should correspond to a 'Method*' constant from 'net/http'.
endpoint
The server's endpoint to send the request. The endpoint value is appended to the client's server URL to construct the full URL for the request. NewRequest() will automatically prepend the Foreman API URL prefix to the endpoint.
body
Functions exactly like net/http/NewRequest()
func (*Client) QueryArchitecture ¶
func (c *Client) QueryArchitecture(a *ForemanArchitecture) (QueryResponse, error)
QueryArchitecture queries for a ForemanArchitecture based on the attributes of the supplied ForemanArchitecture reference and returns a QueryResponse struct containing query/response metadata and the matching architectures.
func (*Client) QueryDomain ¶
func (c *Client) QueryDomain(d *ForemanDomain) (QueryResponse, error)
QueryDomain queries for a ForemanDomain based on the attributes of the supplied ForemanDomain reference and returns a QueryResponse struct containing query/response metadata and the matching domains.
func (*Client) QueryEnvironment ¶
func (c *Client) QueryEnvironment(e *ForemanEnvironment) (QueryResponse, error)
QueryEnvironment queries for a ForemanEnvironment based on the attributes of the supplied ForemanEnvironment reference and returns a QueryResponse struct containing query/response metadata and the matching environments.
func (*Client) QueryHostgroup ¶
func (c *Client) QueryHostgroup(h *ForemanHostgroup) (QueryResponse, error)
QueryHostgroup queries for a ForemanHostgroup based on the attributes of the supplied ForemanHostgroup reference and returns a QueryResponse struct containing query/response metadata and the matching hostgroups.
func (*Client) QueryMedia ¶
func (c *Client) QueryMedia(m *ForemanMedia) (QueryResponse, error)
QueryMedia queries for a ForemanMedia based on the attributes of the supplied ForemanMedia reference and returns a QueryResponse struct containing query/response metadata and the matching media.
func (*Client) QueryModel ¶
func (c *Client) QueryModel(m *ForemanModel) (QueryResponse, error)
QueryModel queries for a ForemanModel based on the attributes of the supplied ForemanModel reference and returns a QueryResponse struct containing query/response metadata and the matching model.
func (*Client) QueryOperatingSystem ¶
func (c *Client) QueryOperatingSystem(o *ForemanOperatingSystem) (QueryResponse, error)
QueryOperatingSystem queries for a ForemanOperatingSystem based on the attributes of the supplied ForemanOperatingSystem reference and returns a QueryResponse struct containing query/response metadata and the matching operating systems.
func (*Client) QueryPartitionTable ¶
func (c *Client) QueryPartitionTable(t *ForemanPartitionTable) (QueryResponse, error)
QueryPartitionTable queries for a ForemanPartitionTable based on the attributes of the supplied ForemanPartitionTable reference and returns a QueryResponse struct containing query/response metadata and the matching partition tables.
func (*Client) QueryProvisioningTemplate ¶
func (c *Client) QueryProvisioningTemplate(t *ForemanProvisioningTemplate) (QueryResponse, error)
QueryProvisioningTemplate queries for a ForemanProvisioningTemplate based on the attributes of the supplied ForemanProvisioningTemplate reference and returns a QueryResponse struct containing query/response metadata and the matching templates.
func (*Client) QuerySmartProxy ¶
func (c *Client) QuerySmartProxy(s *ForemanSmartProxy) (QueryResponse, error)
QuerySmartProxy queries for a ForemanSmartProxy based on the attributes of the supplied ForemanSmartProxy reference and returns a QueryResponse struct containing query/response metadata and the matching smart proxy.
func (*Client) QuerySubnet ¶
func (c *Client) QuerySubnet(s *ForemanSubnet) (QueryResponse, error)
QuerySubnet queries for a ForemanSubnet based on the attributes of the supplied ForemanSubnet reference and returns a QueryResponse struct containing query/response metadata and the matching subnets
func (*Client) QueryTemplateKind ¶
func (c *Client) QueryTemplateKind(t *ForemanTemplateKind) (QueryResponse, error)
QueryTemplateKind queries for a ForemanTemplateKind based on the attributes of the supplied ForemanTemplateKind reference and returns a QueryResponse struct containing query/response metadata and the matching template kinds
func (*Client) ReadArchitecture ¶
func (c *Client) ReadArchitecture(id int) (*ForemanArchitecture, error)
ReadArchitecture reads the attributes of a ForemanArchitecture identified by the supplied ID and returns a ForemanArchitecture reference.
func (*Client) ReadDomain ¶
func (c *Client) ReadDomain(id int) (*ForemanDomain, error)
ReadDomain reads the attributes of a ForemanDomain identified by the supplied ID and returns a ForemanDomain reference.
func (*Client) ReadEnvironment ¶
func (c *Client) ReadEnvironment(id int) (*ForemanEnvironment, error)
ReadEnvironment reads the attributes of a ForemanEnvironment identified by the supplied ID and returns a ForemanEnvironment reference.
func (*Client) ReadHost ¶
func (c *Client) ReadHost(id int) (*ForemanHost, error)
ReadHost reads the attributes of a ForemanHost identified by the supplied ID and returns a ForemanHost reference.
func (*Client) ReadHostgroup ¶
func (c *Client) ReadHostgroup(id int) (*ForemanHostgroup, error)
ReadHostgroup reads the attributes of a ForemanHostgroup identified by the supplied ID and returns a ForemanHostgroup reference.
func (*Client) ReadMedia ¶
func (c *Client) ReadMedia(id int) (*ForemanMedia, error)
ReadMedia reads the attributes of a ForemanMedia identified by the supplied ID and returns a ForemanMedia reference.
func (*Client) ReadModel ¶
func (c *Client) ReadModel(id int) (*ForemanModel, error)
ReadModel reads the attributes of a ForemanModel identified by the supplied ID and returns a ForemanModel reference.
func (*Client) ReadOperatingSystem ¶
func (c *Client) ReadOperatingSystem(id int) (*ForemanOperatingSystem, error)
ReadOperatingSystem reads the attributes of a ForemanOperatingSystem identified by the supplied ID and returns a ForemanOperatingSystem reference.
func (*Client) ReadPartitionTable ¶
func (c *Client) ReadPartitionTable(id int) (*ForemanPartitionTable, error)
ReadPartitionTable reads the attributes of a ForemanPartitionTable identified by the supplied ID and returns a ForemanPartitionTable reference.
func (*Client) ReadProvisioningTemplate ¶
func (c *Client) ReadProvisioningTemplate(id int) (*ForemanProvisioningTemplate, error)
ReadProvisioningTemplate reads the attributes of a ForemanProvisioningTemplate identified by the supplied ID and returns a ForemanProvisioningTemplate reference.
func (*Client) ReadSmartProxy ¶
func (c *Client) ReadSmartProxy(id int) (*ForemanSmartProxy, error)
ReadSmartProxy reads the attributes of a ForemanSmartProxy identified by the supplied ID and returns a ForemanSmartProxy reference.
func (*Client) ReadSubnet ¶
func (c *Client) ReadSubnet(id int) (*ForemanSubnet, error)
ReadSubnet reads the attributes of a ForemanSubnet identified by the supplied ID and returns a ForemanSubnet reference.
func (*Client) ReadTemplateKind ¶
func (c *Client) ReadTemplateKind(id int) (*ForemanTemplateKind, error)
ReadTemplateKind reads the attributes of a ForemanTemplateKind identified by the supplied ID and returns a ForemanTemplateKind reference.
func (*Client) Send ¶
Send sends an HTTP request generated by Client.NewRequest() and returns the StatusCode, response. Serves as a facade to the Client's underlying HTTP client.
If an error is encountered when reading the server's response, the returned StatusCode will be -1. If an error is encountered during any step of the the send and response parsing, an empty slice will be returned as the request body.
request
An HTTP request generated by Client.NewRequest()
func (*Client) SendAndParse ¶
SendAndParse sends an HTTP request generated by Client.NewRequest() and parses the server's response for errors. If an error is encountered during the sending or response parsing, the function returns an error. Otherwise, the server's response is unmarshalled into the supplied interface (if the interface is not nil).
func (*Client) SendBMCCommand ¶
func (c *Client) SendBMCCommand(h *ForemanHost, cmd interface{}, retryCount int) error
SendBMCCommand sends provided BMC Action and State to foreman. This performs an IPMI action against the provided host Expects BMCPower or BMCBoot type struct populated with an action
Example: https://<foreman>/api/hosts/<hostname>/boot
func (*Client) UpdateArchitecture ¶
func (c *Client) UpdateArchitecture(a *ForemanArchitecture) (*ForemanArchitecture, error)
UpdateArchitecture updates a ForemanArchitecture's attributes. The architecture with the ID of the supplied ForemanArchitecture will be updated. A new ForemanArchitecture reference is returned with the attributes from the result of the update operation.
func (*Client) UpdateDomain ¶
func (c *Client) UpdateDomain(d *ForemanDomain) (*ForemanDomain, error)
UpdateDomain updates a ForemanDomain's attributes. The domain with the ID of the supplied ForemanDomain will be updated. A new ForemanDomain reference is returned with the attributes from the result of the update operation.
func (*Client) UpdateEnvironment ¶
func (c *Client) UpdateEnvironment(e *ForemanEnvironment) (*ForemanEnvironment, error)
UpdateEnvironment updates a ForemanEnvironment's attributes. The environment with the ID of the supplied ForemanEnvironment will be updated. A new ForemanEnvironment reference is returned with the attributes from the result of the update operation.
func (*Client) UpdateHost ¶
func (c *Client) UpdateHost(h *ForemanHost, retryCount int) (*ForemanHost, error)
UpdateHost updates a ForemanHost's attributes. The host with the ID of the supplied ForemanHost will be updated. A new ForemanHost reference is returned with the attributes from the result of the update operation.
func (*Client) UpdateHostgroup ¶
func (c *Client) UpdateHostgroup(h *ForemanHostgroup) (*ForemanHostgroup, error)
UpdateHostgroup updates a ForemanHostgroup's attributes. The hostgroup with the ID of the supplied ForemanHostgroup will be updated. A new ForemanHostgroup reference is returned with the attributes from the result of the update operation.
func (*Client) UpdateMedia ¶
func (c *Client) UpdateMedia(m *ForemanMedia) (*ForemanMedia, error)
UpdateMedia updates a ForemanMedia's attributes. The media with the ID of the supplied ForemanMedia will be updated. A new ForemanMedia reference is returned with the attributes from the result of the update operation.
func (*Client) UpdateModel ¶
func (c *Client) UpdateModel(m *ForemanModel) (*ForemanModel, error)
UpdateModel updates a ForemanModel's attributes. The model with the ID of the supplied ForemanModel will be updated. A new ForemanModel reference is returned with the attributes from the result of the update operation.
func (*Client) UpdateOperatingSystem ¶
func (c *Client) UpdateOperatingSystem(o *ForemanOperatingSystem) (*ForemanOperatingSystem, error)
UpdateOperatingSystem updates a ForemanOperatingSystem's attributes. The operating system with the ID of the supplied ForemanOperatingSystem will be updated. A new ForemanOperatingSystem reference is returned with the attributes from the result of the update operation.
func (*Client) UpdatePartitionTable ¶
func (c *Client) UpdatePartitionTable(t *ForemanPartitionTable) (*ForemanPartitionTable, error)
UpdatePartitionTable updates a ForemanPartitionTable's attributes. The partition table with the ID of the supplied ForemanPartitionTable will be updated. A new ForemanPartitionTable reference is returned with the attributes from the result of the update operation.
func (*Client) UpdateProvisioningTemplate ¶
func (c *Client) UpdateProvisioningTemplate(t *ForemanProvisioningTemplate) (*ForemanProvisioningTemplate, error)
UpdateProvisioningTemplate updates a ForemanProvisioningTemplate's attributes. The template with the ID of the supplied ForemanProvisioningTemplate will be updated. A new ForemanProvisioningTemplate reference is returned with the attributes from the result of the update operation.
func (*Client) UpdateSmartProxy ¶
func (c *Client) UpdateSmartProxy(s *ForemanSmartProxy) (*ForemanSmartProxy, error)
UpdateSmartProxy updates a ForemanSmartProxy's attributes. The smart proxy with the ID of the supplied ForemanSmartProxy will be updated. A new ForemanSmartProxy reference is returned with the attributes from the result of the update operation.
func (*Client) UpdateSubnet ¶
func (c *Client) UpdateSubnet(s *ForemanSubnet) (*ForemanSubnet, error)
UpdateSubnet updates a ForemanSubnet's attributes. The subnet with the ID of the supplied ForemanSubnet will be updated. A new ForemanSubnet reference is returned with the attributes from the result of the update operation.
type ClientConfig ¶
type ClientConfig struct { // Whether or not to verify the server's certificate/hostname. This flag // is passed to the TLS config when initializing the REST client for API // communication. // // See 'pkg/crypto/tls/#Config.InsecureSkipVerify' for more information TLSInsecureEnabled bool }
Configurable features to apply the REST client
type ClientCredentials ¶
Credentials used to authenticate the client against the remote server - in this case, the Foreman API
type ForemanArchitecture ¶
type ForemanArchitecture struct { // Inherits the base object's attributes ForemanObject // Array of ForemanOperatingSystem IDs associated with this architecture OperatingSystemIds []int `json:"operatingsystem_ids"` }
The ForemanArchitecture API model represents an instruction set architecture (ISA)
func (*ForemanArchitecture) UnmarshalJSON ¶
func (fa *ForemanArchitecture) UnmarshalJSON(b []byte) error
Custom JSON unmarshal function. Unmarshal to the unexported JSON struct and then convert over to a ForemanArchitecture struct.
type ForemanDomain ¶
type ForemanDomain struct { // Inherits the base object's attributes ForemanObject // Fully qualified domain name Fullname string `json:"fullname"` }
The ForemanDomain API model represents the domain name. Domains serve as an identification string that defines autonomy, authority, or control for a portion of a network.
type ForemanEnvironment ¶
type ForemanEnvironment struct { // Inherits the base object's attributes ForemanObject }
The ForemanEnvironment API model represents a puppet environment
type ForemanHost ¶
type ForemanHost struct { // Inherits the base object's attributes ForemanObject // Whether or not to rebuild the host on reboot Build bool `json:"build"` // ID of the domain to assign the host DomainId int `json:"domain_id"` // ID of the environment to assign the host EnvironmentId int `json:"environment_id"` // ID of the hostgroup to assign the host HostgroupId int `json:"hostgroup_id"` // ID of the operating system to put on the host OperatingSystemId int `json:"operatingsystem_id"` // Whether or not to Enable BMC Functionality on this host EnableBMC bool // Boolean to track success of BMC Calls BMCSuccess bool // Additional information about this host Comment string `json:"comment"` // Nested struct defining any interfaces associated with the Host InterfacesAttributes []ForemanInterfacesAttribute `json:"interfaces_attributes"` }
The ForemanHost API model represents a host managed by Foreman
func (ForemanHost) MarshalJSON ¶
func (fh ForemanHost) MarshalJSON() ([]byte, error)
Implement the Marshaler interface
func (*ForemanHost) UnmarshalJSON ¶
func (fh *ForemanHost) UnmarshalJSON(b []byte) error
Custom JSON unmarshal function. Unmarshal to the unexported JSON struct and then convert over to a ForemanHost struct.
type ForemanHostgroup ¶
type ForemanHostgroup struct { // Inherits the base object's attributes ForemanObject // The title is a computed property representing the fullname of the // hostgroup. A hostgroup's title is a path-like string from the head // of the hostgroup tree down to this hostgroup. The title will be // in the form of: "<parent 1>/<parent 2>/.../<name>" Title string `json:"title"` // ID of the architecture associated with this hostgroup ArchitectureId int `json:"architecture_id"` // ID of the compute profile associated with this hostgroup ComputeProfileId int `json:"compute_profile_id"` // ID of the domain associated with this hostgroup DomainId int `json:"domain_id"` // ID of the environment associated with this hostgroup EnvironmentId int `json:"environment_id"` // ID of the media associated with this hostgroup MediaId int `json:"medium_id"` // ID of the operating system associated with this hostgroup OperatingSystemId int `json:"operatingsystem_id"` // ID of this hostgroup's parent hostgroup ParentId int `json:"parent_id"` // ID of the partition table to use with this hostgroup PartitionTableId int `json:"ptable_id"` // ID of the smart proxy acting as the puppet certificate authority // server for the hostgroup PuppetCAProxyId int `json:"puppet_ca_proxy_id"` // ID of the smart proxy acting as the puppet proxy server for the // hostgroup PuppetProxyId int `json:"puppet_proxy_id"` // ID of the realm associated with the hostgroup RealmId int `json:"realm_id"` // ID of the subnet associated with the hostgroup SubnetId int `json:"subnet_id"` }
The ForemanHostgroup API model represents a hostgroup. Hostgroups are organized in a tree-like structure and can inherit the values of their parent hostgroups. The relationship is maintained through the parent_id attribute.
When hosts get associated with a hostgroup, it will inherit attributes from the hostgroup. This allows for easy shared configuration of various hosts based on common attributes.
func (ForemanHostgroup) MarshalJSON ¶
func (fh ForemanHostgroup) MarshalJSON() ([]byte, error)
Implement the Marshaler interface
type ForemanInterfacesAttribute ¶
type ForemanInterfacesAttribute struct { Id int `json:"id,omitempty"` SubnetId int `json:"subnet_id"` Identifier string `json:"identifier"` Name string `json:"name"` Username string `json:"username"` Password string `json:"password"` Managed bool `json:"managed"` Provision bool `json:"provision"` Virtual bool `json:"virtual"` Primary bool `json:"primary"` IP string `json:"ip"` MAC string `json:"mac"` Type string `json:"type"` Provider string `json:"provider"` // NOTE(ALL): Each of the interfaces receives a unique identifier // on creation. To modify the list of interfaces, the supplied // list to the API does NOT perform a replace operation. Adding new // interfaces to the list is rather trivial and just involves sending the // new values to receive an ID. When removing one of the combinations from // the set, a secret flag "_destroy" must be supplied as part of that // combination. This is not documented as part of the Foreman API. We // omit empty here, because we only want to pass the flag when "_destroy" // is "true" to signal an item removal. Destroy bool `json:"_destroy,omitempty"` }
ForemanInterfacesAttribute representing a hosts defined network interfaces
type ForemanMedia ¶
type ForemanMedia struct { // Inherits the base object's attributes ForemanObject // The path to the medium, can be a URL or a valid NFS server (exclusive // of the architecture). For example: // // http://mirror.centos.org/centos/$version/os/$arch // // Where $arch will be substituted for the host's actual OS architecture // and $version, $major, $minor will be substituted for the version of the // operating system. // // Solaris and Debian media may also use $release. Path string `json:"path"` // Operating sysem family. Available values: AIX, Altlinux, Archlinux, // Coreos, Debian, Freebsd, Gentoo, Junos, NXOS, Redhat, Solaris, Suse, // Windows. OSFamily string `json:"os_family"` // IDs of operating systems associated with this media OperatingSystemIds []int `json:"operatingsystem_ids"` }
The ForemanMedia API model represents a remote installation media.
func (*ForemanMedia) UnmarshalJSON ¶
func (fm *ForemanMedia) UnmarshalJSON(b []byte) error
Implement the Unmarshaler interface
type ForemanModel ¶
type ForemanModel struct { // Inherits the base object's attributes ForemanObject // Additional information about this hardware model Info string `json:"info"` // Name or class of the hardware vendor VendorClass string `json:"vendor_class"` // Name of the specific hardware model HardwareModel string `json:"hardware_model"` }
The ForemanModel API model represents a specific vendor hardware model
type ForemanObject ¶
type ForemanObject struct { // Unique identifier for this object Id int `json:"id"` // Human readable name of the API object Name string `json:"name"` // Timestamp of when the API object was created in the following format: // "%Y-%m-%d %H-%M-%S UTC" CreatedAt string `json:"created_at"` // Timestamp of when the API object was last updated in the following format: // "%Y-%m-%d %H-%M-%S UTC" UpdatedAt string `json:"updated_at"` }
Base Foreman API object in the Foreman object model. Every API entity has the following attributes:
type ForemanOperatingSystem ¶
type ForemanOperatingSystem struct { // Inherits the base object's attributes ForemanObject // Title is a computed property by Foreman. The operating system's // title is a concatentation of the OS name, major, and minor versions // to get a full operating system release. Title string `json:"title"` // Major release version Major string `json:"major"` // Minor release version Minor string `json:"minor"` // Additional information about the operating system Description string `json:"description"` // Operating sysem family. Available values: AIX, Altlinux, Archlinux, // Coreos, Debian, Freebsd, Gentoo, Junos, NXOS, Redhat, Solaris, Suse, // Windows. Family string `json:"family"` // Code name or release name for the specific operating system version ReleaseName string `json:"release_name"` // Root password hash function to use. If set, valid values are "MD5", // "SHA256", "SHA512", and "Base64" PasswordHash string `json:"password_hash"` }
The ForemanOperatingSystem API model represents an operating system
type ForemanPartitionTable ¶
type ForemanPartitionTable struct { // Inherits the base object's attributes ForemanObject // The script that defines the partition table layout Layout string `json:"layout"` // Whether or not this partition table is a snippet to be embedded in // other partition tables Snippet bool `json:"snippet"` // Any audit comments to associate with the partition table. // // The Audit Comment field is saved with the template auditing to document // the template changes. AuditComment string `json:"audit_comment"` // Whether or not this partition table is locked for editing Locked bool `json:"locked"` // Operating sysem family. Available values: AIX, Altlinux, Archlinux, // Coreos, Debian, Freebsd, Gentoo, Junos, NXOS, Redhat, Solaris, Suse, // Windows. OSFamily string `json:"os_family"` // IDs of the operating system this partition table applies OperatingSystemIds []int `json:"operatingsystem_ids"` // IDs of the hostgroups this partition table applies HostgroupIds []int `json:"hostgroup_ids"` // IDs of the hosts this partition table applies HostIds []int `json:"host_ids"` }
The FormanPartitionTable API model represents the disk partition layout of the host. The actual meta-script is stored inside of the Layout attribute.
func (*ForemanPartitionTable) UnmarshalJSON ¶
func (ft *ForemanPartitionTable) UnmarshalJSON(b []byte) error
Implement the Unmarshaler interface
type ForemanProvisioningTemplate ¶
type ForemanProvisioningTemplate struct { // Inherits the base object's attributes ForemanObject // The markup and code of the provisioning template Template string // Whether or not the provisioning template is a snippet to be embedded // and used by other templates Snippet bool // Notes and comments for auditing purposes AuditComment string // Whether or not the template is locked for editing Locked bool // ID of the template kind which categorizes the provisioning template. // Optional for snippets, otherwise required. TemplateKindId int // IDs of operating systems associated with this provisioning template OperatingSystemIds []int // How templates are determined: // // When editing a template, you must assign a list of operating systems // which this template can be used with. Optionally, you can restrict // a template to a list of host groups and/or environments. // // When a host requests a template, Foreman will select the best match // from the available templates of that type in the following order: // // 1. host group and environment // 2. host group only // 3. environment only // 4. operating system default // // Template combinations attributes contains an array of hostgroup IDs // and environment ID combinations so they can be used in the // provisioning template selection described above. TemplateCombinationsAttributes []ForemanTemplateCombinationAttribute `json:"template_combinations_attributes"` }
The ForemanProvisioningTemplate API model represents a provisioning template. Provisioning templates are scripts used to describe how to boostrap and install the operating system on a host.
func (ForemanProvisioningTemplate) MarshalJSON ¶
func (ft ForemanProvisioningTemplate) MarshalJSON() ([]byte, error)
Custom JSON marshal function for provisioning temmplates. The Foreman API expects all parameters to be enclosed in double quotes, with the exception of boolean and slice values.
func (*ForemanProvisioningTemplate) UnmarshalJSON ¶
func (ft *ForemanProvisioningTemplate) UnmarshalJSON(b []byte) error
Custom JSON unmarshal function. Unmarshal to the unexported JSON struct and then convert over to a ForemanProvisioningTemplate struct.
type ForemanSmartProxy ¶
type ForemanSmartProxy struct { // Inherits the base object's attributes ForemanObject // Uniform resource locator of the proxy (ie: https://server:8008) URL string `json:"url"` }
The ForemanSmartProxy API model representing a proxy server. Smart proxies provide an API for a higher-level orchestration tool. Foreman supports the following smart proxies:
- DHCP - ISC DHCP & MS DHCP servers
- DNS - bind & MS DNS servers
- Puppet >= 0.24.x
- Puppet CA
- Realm - manage host registration to a realm (eg: FreeIPA)
- Templates - Proxy template requests from hosts in isolated networks
- TFTP
type ForemanSubnet ¶
type ForemanSubnet struct { // Inherits the base object's attributes ForemanObject // Subnet network (ie: 192.168.100.0) Network string `json:"network"` // Netmask for this subnet (ie: 255.255.255.0) Mask string `json:"mask"` // Gateway server to use when connecting/communicating to anything not // on the same network Gateway string `json:"gateway"` // Primary DNS server for this subnet DnsPrimary string `json:"dns_primary"` // Secondary DNS server for this subnet DnsSecondary string `json:"dns_secondary"` // IP address auto-suggestion mode for this subnet. If set, valid values // are "DHCP", "Internal DB", and "None". Ipam string `json:"ipam"` // Starting IP address for IP auto suggestion From string `json:"from"` // Ending IP address for IP auto suggestion To string `json:"to"` // Default boot mode for instances assigned to this subnet. If set, valid // values are "Static" and "DHCP". BootMode string `json:"boot_mode"` }
The ForemanSubnet API model represents a subnet
type ForemanTemplateCombinationAttribute ¶
type ForemanTemplateCombinationAttribute struct { // Unique identifier of the template combination Id int `json:"id,omitempty"` // Hostgroup ID associated with the template combination HostgroupId int `json:"hostgroup_id,omitempty"` // Environment ID associated with the template combination EnvironmentId int `json:"environment_id,omitempty"` // NOTE(ALL): Each of the template combinations receives a unique identifier // on creation. To modify the list of template combinations, the supplied // list to the API does NOT perform a replace operation. Adding new // combinations to the list is rather trivial and just involves sending the // new values to receive an ID. When removing one of the combinations from // the set, a secret flag "_destroy" must be supplied as part of that // combination. This is not documented as part of the Foreman API. We // omit empty here, because we only want to pass the flag when "_destroy" // is "true" to signal an item removal. Destroy bool `json:"_destroy,omitempty"` }
See the comment in ForemanProvisioningTemplate.TemplateCombinationsAttributes
type ForemanTemplateKind ¶
type ForemanTemplateKind struct { // Inherits the base object's attributes ForemanObject }
The ForemanTemplateKind API model represents a category of provisioning template. Examples include:
- PXELinux
- provision
- PXEGrub
- ZTP
type QueryResponse ¶
type QueryResponse struct { // Total number of objects of that resource type in Foreman Total int `json:"total"` // Number of results matching the search criteria Subtotal int `json:"subtotal"` // Current result page (if using pagination in searches) Page int `json:"page"` // How many results to display per page (if using pagination in searches) PerPage int `json:"per_page"` // The search filter string in the form property=value&property=value&... Search string `json:"search,omitempty"` // Sorting options provided for the search Sort QueryResponseSort `json:"sort,omitempty"` // Foreman API objects that matched the search criteria for the query. Results []interface{} `json:"results"` }
Base API query response struct. For all "search" API calls (following the format /api/<resource name>), the response will be in the following format.
The Results attribute will be an array of Foreman API objects from the model package that matched the search criteria.
type QueryResponseSort ¶
type QueryResponseSort struct { // In which manner to order results (ASC, DESC) Order string `json:"order,omitempty"` // Which field to order by By string `json:"by,omitempty"` }
Sort options as part of the generic query resposne