awx

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: MIT Imports: 12 Imported by: 0

README

awx-go

Build Status Go Report Card codecov

AWX SDK for the Go programming language.

AWX-GO-ROBOT

Installing

If you are using Go 1.5 with the GO15VENDOREXPERIMENT=1 vendoring flag, or 1.6 and higher you can use the following command to retrieve the SDK. The SDK will be included.

go get -u github.com/Colstuwjx/awx-go

Example

We can simply import awx-go and call its services, such as PingService:

import (
    "log"
    awxGo "github.com/Colstuwjx/awx-go"
)

func main() {
    awx := awxGo.NewAWX("http://awx.your_server_host.com", "your_awx_username", "your_awx_passwd", nil)
    result, err := awx.PingService.Ping()
    if err != nil {
        log.Fatalf("Ping awx err: %s", err)
    }

    log.Println("Ping awx: ", result)
}

More examples can be found at here.

Roadmap

awx-go is still in development, and its roadmap could be found at here.

Contribute

There are many ways to contribute to awx-go.

Documentation

Index

Constants

View Source
const (
	JobStatusNew        = "new"
	JobStatusPending    = "pending"
	JobStatusWaiting    = "waiting"
	JobStatusRunning    = "running"
	JobStatusSuccessful = "successful"
	JobStatusFailed     = "failed"
	JobStatusError      = "error"
	JobStatusCanceled   = "canceled"
)

Enum of job statuses.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(resp *http.Response) error

CheckResponse do http response check, and return err if not in [200, 300).

func ValidateParams added in v0.0.3

func ValidateParams(data map[string]interface{}, mandatoryFields []string) (notfound []string, status bool)

ValidateParams is to validate the input to use the services.

Types

type APIRequest

type APIRequest struct {
	Method   string
	Endpoint string
	Payload  io.Reader
	Headers  http.Header
	Suffix   string
}

APIRequest represents the http api communication way.

func NewAPIRequest

func NewAPIRequest(method string, endpoint string, payload io.Reader) *APIRequest

NewAPIRequest news an APIRequest object.

func (*APIRequest) SetHeader

func (ar *APIRequest) SetHeader(key string, value string) *APIRequest

SetHeader sets http header by passing k,v.

type AWX

type AWX struct {
	PingService             *PingService
	InventoriesService      *InventoriesService
	InventoryUpdatesService *InventoryUpdatesService
	JobService              *JobService
	JobTemplateService      *JobTemplateService
	ProjectService          *ProjectService
	ProjectUpdatesService   *ProjectUpdatesService
	UserService             *UserService
	GroupService            *GroupService
	HostService             *HostService
	// contains filtered or unexported fields
}

AWX represents awx api endpoints with services, and using client to communicate with awx server.

func NewAWX

func NewAWX(baseURL, userName, passwd string, client *http.Client) *AWX

NewAWX news an awx handler with basic auth support, you could customize the http transport by passing custom client.

type ApplyRole

type ApplyRole struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

ApplyRole represents the awx api apply role.

type AssociateGroup added in v0.0.3

type AssociateGroup struct {
	ID        int  `json:"id"`
	Associate bool `json:"associate"`
}

AssociateGroup implement the awx group association request

type BasicAuth

type BasicAuth struct {
	Username string
	Password string
}

BasicAuth represents http basic auth.

type ByUserSummary

type ByUserSummary struct {
	ID        int    `json:"id"`
	Username  string `json:"username"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
}

ByUserSummary represents the awx api user summary fields.

type CancelJobResponse

type CancelJobResponse struct {
	Detail string `json:"detail"`
}

CancelJobResponse represents `CancelJob` endpoint response.

type Client

type Client struct {
	BaseURL   string
	Requester *Requester
}

Client implement http client.

type Credential

type Credential struct {
	Description      string `json:"description"`
	CredentialTypeID int    `json:"credential_type_id"`
	ID               int    `json:"id"`
	Kind             string `json:"kind"`
	Name             string `json:"name"`
}

Credential represents the awx api credential.

type EventData

type EventData struct {
	PlayPattern  string      `json:"play_pattern"`
	Play         string      `json:"play"`
	EventLoop    interface{} `json:"event_loop"`
	TaskArgs     string      `json:"task_args"`
	RemoteAddr   string      `json:"remote_addr"`
	Res          *EventRes   `json:"res"`
	Pid          int         `json:"pid"`
	PlayUUID     string      `json:"play_uuid"`
	TaskUUID     string      `json:"task_uuid"`
	Task         string      `json:"task"`
	PlaybookUUID string      `json:"playbook_uuid"`
	Playbook     string      `json:"playbook"`
	TaskAction   string      `json:"task_action"`
	Host         string      `json:"host"`
	Role         string      `json:"role"`
	TaskPath     string      `json:"task_path"`
}

EventData represents the awx api event data.

type EventInvocation

type EventInvocation struct {
	ModuleArgs *EventModuleArgs `json:"module_args"`
}

EventInvocation represents the awx api event invocation.

type EventModuleArgs

type EventModuleArgs struct {
	Creates    interface{} `json:"creates"`
	Executable interface{} `json:"executable"`
	UsesShell  bool        `json:"_uses_shell"`
	RawParams  string      `json:"_raw_params"`
	Removes    interface{} `json:"removes"`
	Warn       bool        `json:"warn"`
	Chdir      string      `json:"chdir"`
	Stdin      interface{} `json:"stdin"`
}

EventModuleArgs represents the awx api event module args.

type EventRes

type EventRes struct {
	AnsibleParsed bool             `json:"_ansible_parsed"`
	StderrLines   []string         `json:"stderr_lines"`
	Changed       bool             `json:"changed"`
	End           string           `json:"end"`
	AnsibleNoLog  bool             `json:"_ansible_no_log"`
	Stdout        string           `json:"stdout"`
	Cmd           string           `json:"cmd"`
	Start         string           `json:"start"`
	Delta         string           `json:"delta"`
	Stderr        string           `json:"stderr"`
	Rc            int              `json:"rc"`
	Invocation    *EventInvocation `json:"invocation"`
	StdoutLines   []string         `json:"stdout_lines"`
	Warnings      []string         `json:"warnings"`
}

EventRes represents the awx api event response.

type Group added in v0.0.3

type Group struct {
	ID                       int       `json:"id"`
	Type                     int       `json:"type"`
	URL                      string    `json:"url"`
	Related                  *Related  `json:"related"`
	SummaryFields            *Summary  `json:"summary_fields"`
	Created                  time.Time `json:"created"`
	Modified                 time.Time `json:"modified"`
	Name                     string    `json:"name"`
	Description              string    `json:"description"`
	Inventory                int       `json:"inventory"`
	Variables                string    `json:"variables"`
	HasActiveFailures        bool      `json:"has_active_failures"`
	TotalHosts               int       `json:"total_hosts"`
	HostsWithActiveFailures  int       `json:"hosts_with_active_failures"`
	TotalGroups              int       `json:"total_groups"`
	GroupsWithActiveFailures int       `json:"groups_with_active_failures"`
	HasInventorySources      bool      `json:"has_inventory_sources"`
}

Group represents a group

type GroupService added in v0.0.3

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

GroupService implements awx Groups apis.

func (*GroupService) CreateGroup added in v0.0.3

func (g *GroupService) CreateGroup(data map[string]interface{}, params map[string]string) (*Group, error)

CreateGroup creates an awx Group.

func (*GroupService) DeleteGroup added in v0.0.3

func (g *GroupService) DeleteGroup(id int) (*Group, error)

DeleteGroup delete an awx Group.

func (*GroupService) ListGroups added in v0.0.3

func (g *GroupService) ListGroups(params map[string]string) ([]*Group, *ListGroupsResponse, error)

ListGroups shows list of awx Groups.

func (*GroupService) UpdateGroup added in v0.0.3

func (g *GroupService) UpdateGroup(id int, data map[string]interface{}, params map[string]string) (*Group, error)

UpdateGroup update an awx group

type Groups added in v0.0.3

type Groups struct {
	Count   int      `json:"count"`
	Results []Result `json:"results"`
}

Groups represents the awx api hosts group list

type Host added in v0.0.3

type Host struct {
	ID                   int          `json:"id"`
	Type                 string       `json:"type"`
	URL                  string       `json:"url"`
	Related              *Related     `json:"related"`
	SummaryFields        *Summary     `json:"summary_fields"`
	Created              time.Time    `json:"created"`
	Modified             time.Time    `json:"modified"`
	Name                 string       `json:"name"`
	Description          string       `json:"description"`
	Inventory            int          `json:"inventory"`
	Enabled              bool         `json:"enabled"`
	InstanceID           string       `json:"instance_id"`
	Variables            string       `json:"variables"`
	HasActiveFailures    bool         `json:"has_active_failures"`
	HasInventorySources  bool         `json:"has_inventory_sources"`
	LastJob              *Job         `json:"last_job"`
	LastJobHostSummary   *HostSummary `json:"last_job_host_summary"`
	InsightsSystemID     interface{}  `json:"insights_system_id"`
	AnsibleFactsModified interface{}  `json:"ansible_facts_modified"`
}

Host represents a host

type HostService added in v0.0.3

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

HostService implements awx Hosts apis.

func (*HostService) AssociateGroup added in v0.0.3

func (h *HostService) AssociateGroup(id int, data map[string]interface{}, params map[string]string) (*Host, error)

AssociateGroup update an awx Host

func (*HostService) CreateHost added in v0.0.3

func (h *HostService) CreateHost(data map[string]interface{}, params map[string]string) (*Host, error)

CreateHost creates an awx Host.

func (*HostService) DeleteHost added in v0.0.3

func (h *HostService) DeleteHost(id int) (*Host, error)

DeleteHost delete an awx Host.

func (*HostService) DisAssociateGroup added in v0.0.3

func (h *HostService) DisAssociateGroup(id int, data map[string]interface{}, params map[string]string) (*Host, error)

DisAssociateGroup update an awx Host

func (*HostService) ListHosts added in v0.0.3

func (h *HostService) ListHosts(params map[string]string) ([]*Host, *ListHostsResponse, error)

ListHosts shows list of awx Hosts.

func (*HostService) UpdateHost added in v0.0.3

func (h *HostService) UpdateHost(id int, data map[string]interface{}, params map[string]string) (*Host, error)

UpdateHost update an awx Host

type HostSummariesResponse

type HostSummariesResponse struct {
	Pagination
	Results []HostSummary `json:"results"`
}

HostSummariesResponse represents `JobHostSummaries` endpoint response.

type HostSummary

type HostSummary struct {
	ID            int                `json:"id"`
	Type          string             `json:"type"`
	URL           string             `json:"url"`
	Related       *Related           `json:"related"`
	SummaryFields *HostSummaryFields `json:"summary_fields"`
	Created       time.Time          `json:"created"`
	Modified      time.Time          `json:"modified"`
	Job           int                `json:"job"`
	Host          int                `json:"host"`
	HostName      string             `json:"host_name"`
	Changed       int                `json:"changed"`
	Dark          int                `json:"dark"`
	Failures      int                `json:"failures"`
	Ok            int                `json:"ok"`
	Processed     int                `json:"processed"`
	Skipped       int                `json:"skipped"`
	Failed        bool               `json:"failed"`
}

HostSummary represents the awx api host summary.

type HostSummaryFields

type HostSummaryFields struct {
	Role map[string]string `json:"role"`
	Host *HostSummaryHost  `json:"host"`
	Job  *HostSummaryJob   `json:"job"`
}

HostSummaryFields represents the awx api host summary fields.

type HostSummaryHost

type HostSummaryHost struct {
	ID                  int    `json:"id"`
	Name                string `json:"name"`
	Description         string `json:"description"`
	HasActiveFailures   bool   `json:"has_active_failures"`
	HasInventorySources bool   `json:"has_inventory_sources"`
}

HostSummaryHost represents the awx api host summary host fields.

type HostSummaryJob

type HostSummaryJob struct {
	ID              int     `json:"id"`
	Name            string  `json:"name"`
	Description     string  `json:"description"`
	Status          string  `json:"status"`
	Failed          bool    `json:"failed"`
	Elapsed         float64 `json:"elapsed"`
	JobTemplateID   int     `json:"job_template_id"`
	JobTemplateName string  `json:"job_template_name"`
}

HostSummaryJob represents the awx api host summary job fields.

type Instance

type Instance struct {
	Node      string    `json:"node"`
	Heartbeat time.Time `json:"heartbeat"`
	Version   string    `json:"version"`
	Capacity  int       `json:"capacity"`
}

Instance represents the awx api instance.

type InstanceGroup

type InstanceGroup struct {
	Instances []string `json:"instances"`
	Capacity  int      `json:"capacity"`
	Name      string   `json:"name"`
}

InstanceGroup represents the awx api instance group.

type InstanceGroupSummary

type InstanceGroupSummary struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

InstanceGroupSummary represents the awx api instance group summary fields.

type InventoriesService

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

InventoriesService implements awx inventories apis.

func (*InventoriesService) CreateInventory added in v0.0.2

func (i *InventoriesService) CreateInventory(data map[string]interface{}, params map[string]string) (*Inventory, error)

CreateInventory creates an awx inventory.

func (*InventoriesService) DeleteInventory added in v0.0.3

func (i *InventoriesService) DeleteInventory(id int) (*Inventory, error)

DeleteInventory delete an inventory from AWX

func (*InventoriesService) GetInventory added in v0.0.3

func (i *InventoriesService) GetInventory(id int, params map[string]string) (*Inventory, error)

GetInventory retrives the inventory information from its ID or Name

func (*InventoriesService) ListInventories

func (i *InventoriesService) ListInventories(params map[string]string) ([]*Inventory, *ListInventoriesResponse, error)

ListInventories shows list of awx inventories.

func (*InventoriesService) SyncInventorySourcesByInventoryID added in v0.0.3

func (i *InventoriesService) SyncInventorySourcesByInventoryID(id int) ([]*InventoryUpdate, error)

func (*InventoriesService) UpdateInventory added in v0.0.3

func (i *InventoriesService) UpdateInventory(id int, data map[string]interface{}, params map[string]string) (*Inventory, error)

UpdateInventory update an awx inventory

type Inventory

type Inventory struct {
	ID                           int         `json:"id"`
	Type                         string      `json:"type"`
	URL                          string      `json:"url"`
	Related                      *Related    `json:"related"`
	SummaryFields                *Summary    `json:"summary_fields"`
	Created                      time.Time   `json:"created"`
	Modified                     time.Time   `json:"modified"`
	Name                         string      `json:"name"`
	Description                  string      `json:"description"`
	Organization                 int         `json:"organization"`
	OrganizationID               int         `json:"organization_id"`
	Kind                         string      `json:"kind"`
	HostFilter                   interface{} `json:"host_filter"`
	Variables                    string      `json:"variables"`
	HasActiveFailures            bool        `json:"has_active_failures"`
	TotalHosts                   int         `json:"total_hosts"`
	HostsWithActiveFailures      int         `json:"hosts_with_active_failures"`
	TotalGroups                  int         `json:"total_groups"`
	GroupsWithActiveFailures     int         `json:"groups_with_active_failures"`
	HasInventorySources          bool        `json:"has_inventory_sources"`
	TotalInventorySources        int         `json:"total_inventory_sources"`
	InventorySourcesWithFailures int         `json:"inventory_sources_with_failures"`
	InsightsCredential           interface{} `json:"insights_credential"`
	PendingDeletion              bool        `json:"pending_deletion"`
}

Inventory represents the awx api inventory.

type InventorySource added in v0.0.3

type InventorySource struct {
	Source      string    `json:"source"`
	LastUpdated time.Time `json:"last_updated"`
	Status      string    `json:"status"`
}

type InventoryUpdate added in v0.0.3

type InventoryUpdate struct {
	InventorySource         int         `json:"inventory_source"`
	Status                  string      `json:"status"`
	ID                      int         `json:"id"`
	Type                    string      `json:"type"`
	URL                     string      `json:"url"`
	Related                 *Related    `json:"related"`
	SummaryFields           *Summary    `json:"summary_fields"`
	Created                 time.Time   `json:"created"`
	Modified                time.Time   `json:"modified"`
	Name                    string      `json:"name"`
	Description             string      `json:"description"`
	Source                  string      `json:"source"`
	SourcePath              string      `json:"source_path"`
	SourceScript            interface{} `json:"source_script"`
	SourceVars              string      `json:"source_vars"`
	Credential              interface{} `json:"credential"`
	EnabledVar              string      `json:"enabled_var"`
	EnabledValue            string      `json:"enabled_value"`
	HostFilter              string      `json:"host_filter"`
	Overwrite               bool        `json:"overwrite"`
	OverwriteVars           bool        `json:"overwrite_vars"`
	CustomVirtualenv        interface{} `json:"custom_virtualenv"`
	Timeout                 int         `json:"timeout"`
	Verbosity               int         `json:"verbosity"`
	UnifiedJobTemplate      int         `json:"unified_job_template"`
	LaunchType              string      `json:"launch_type"`
	Failed                  bool        `json:"failed"`
	Started                 interface{} `json:"started"`
	Finished                interface{} `json:"finished"`
	CanceledOn              interface{} `json:"canceled_on"`
	Elapsed                 float64     `json:"elapsed"`
	JobArgs                 string      `json:"job_args"`
	JobCwd                  string      `json:"job_cwd"`
	JobEnv                  interface{} `json:"job_env"`
	JobExplanation          string      `json:"job_explanation"`
	ExecutionNode           string      `json:"execution_node"`
	ResultTraceback         string      `json:"result_traceback"`
	EventProcessingFinished bool        `json:"event_processing_finished"`
	Inventory               int         `json:"inventory"`
	LicenseError            bool        `json:"license_error"`
	OrgHostLimitError       bool        `json:"org_host_limit_error"`
	SourceProjectUpdate     interface{} `json:"source_project_update"`
	SourceProject           interface{} `json:"source_project"`
	InventoryUpdate         int         `json:"inventory_update"`
}

InventoryUpdate represents the awx api inventory update.

type InventoryUpdatesService added in v0.0.3

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

InventoryUpdateService implements awx inventory_update apis.

func (*InventoryUpdatesService) GetInventoryUpdate added in v0.0.3

func (i *InventoryUpdatesService) GetInventoryUpdate(id int, params map[string]string) (*InventoryUpdate, error)

GetInventoryUpdate retrives the inventory_update information from its ID or Name

type Job

type Job struct {
	ID                      int               `json:"id"`
	Type                    string            `json:"type"`
	URL                     string            `json:"url"`
	Related                 *Related          `json:"related"`
	SummaryFields           *Summary          `json:"summary_fields"`
	Created                 time.Time         `json:"created"`
	Modified                time.Time         `json:"modified"`
	Name                    string            `json:"name"`
	Description             string            `json:"description"`
	JobType                 string            `json:"job_type"`
	Inventory               int               `json:"inventory"`
	Project                 int               `json:"project"`
	Playbook                string            `json:"playbook"`
	Forks                   int               `json:"forks"`
	Limit                   string            `json:"limit"`
	Verbosity               int               `json:"verbosity"`
	ExtraVars               string            `json:"extra_vars"`
	JobTags                 string            `json:"job_tags"`
	ForceHandlers           bool              `json:"force_handlers"`
	SkipTags                string            `json:"skip_tags"`
	StartAtTask             string            `json:"start_at_task"`
	Timeout                 int               `json:"timeout"`
	UseFactCache            bool              `json:"use_fact_cache"`
	UnifiedJobTemplate      int               `json:"unified_job_template"`
	LaunchType              string            `json:"launch_type"`
	Status                  string            `json:"status"`
	Failed                  bool              `json:"failed"`
	Started                 time.Time         `json:"started"`
	Finished                time.Time         `json:"finished"`
	Elapsed                 float64           `json:"elapsed"`
	JobArgs                 string            `json:"job_args"`
	JobCwd                  string            `json:"job_cwd"`
	JobEnv                  map[string]string `json:"job_env"`
	JobExplanation          string            `json:"job_explanation"`
	ExecutionNode           string            `json:"execution_node"`
	ResultTraceback         string            `json:"result_traceback"`
	EventProcessingFinished bool              `json:"event_processing_finished"`
	JobTemplate             int               `json:"job_template"`
	PasswordsNeededToStart  []interface{}     `json:"passwords_needed_to_start"`
	AskDiffModeOnLaunch     bool              `json:"ask_diff_mode_on_launch"`
	AskVariablesOnLaunch    bool              `json:"ask_variables_on_launch"`
	AskLimitOnLaunch        bool              `json:"ask_limit_on_launch"`
	AskTagsOnLaunch         bool              `json:"ask_tags_on_launch"`
	AskSkipTagsOnLaunch     bool              `json:"ask_skip_tags_on_launch"`
	AskJobTypeOnLaunch      bool              `json:"ask_job_type_on_launch"`
	AskVerbosityOnLaunch    bool              `json:"ask_verbosity_on_launch"`
	AskInventoryOnLaunch    bool              `json:"ask_inventory_on_launch"`
	AskCredentialOnLaunch   bool              `json:"ask_credential_on_launch"`
	AllowSimultaneous       bool              `json:"allow_simultaneous"`
	Artifacts               map[string]string `json:"artifacts"`
	ScmRevision             string            `json:"scm_revision"`
	InstanceGroup           int               `json:"instance_group"`
	DiffMode                bool              `json:"diff_mode"`
	Credential              *Credential       `json:"credential"`
	VaultCredential         interface{}       `json:"vault_credential"`
}

Job represents the awx api job.

type JobEvent

type JobEvent struct {
	ID            int                `json:"id"`
	Type          string             `json:"type"`
	URL           string             `json:"url"`
	Related       *Related           `json:"related"`
	SummaryFields *HostSummaryFields `json:"summary_fields"`
	Created       time.Time          `json:"created"`
	Modified      time.Time          `json:"modified"`
	Job           int                `json:"job"`
	Event         string             `json:"event"`
	Counter       int                `json:"counter"`
	EventDisplay  string             `json:"event_display"`
	EventData     *EventData         `json:"event_data"`
	EventLevel    int                `json:"event_level"`
	Failed        bool               `json:"failed"`
	Changed       bool               `json:"changed"`
	UUID          string             `json:"uuid"`
	ParentUUID    string             `json:"parent_uuid"`

	// FIXME: inconsistent value type from tower API, int, null
	Host interface{} `json:"host"`

	HostName  string      `json:"host_name"`
	Parent    interface{} `json:"parent"`
	Playbook  string      `json:"playbook"`
	Play      string      `json:"play"`
	Task      string      `json:"task"`
	Role      string      `json:"role"`
	Stdout    string      `json:"stdout"`
	StartLine int         `json:"start_line"`
	EndLine   int         `json:"end_line"`
	Verbosity int         `json:"verbosity"`
}

JobEvent represents the awx api job event.

type JobEventsResponse

type JobEventsResponse struct {
	Pagination
	Results []JobEvent `json:"results"`
}

JobEventsResponse represents `JobEvents` endpoint response.

type JobLaunch

type JobLaunch struct {
	Job                     int               `json:"job"`
	IgnoredFields           map[string]string `json:"ignored_fields"`
	ID                      int               `json:"id"`
	Type                    string            `json:"type"`
	URL                     string            `json:"url"`
	Related                 *Related          `json:"related"`
	SummaryFields           *Summary          `json:"summary_fields"`
	Created                 time.Time         `json:"created"`
	Modified                time.Time         `json:"modified"`
	Name                    string            `json:"name"`
	Description             string            `json:"description"`
	JobType                 string            `json:"job_type"`
	Inventory               int               `json:"inventory"`
	Project                 int               `json:"project"`
	Playbook                string            `json:"playbook"`
	Forks                   int               `json:"forks"`
	Limit                   string            `json:"limit"`
	Verbosity               int               `json:"verbosity"`
	ExtraVars               string            `json:"extra_vars"`
	JobTags                 string            `json:"job_tags"`
	ForceHandlers           bool              `json:"force_handlers"`
	SkipTags                string            `json:"skip_tags"`
	StartAtTask             string            `json:"start_at_task"`
	Timeout                 int               `json:"timeout"`
	UseFactCache            bool              `json:"use_fact_cache"`
	UnifiedJobTemplate      int               `json:"unified_job_template"`
	LaunchType              string            `json:"launch_type"`
	Status                  string            `json:"status"`
	Failed                  bool              `json:"failed"`
	Started                 interface{}       `json:"started"`
	Finished                interface{}       `json:"finished"`
	Elapsed                 int               `json:"elapsed"`
	JobArgs                 string            `json:"job_args"`
	JobCwd                  string            `json:"job_cwd"`
	JobEnv                  map[string]string `json:"job_env"`
	JobExplanation          string            `json:"job_explanation"`
	ExecutionNode           string            `json:"execution_node"`
	ResultTraceback         string            `json:"result_traceback"`
	EventProcessingFinished bool              `json:"event_processing_finished"`
	JobTemplate             int               `json:"job_template"`
	PasswordsNeededToStart  []interface{}     `json:"passwords_needed_to_start"`
	AskDiffModeOnLaunch     bool              `json:"ask_diff_mode_on_launch"`
	AskVariablesOnLaunch    bool              `json:"ask_variables_on_launch"`
	AskLimitOnLaunch        bool              `json:"ask_limit_on_launch"`
	AskTagsOnLaunch         bool              `json:"ask_tags_on_launch"`
	AskSkipTagsOnLaunch     bool              `json:"ask_skip_tags_on_launch"`
	AskJobTypeOnLaunch      bool              `json:"ask_job_type_on_launch"`
	AskVerbosityOnLaunch    bool              `json:"ask_verbosity_on_launch"`
	AskInventoryOnLaunch    bool              `json:"ask_inventory_on_launch"`
	AskCredentialOnLaunch   bool              `json:"ask_credential_on_launch"`
	AllowSimultaneous       bool              `json:"allow_simultaneous"`
	Artifacts               map[string]string `json:"artifacts"`
	ScmRevision             string            `json:"scm_revision"`
	InstanceGroup           interface{}       `json:"instance_group"`
	DiffMode                bool              `json:"diff_mode"`
	Credential              int               `json:"credential"`
	VaultCredential         interface{}       `json:"vault_credential"`
}

JobLaunch represents the awx api job launch.

type JobService

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

JobService implements awx job apis.

func (*JobService) CancelJob

func (j *JobService) CancelJob(id int, data map[string]interface{}, params map[string]string) (*CancelJobResponse, error)

CancelJob cancels a job.

func (*JobService) GetHostSummaries

func (j *JobService) GetHostSummaries(id int, params map[string]string) ([]HostSummary, *HostSummariesResponse, error)

GetHostSummaries get a job hosts summaries.

func (*JobService) GetJob

func (j *JobService) GetJob(id int, params map[string]string) (*Job, error)

GetJob shows the details of a job.

func (*JobService) GetJobEvents

func (j *JobService) GetJobEvents(id int, params map[string]string) ([]JobEvent, *JobEventsResponse, error)

GetJobEvents get a list of job events.

func (*JobService) RelaunchJob

func (j *JobService) RelaunchJob(id int, data map[string]interface{}, params map[string]string) (*JobLaunch, error)

RelaunchJob relaunch a job.

type JobTemplate

type JobTemplate struct {
	ID                    int         `json:"id"`
	Type                  string      `json:"type"`
	URL                   string      `json:"url"`
	Related               *Related    `json:"related"`
	SummaryFields         *Summary    `json:"summary_fields"`
	Created               time.Time   `json:"created"`
	Modified              time.Time   `json:"modified"`
	Name                  string      `json:"name"`
	Description           string      `json:"description"`
	JobType               string      `json:"job_type"`
	Inventory             int         `json:"inventory"`
	Project               int         `json:"project"`
	Playbook              string      `json:"playbook"`
	Forks                 int         `json:"forks"`
	Limit                 string      `json:"limit"`
	Verbosity             int         `json:"verbosity"`
	ExtraVars             string      `json:"extra_vars"`
	JobTags               string      `json:"job_tags"`
	ForceHandlers         bool        `json:"force_handlers"`
	SkipTags              string      `json:"skip_tags"`
	StartAtTask           string      `json:"start_at_task"`
	Timeout               int         `json:"timeout"`
	UseFactCache          bool        `json:"use_fact_cache"`
	LastJobRun            interface{} `json:"last_job_run"`
	LastJobFailed         bool        `json:"last_job_failed"`
	NextJobRun            interface{} `json:"next_job_run"`
	Status                string      `json:"status"`
	HostConfigKey         string      `json:"host_config_key"`
	AskDiffModeOnLaunch   bool        `json:"ask_diff_mode_on_launch"`
	AskVariablesOnLaunch  bool        `json:"ask_variables_on_launch"`
	AskLimitOnLaunch      bool        `json:"ask_limit_on_launch"`
	AskTagsOnLaunch       bool        `json:"ask_tags_on_launch"`
	AskSkipTagsOnLaunch   bool        `json:"ask_skip_tags_on_launch"`
	AskJobTypeOnLaunch    bool        `json:"ask_job_type_on_launch"`
	AskVerbosityOnLaunch  bool        `json:"ask_verbosity_on_launch"`
	AskInventoryOnLaunch  bool        `json:"ask_inventory_on_launch"`
	AskCredentialOnLaunch bool        `json:"ask_credential_on_launch"`
	SurveyEnabled         bool        `json:"survey_enabled"`
	BecomeEnabled         bool        `json:"become_enabled"`
	DiffMode              bool        `json:"diff_mode"`
	AllowSimultaneous     bool        `json:"allow_simultaneous"`
	CustomVirtualenv      interface{} `json:"custom_virtualenv"`
	Credential            int         `json:"credential"`
	VaultCredential       interface{} `json:"vault_credential"`
}

JobTemplate represents the awx api job template.

type JobTemplateService

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

JobTemplateService implements awx job template apis.

func (*JobTemplateService) CreateJobTemplate added in v0.0.3

func (jt *JobTemplateService) CreateJobTemplate(data map[string]interface{}, params map[string]string) (*JobTemplate, error)

CreateJobTemplate creates a job template

func (*JobTemplateService) DeleteJobTemplate added in v0.0.3

func (jt *JobTemplateService) DeleteJobTemplate(id int) (*JobTemplate, error)

DeleteJobTemplate deletes a job template

func (*JobTemplateService) Launch

func (jt *JobTemplateService) Launch(id int, data map[string]interface{}, params map[string]string) (*JobLaunch, error)

Launch lauchs a job with the job template.

func (*JobTemplateService) ListJobTemplates

func (jt *JobTemplateService) ListJobTemplates(params map[string]string) ([]*JobTemplate, *ListJobTemplatesResponse, error)

ListJobTemplates shows a list of job templates.

func (*JobTemplateService) UpdateJobTemplate added in v0.0.3

func (jt *JobTemplateService) UpdateJobTemplate(id int, data map[string]interface{}, params map[string]string) (*JobTemplate, error)

UpdateJobTemplate updates a job template

type JobTemplateSummary

type JobTemplateSummary struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

JobTemplateSummary represents the awx api job template summary fields.

type Labels

type Labels struct {
	Count   int           `json:"count"`
	Results []interface{} `json:"results"`
}

Labels represents the awx api labels.

type ListGroupsResponse added in v0.0.3

type ListGroupsResponse struct {
	Pagination
	Results []*Group `json:"results"`
}

ListGroupsResponse represents `ListGroups` endpoint response.

type ListHostsResponse added in v0.0.3

type ListHostsResponse struct {
	Pagination
	Results []*Host `json:"results"`
}

ListHostsResponse represents `ListHosts` endpoint response.

type ListInventoriesResponse

type ListInventoriesResponse struct {
	Pagination
	Results []*Inventory `json:"results"`
}

ListInventoriesResponse represents `ListInventories` endpoint response.

type ListJobTemplatesResponse

type ListJobTemplatesResponse struct {
	Pagination
	Results []*JobTemplate `json:"results"`
}

ListJobTemplatesResponse represents `ListJobTemplates` endpoint response.

type ListProjectsResponse added in v0.0.3

type ListProjectsResponse struct {
	Pagination
	Results []*Project `json:"results"`
}

ListProjectsResponse represents `ListProjects` endpoint response.

type ListUsersResponse added in v0.0.3

type ListUsersResponse struct {
	Pagination
	Results []*User `json:"results"`
}

ListUsersResponse represents `ListUsers` endpoint response.

type ObjectRoles

type ObjectRoles struct {
	UseRole     *ApplyRole `json:"use_role"`
	AdminRole   *ApplyRole `json:"admin_role"`
	AdhocRole   *ApplyRole `json:"adhoc_role"`
	UpdateRole  *ApplyRole `json:"update_role"`
	ReadRole    *ApplyRole `json:"read_role"`
	ExecuteRole *ApplyRole `json:"execute_role"`
}

ObjectRoles represents the awx api object roles.

type OrgnizationSummary

type OrgnizationSummary struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

OrgnizationSummary represents the awx api orgnization summary fields.

type Pagination

type Pagination struct {
	Count    int         `json:"count"`
	Next     interface{} `json:"next"`
	Previous interface{} `json:"previous"`
}

Pagination represents the awx api pagination params.

type Ping

type Ping struct {
	Instances      []Instance      `json:"instances"`
	InstanceGroups []InstanceGroup `json:"instance_groups"`
	Ha             bool            `json:"ha"`
	Version        string          `json:"version"`
	ActiveNode     string          `json:"active_node"`
}

Ping represents the awx api ping.

type PingService

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

PingService implements awx ping apis.

func (*PingService) Ping

func (p *PingService) Ping() (*Ping, error)

Ping do ping with awx servers.

type Project

type Project struct {
	ID                    int       `json:"id"`
	Type                  string    `json:"type"`
	URL                   string    `json:"url"`
	Related               *Related  `json:"related"`
	SummaryFields         *Summary  `json:"summary_fields"`
	Created               time.Time `json:"created"`
	Modified              time.Time `json:"modified"`
	Name                  string    `json:"name"`
	Description           string    `json:"description"`
	LocalPath             string    `json:"local_path"`
	ScmType               string    `json:"scm_type"`
	ScmURL                string    `json:"scm_url"`
	ScmBranch             string    `json:"scm_branch"`
	ScmClean              bool      `json:"scm_clean"`
	ScmDeleteOnUpdate     bool      `json:"scm_delete_on_update"`
	Credential            string    `json:"credential"`
	Timeout               int       `json:"timeout"`
	LastJobRun            time.Time `json:"last_job_run"`
	LastJobFailed         bool      `json:"last_job_failed"`
	NextJobRun            time.Time `json:"next_job_run"`
	Status                string    `json:"status"`
	Organization          int       `json:"organization"`
	ScmDeleteOnNextUpdate bool      `json:"scm_delete_on_next_update"`
	ScmUpdateOnLaunch     bool      `json:"scm_update_on_launch"`
	ScmUpdateCacheTimeout int       `json:"scm_update_cache_timeout"`
	ScmRevision           string    `json:"scm_revision"`
	LastUpdateFailed      bool      `json:"last_update_failed"`
	LastUpdated           time.Time `json:"last_updated"`
}

Project represents the awx api project.

type ProjectService added in v0.0.3

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

ProjectService implements awx projects apis.

func (*ProjectService) CreateProject added in v0.0.3

func (p *ProjectService) CreateProject(data map[string]interface{}, params map[string]string) (*Project, error)

CreateProject creates an awx project.

func (*ProjectService) DeleteProject added in v0.0.3

func (p *ProjectService) DeleteProject(id int) (*Project, error)

DeleteProject delete an awx Project.

func (*ProjectService) ListProjects added in v0.0.3

func (p *ProjectService) ListProjects(params map[string]string) ([]*Project, *ListProjectsResponse, error)

ListProjects shows list of awx projects.

func (*ProjectService) UpdateProject added in v0.0.3

func (p *ProjectService) UpdateProject(id int, data map[string]interface{}, params map[string]string) (*Project, error)

UpdateProject update an awx Project.

type ProjectUpdate

type ProjectUpdate struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Status      string `json:"status"`
	Failed      bool   `json:"failed"`
}

ProjectUpdate represents the awx api project update.

type ProjectUpdateCancel added in v0.0.3

type ProjectUpdateCancel struct {
	CanCancel bool `json:"can_cancel"`
}

ProjectUpdateCancel represents the awx project update cancel api response.

type ProjectUpdatesService added in v0.0.3

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

ProjectUpdatesService implements awx projects apis.

func (*ProjectUpdatesService) ProjectUpdateCancel added in v0.0.3

func (p *ProjectUpdatesService) ProjectUpdateCancel(id int) (*ProjectUpdateCancel, error)

ProjectUpdateCancel cancel of awx projects update.

func (*ProjectUpdatesService) ProjectUpdateGet added in v0.0.3

func (p *ProjectUpdatesService) ProjectUpdateGet(id int) (*Job, error)

ProjectUpdateGet get of awx projects update.

type Related struct {
	NamedURL                     string `json:"named_url"`
	CreatedBy                    string `json:"created_by"`
	ModifiedBy                   string `json:"modified_by"`
	JobTemplates                 string `json:"job_templates"`
	VariableData                 string `json:"variable_data"`
	RootGroups                   string `json:"root_groups"`
	ObjectRoles                  string `json:"object_roles"`
	AdHocCommands                string `json:"ad_hoc_commands"`
	Script                       string `json:"script"`
	Tree                         string `json:"tree"`
	AccessList                   string `json:"access_list"`
	ActivityStream               string `json:"activity_stream"`
	InstanceGroups               string `json:"instance_groups"`
	Hosts                        string `json:"hosts"`
	Job                          string `json:"job"`
	Host                         string `json:"host"`
	Groups                       string `json:"groups"`
	Copy                         string `json:"copy"`
	UpdateInventorySources       string `json:"update_inventory_sources"`
	InventorySources             string `json:"inventory_sources"`
	InventorySource              string `json:"inventory_source"`
	FactVersions                 string `json:"fact_versions"`
	SmartInventories             string `json:"smart_inventories"`
	Insights                     string `json:"insights"`
	Organization                 string `json:"organization"`
	Labels                       string `json:"labels"`
	Inventory                    string `json:"inventory"`
	Project                      string `json:"project"`
	Credential                   string `json:"credential"`
	ExtraCredentials             string `json:"extra_credentials"`
	Credentials                  string `json:"credentials"`
	NotificationTemplatesError   string `json:"notification_templates_error"`
	NotificationTemplatesSuccess string `json:"notification_templates_success"`
	Jobs                         string `json:"jobs"`
	NotificationTemplatesAny     string `json:"notification_templates_any"`
	Launch                       string `json:"launch"`
	Schedules                    string `json:"schedules"`
	SurveySpec                   string `json:"survey_spec"`
	UnifiedJobTemplate           string `json:"unified_job_template"`
	Stdout                       string `json:"stdout"`
	Notifications                string `json:"notifications"`
	JobHostSummaries             string `json:"job_host_summaries"`
	JobEvents                    string `json:"job_events"`
	JobTemplate                  string `json:"job_template"`
	Cancel                       string `json:"cancel"`
	ProjectUpdate                string `json:"project_update"`
	CreateSchedule               string `json:"create_schedule"`
	Relaunch                     string `json:"relaunch"`
	AdminOfOrganizations         string `json:"admin_of_organizations"`
	Organizations                string `json:"organizations"`
	Roles                        string `json:"roles"`
	Teams                        string `json:"teams"`
	Projects                     string `json:"projects"`
	PotentialChildren            string `json:"potential_children"`
	AllHosts                     string `json:"all_hosts"`
	AllGroups                    string `json:"all_groups"`
	AdHocCommandEvents           string `json:"ad_hoc_command_events"`
	Children                     string `json:"children"`
	AnsibleFacts                 string `json:"ansible_facts"`
	Events                       string `json:"events"`
}

Related represents the awx api related field.

type Requester

type Requester struct {
	Base      string
	BasicAuth *BasicAuth
	Client    *http.Client
}

Requester implemented a base http client. It supports do POST/GET via an human-readable way, in other word, all data is in `application/json` format. It also originally supports basic auth. For production usage, It would be better to wrapper an another rest client on this requester.

func (*Requester) Delete added in v0.0.3

func (r *Requester) Delete(endpoint string, responseStruct interface{}, querystring map[string]string) (*http.Response, error)

Delete performs http Delete request.

func (*Requester) Do

func (r *Requester) Do(ar *APIRequest, responseStruct interface{}, options ...interface{}) (*http.Response, error)

Do do the actual http request.

func (*Requester) Get

func (r *Requester) Get(endpoint string, responseStruct interface{}, querystring map[string]string) (*http.Response, error)

Get performs http get request.

func (*Requester) GetJSON

func (r *Requester) GetJSON(endpoint string, responseStruct interface{}, query map[string]string) (*http.Response, error)

GetJSON performs http get request with json response.

func (*Requester) PatchJSON added in v0.0.3

func (r *Requester) PatchJSON(endpoint string, payload io.Reader, responseStruct interface{}, querystring map[string]string) (*http.Response, error)

PatchJSON perform http patch request with json response

func (*Requester) Post

func (r *Requester) Post(endpoint string, payload io.Reader, responseStruct interface{}, querystring map[string]string) (*http.Response, error)

Post performs http post request.

func (*Requester) PostJSON

func (r *Requester) PostJSON(endpoint string, payload io.Reader, responseStruct interface{}, querystring map[string]string) (*http.Response, error)

PostJSON performs http post request with json response.

func (*Requester) PutJSON added in v0.0.3

func (r *Requester) PutJSON(endpoint string, payload io.Reader, responseStruct interface{}, querystring map[string]string) (*http.Response, error)

PutJSON perform http PUT request with json response

func (*Requester) ReadJSONResponse

func (r *Requester) ReadJSONResponse(response *http.Response, responseStruct interface{}) (*http.Response, error)

ReadJSONResponse reads the http raw response and decodes into json.

func (*Requester) ReadRawResponse

func (r *Requester) ReadRawResponse(response *http.Response, responseStruct interface{}) (*http.Response, error)

ReadRawResponse reads the http raw response and store it into `responseStruct`.

type Result added in v0.0.3

type Result struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

Result data type

type Summary

type Summary struct {
	InstanceGroup      *InstanceGroupSummary  `json:"instance_group"`
	Organization       *OrgnizationSummary    `json:"organization"`
	CreatedBy          *ByUserSummary         `json:"created_by"`
	ModifiedBy         *ByUserSummary         `json:"modified_by"`
	ObjectRoles        *ObjectRoles           `json:"object_roles"`
	UserCapabilities   *UserCapabilities      `json:"user_capabilities"`
	Project            *Project               `json:"project"`
	LastJob            map[string]interface{} `json:"last_job"`
	CurrentJob         map[string]interface{} `json:"current_job"`
	LastUpdate         map[string]interface{} `json:"last_update"`
	Inventory          *Inventory             `json:"inventory"`
	RecentJobs         []interface{}          `json:"recent_jobs"`
	Groups             *Groups                `json:"groups"`
	Credentials        []Credential           `json:"credentials"`
	Credential         *Credential            `json:"credential"`
	Labels             *Labels                `json:"labels"`
	JobTemplate        *JobTemplateSummary    `json:"job_template"`
	UnifiedJobTemplate *UnifiedJobTemplate    `json:"unified_job_template"`
	ExtraCredentials   []interface{}          `json:"extra_credentials"`
	ProjectUpdate      *ProjectUpdate         `json:"project_update"`
	InventorySource    *InventorySource       `json:"inventory_source"`
}

Summary represents the awx api summary fields.

type UnifiedJobTemplate

type UnifiedJobTemplate struct {
	ID             int    `json:"id"`
	Name           string `json:"name"`
	Description    string `json:"description"`
	UnifiedJobType string `json:"unified_job_type"`
}

UnifiedJobTemplate represents the awx api unified job template.

type User added in v0.0.3

type User struct {
	ID              int         `json:"id"`
	Type            int         `json:"type"`
	URL             string      `json:"url"`
	Related         *Related    `json:"related"`
	SummaryFields   *Summary    `json:"summary_fields"`
	Created         time.Time   `json:"created"`
	Username        string      `json:"username"`
	FirstName       string      `json:"first_name"`
	LastName        string      `json:"last_name"`
	Email           string      `json:"email"`
	IsSuperUser     bool        `json:"is_superuser"`
	IsSystemAuditor bool        `json:"is_system_auditor"`
	Password        string      `json:"password"`
	LdapDn          string      `json:"ldap_dn"`
	ExternalAccount interface{} `json:"external_account"`
}

User represents an user

type UserCapabilities

type UserCapabilities struct {
	Edit     bool `json:"edit"`
	Start    bool `json:"start"`
	Schedule bool `json:"schedule"`
	Copy     bool `json:"copy"`
	Adhoc    bool `json:"adhoc"`
	Delete   bool `json:"delete"`
}

UserCapabilities represents the awx api user capabilities.

type UserService added in v0.0.3

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

UserService implements awx Users apis.

func (*UserService) CreateUser added in v0.0.3

func (u *UserService) CreateUser(data map[string]interface{}, params map[string]string) (*User, error)

CreateUser creates an awx User.

func (*UserService) DeleteUser added in v0.0.3

func (u *UserService) DeleteUser(id int) (*User, error)

DeleteUser delete an awx User.

func (*UserService) ListUsers added in v0.0.3

func (u *UserService) ListUsers(params map[string]string) ([]*User, *ListUsersResponse, error)

ListUsers shows list of awx Users.

func (*UserService) UpdateUser added in v0.0.3

func (u *UserService) UpdateUser(id int, data map[string]interface{}, params map[string]string) (*User, error)

UpdateUser update an awx user.

Directories

Path Synopsis
awxtesting

Jump to

Keyboard shortcuts

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