theforeman

package module
v0.0.0-...-ec59288 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2016 License: Apache-2.0 Imports: 2 Imported by: 0

README

go-theforeman

A small sling wrapper for The Foreman API in Golang

Usage

package main

import (
  "fmt"
  "github.com/dudemcbacon/go-theforeman"
)

func main() {
  config := &theforeman.Config{
    BaseURL:  "http://foreman.mgmt.nweacolo.pvt/api/",
    Username: "api-user",
    Password: "snip",
  }

  foreman := theforeman.NewClient(config, nil)

  names, _, _ := foreman.EnvironmentsService.ListEnvironmentNames(nil)
  for _, name := range names {
    fmt.Println(name)
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	EnvironmentsService *EnvironmentsService
	HostsService        *HostsService
}

func NewClient

func NewClient(conf *Config, httpClient *http.Client) *Client

NewClient returns a new Client

type Config

type Config struct {
	// Base URL for TheForeman API
	BaseURL string

	HttpClient *http.Client

	Username string

	Password string
}

type Environment

type Environment struct {
	Name      string `json:"name"`
	ID        int    `json:"id"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

type Environments

type Environments struct {
	Total    int           `json:"total"`
	SubTotal int           `json:"subtotal"`
	Page     int           `json:"page"`
	PerPage  int           `json:"per_page"`
	Search   string        `json:"search"`
	Results  []Environment `json:"results"`
}

type EnvironmentsParams

type EnvironmentsParams struct {
	PuppetClassID  string `url:"puppetclass_id,omitempty"`
	LocationID     string `url:"location_id,omitempty"`
	Order          string `url:"order,omitempty"`
	OrganizationID string `url:"organization_id,omitempty"`
	Page           string `url:"page,omitempty"`
	PerPage        string `url:"per_page,omitempty"`
	Search         string `url:"search,omitempty"`
}

type EnvironmentsService

type EnvironmentsService struct {
	// contains filtered or unexported fields
}

func NewEnvironmentsService

func NewEnvironmentsService(s *sling.Sling) *EnvironmentsService

func (*EnvironmentsService) List

func (*EnvironmentsService) ListEnvironmentNames

func (s *EnvironmentsService) ListEnvironmentNames(params *EnvironmentsParams) ([]string, *http.Response, error)

type Host

type Host struct {
	ArchitectureID      int    `json:"architecture_id"`
	ArchitectureName    string `json:"architecture_name"`
	Build               bool   `json:"build"`
	CertName            string `json:"certname"`
	Comment             string `json:"comment"`
	ComputeProfileName  string `json:"compute_profile_name"`
	ComputeResourceID   int    `json:"compute_resource_id"`
	ComputeResourceName string `json:"compute_resource_name"`
	ComputerProfileID   int    `json:"compute_profile_id"`
	DomainID            int    `json:"domain_id"`
	DomainName          string `json:"domain_name"`
	Enabled             bool   `json:"enabled"`
	EnvironmentID       int    `json:"environment_id"`
	EnvironmentName     string `json:"environment_name"`
	GlobalStatus        int    `json:"global_status"`
	GlobalStatusLabel   string `json:"global_status_label"`
	HostgroupID         int    `json:"hostgroup_id"`
	HostgroupName       string `json:"hostgroup_name"`
	HostgroupTitle      string `json:"hostgroup_title"`
	ID                  int    `json:"id"`
	IP                  string `json:"ip"`
	ImageFile           string `json:"image_file"`
	ImageID             int    `json:"image_id"`
	ImageName           string `json:"image_name"`
	LastReport          string `json:"last_report"`
	LocationID          int    `json:"location_id"`
	LocationName        string `json:"location_name"`
	MAC                 string `json:"mac"`
	Managed             bool   `json:"managed"`
	MediumID            int    `json:"medium_id"`
	MediumName          string `json:"medium_name"`
	ModelID             int    `json:"model_id"`
	ModelName           string `json:"model_name"`
	Name                string `json:"name"`
	OperatingSystemID   int    `json:"operatingsystem_id"`
	OperatingSystemName string `json:"operatingsystem_name"`
	OrganizationID      int    `json:"organization_id"`
	OrganizationName    string `json:"organization_name"`
	OwnerID             int    `json:"owner_id"`
	OwnerType           string `json:"owner_type"`
	PTableID            int    `json:"ptable_id"`
	PTableName          string `json:"ptable_name"`
	ProvisionMethod     string `json:"provision_method"`
	PuppetCAProxyID     int    `json:"puppet_ca_proxy_id"`
	PuppetProxyID       int    `json:"puppet_proxy_id"`
	PuppetStatus        int    `json:"puppet_status"`
	RealmID             int    `json:"realm_id"`
	RealmName           string `json:"realm_name"`
	SPIP                string `json:"sp_ip"`
	SPMAC               string `json:"sp_mac"`
	SPName              string `json:"sp_name"`
	SPSUbnetID          int    `json:"sp_subnet_id"`
	SubnetID            int    `json:"subnet_id"`
	SubnetName          string `json:"subnet_name"`
	UUID                string `json:"uuid"`
}

type Hosts

type Hosts struct {
	Total    int    `json:"total"`
	SubTotal int    `json:"subtotal"`
	Page     int    `json:"page"`
	PerPage  int    `json:"per_page"`
	Search   string `json:"search"`
	Results  []Host `json:"results"`
}

type HostsParams

type HostsParams struct {
	EnvironmentID  string `url:"environment_id,omitempty"`
	HostgroupID    string `url:"hostgroup_id,omitempty"`
	LocationID     string `url:"location_id,omitempty"`
	Order          string `url:"order,omitempty"`
	OrganizationID string `url:"organization_id,omitempty"`
	Page           string `url:"page,omitempty"`
	PerPage        string `url:"per_page,omitempty"`
	Search         string `url:"search,omitempty"`
}

type HostsService

type HostsService struct {
	// contains filtered or unexported fields
}

func NewHostsService

func NewHostsService(s *sling.Sling) *HostsService

func (*HostsService) List

func (s *HostsService) List(params *HostsParams) (Hosts, *http.Response, error)

func (*HostsService) ListHostNames

func (s *HostsService) ListHostNames(params *HostsParams) ([]string, *http.Response, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL