Documentation ¶
Index ¶
- Constants
- Variables
- func PopulateStruct(j *Result, s interface{}) (err error)
- func WaitForJob(jobPath string) error
- type AndQuery
- type JobState
- type Location
- type OrQuery
- type Query
- type QueryFields
- type QueryType
- type Result
- func (r *Result) Count() (int, error)
- func (r *Result) Elements() ([]*Result, error)
- func (r *Result) Error() error
- func (r *Result) Get(method string, params ...interface{}) (*Result, error)
- func (r *Result) GetProperty(property string) (*Result, error)
- func (r *Result) GetText(i int) (string, error)
- func (r *Result) ItemAtIndex(i int) (*Result, error)
- func (r *Result) Path() (string, error)
- func (r *Result) Raw() *ole.VARIANT
- func (r *Result) Set(property string, params ...interface{}) error
- func (r *Result) ToArray() *ole.SafeArrayConversion
- func (r *Result) Value() interface{}
- type WMI
- func (w *WMI) Close()
- func (w *WMI) ExecMethod(params ...interface{}) (*Result, error)
- func (w *WMI) Get(params ...interface{}) (*Result, error)
- func (w *WMI) GetOne(resource string, fields []string, qParams []Query) (*Result, error)
- func (w *WMI) Gwmi(resource string, fields []string, qParams []Query) (*Result, error)
Constants ¶
const ( JobStatusStarted = 4096 JobStatusRunning = 4 JobStateCompleted = 7 )
WMI job statuses
Variables ¶
var ErrNotFound = errors.New("Query returned empty set")
ErrNotFound is returned when the query yielded no results
Functions ¶
func PopulateStruct ¶
PopulateStruct populates the fields of the supplied struct with values received form a Result. Care must be taken when declaring the struct. It must match the types returned by WMI.
func WaitForJob ¶
WaitForJob will wait for a WMI job to complete
Types ¶
type JobState ¶
type JobState struct { Name string Description string ElementName string ErrorCode int32 ErrorDescription string InstanceID string JobRunTimes int32 JobState int32 JobStatus string JobType int32 }
JobState represents a WMI job that was run. This type exposes a subset of the information available in CIM_ConcreteJob https://msdn.microsoft.com/en-us/library/cc136808%28v=vs.85%29.aspx
func NewJobState ¶
NewJobState returns a new Jobstate, given a path
type Location ¶
type Location struct { // Server represents the server on which this query should be run Server string // Namespace represents the namespace in which to run the query Namespace string // Class represents the class against which to run the query Class string // Params is a map of parameters to filter Params map[string]string }
Location contains the parsed fields of a __PATH
func NewLocation ¶
NewLocation returns a *Location object
func (*Location) QueryParams ¶
QueryParams returns a []Query from the params present in the location string
type QueryFields ¶
QueryFields is a helper structure that enables us to build queries
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result holds the raw WMI result of a query
func NewWMIObject ¶
NewWMIObject returns a new *Result from a path
func (*Result) Get ¶
Get will execute a method on the WMI object held in *Result, with the given params
func (*Result) GetProperty ¶
GetProperty will return a *Result holding a given property
func (*Result) ItemAtIndex ¶
ItemAtIndex returns the result of the ItemIndex WMI call on a raw WMI result object
type WMI ¶
WMI represents a WMI connection object
func NewConnection ¶
NewConnection returns a new *WMI connection, given the parameters
func NewStandardCimV2Connection ¶
NewStandardCimV2Connection returns a new WMI connection to the Root\StandardCimv2 namespace.
func (*WMI) Close ¶
func (w *WMI) Close()
Close will close the WMI connection and release all resources.
func (*WMI) ExecMethod ¶
ExecMethod wraps the WMI ExecMethod call and returns a *Result