snipeit
Explore the following sections to learn more:
snipeit
import "github.com/gemini-oss/rego/pkg/snipeit"
pkg/snipeit/accessories.go
pkg/snipeit/assets.go
pkg/snipeit/categories.go
pkg/snipeit/entities.go
pkg/snipeit/licenses.go
pkg/snipeit/accessories.go
pkg/snipeit/snipeit.go
Index
- Constants
- Variables
- type Accessory
- type AccessoryClient
- type AccessoryList
- type AccessoryQuery
- type AssetClient
- func (c *AssetClient) CreateAsset(p *Hardware[HardwarePOST]) (*Hardware[HardwarePOST], error)
- func (c *AssetClient) DeleteAsset(id int64) (string, error)
- func (c *AssetClient) GetAllAssets() (*HardwareList, error)
- func (c *AssetClient) GetAssetBySerial(serial string) (*Hardware[HardwareGET], error)
- func (c *AssetClient) GetAssetByTag(tag string) (*Hardware[HardwareGET], error)
- func (c *AssetClient) PartialUpdateAsset(id uint32, h *Hardware[HardwarePUTPATCH]) (*Hardware[HardwarePUTPATCH], error)
- type AssetQuery
- type AvailableActions
- type Category
- type CategoryBase
- type CategoryClient
- type CategoryGET
- type CategoryList
- type CategoryPOST
- type CategoryQuery
- type Client
- func NewClient(verbosity int) *Client
- func (c *Client) Accessories() *AccessoryClient
- func (c *Client) Assets() *AssetClient
- func (c *Client) BuildURL(endpoint string, identifiers …interface{}) string
- func (c *Client) Categories() *CategoryClient
- func (c *Client) GetCache(key string, target interface{}) bool
- func (c *Client) Licenses() *LicenseClient
- func (c *Client) Locations() *LocationClient
- func (c *Client) SetCache(key string, value interface{}, duration time.Duration)
- type DateInfo
- type GET
- type Hardware
- type HardwareBase
- type HardwareGET
- type HardwareList
- type HardwarePOST
- type HardwarePUTPATCH
- type License
- type LicenseBase
- type LicenseBuilder
- func NewLicense(name string) LicenseBuilder
- func (b LicenseBuilder) Build() *License[LicensePOST]
- func (b LicenseBuilder) CategoryID(v uint32) LicenseBuilder
- func (b LicenseBuilder) ExpirationDate(v string) LicenseBuilder
- func (b LicenseBuilder) LicenseEmail(v string) LicenseBuilder
- func (b LicenseBuilder) LicenseName(v string) LicenseBuilder
- func (b LicenseBuilder) Maintained(v bool) LicenseBuilder
- func (b LicenseBuilder) Notes(v string) LicenseBuilder
- func (b LicenseBuilder) OrderNumber(v string) LicenseBuilder
- func (b LicenseBuilder) ProductKey(v string) LicenseBuilder
- func (b LicenseBuilder) PurchaseCost(v float64) LicenseBuilder
- func (b LicenseBuilder) PurchaseDate(v string) LicenseBuilder
- func (b LicenseBuilder) PurchaseOrder(v string) LicenseBuilder
- func (b LicenseBuilder) Reassignable(v bool) LicenseBuilder
- func (b LicenseBuilder) Seats(v string) LicenseBuilder
- type LicenseClient
- type LicenseGET
- type LicenseList
- type LicensePOST
- type LicenseQuery
- type Location
- type LocationClient
- func (c *LocationClient) CreateLocation(p *Location) (*Location, error)
- func (c *LocationClient) DeleteLocation(id int) error
- func (c *LocationClient) GetAllLocations() (*LocationList, error)
- func (c *LocationClient) GetLocation(id int) (*Location, error)
- func (c *LocationClient) PartialUpdateLocation(id int, p *Location) (*Location, error)
- func (c *LocationClient) UpdateLocation(id int, p *Location) (*Location, error)
- type LocationList
- type LocationQuery
- type Messages
- type Model
- type ModelBase
- type ModelList
- type PPPD
- type PaginatedList
- type PaginatedResponse
- type QueryInterface
- type Record
- type SnipeIT
- type SnipeITResponse
- type StatusLabel
- type Timestamp
- type User
- type UserList
Constants
const (
CATEGORY_TYPE_ASSET string = "Asset"
CATEGORY_TYPE_ACCESSORY string = "Accessory"
CATEGORY_TYPE_CONSUMABLE string = "Consumable"
CATEGORY_TYPE_COMPONENT string = "Component"
CATEGORY_TYPE_LICENSE string = "License"
)
const (
Assets = "%s/hardware" // https://snipe-it.readme.io/reference#hardware
Fields = "%s/fields" // https://snipe-it.readme.io/reference/fields-1
FieldSets = "%s/fieldsets" // https://snipe-it.readme.io/reference/fieldsets
Companies = "%s/companies" // https://snipe-it.readme.io/reference#companies
Locations = "%s/locations" // https://snipe-it.readme.io/reference#locations
Accessories = "%s/accessories" // https://snipe-it.readme.io/reference#accessories
Consumables = "%s/consumables" // https://snipe-it.readme.io/reference#consumables
Components = "%s/components" // https://snipe-it.readme.io/reference#components
Users = "%s/users" // https://snipe-it.readme.io/reference#users
StatusLabels = "%s/statuslabels" // https://snipe-it.readme.io/reference#status-labels
Models = "%s/models" // https://snipe-it.readme.io/reference#models
Licenses = "%s/licenses" // https://snipe-it.readme.io/reference#licenses
Categories = "%s/categories" // https://snipe-it.readme.io/reference#categories
Manufacturers = "%s/manufacturers" // https://snipe-it.readme.io/reference#manufacturers
Suppliers = "%s/suppliers" // https://snipe-it.readme.io/reference#suppliers
AssetMaintenance = "%s/hardware/maintenance" // https://snipe-it.readme.io/reference#maintenances
Departments = "%s/departments" // https://snipe-it.readme.io/reference#departments
Groups = "%s/groups" // https://snipe-it.readme.io/reference#groups
Settings = "%s/settings" // https://snipe-it.readme.io/reference#settings
Reports = "%s/reports" // https://snipe-it.readme.io/reference#reports
)
Variables
var (
BaseURL = fmt.Sprintf("https://%s/api/v1", "%s") // https://snipe-it.readme.io/reference/api-overview
)
type Accessory
Accessory represents an individual accessory. https://snipe-it.readme.io/reference/accessories#sortable-columns
type Accessory struct {
*SnipeIT `json:",inline"`
Category *Record `json:"category,omitempty"` // Name and ID of the accessory's category
Image string `json:"image,omitempty"` // URL of the accessory's image
MinQty int `json:"min_qty,omitempty"` // Minimum quantity of the accessory
ModelNumber string `json:"model_number,omitempty"` // Model number of the accessory
Notes string `json:"notes,omitempty"` // Notes about the accessory
OrderNumber string `json:"order_number,omitempty"` // Order number associated with the accessory
PurchaseCost string `json:"purchase_cost,omitempty"` // Purchase cost of the accessory
PurchaseDate string `json:"purchase_date,omitempty"` // Purchase date of the accessory
Qty int `json:"qty,omitempty"` // Quantity of the accessory
RemainingQty int `json:"remaining_qty,omitempty"` // Remaining quantity of the accessory
UserCanCheckout bool `json:"user_can_checkout,omitempty"` // If the user can checkout the accessory
}
type AccessoryClient
AccessoriesClient for chaining methods
type AccessoryClient struct {
*Client
}
func (*AccessoryClient) GetAllAccessories
func (c *AccessoryClient) GetAllAccessories() (*AccessoryList, error)
* # List all Accessories in Snipe-IT
- /api/v1/accessories
- - https://snipe-it.readme.io/reference/accessories
type AccessoryList
### Accessories ------------------------------------------------------------------------- Source: https://snipe-it.readme.io/reference/accessories
type AccessoryList = PaginatedList[Accessory]
type AccessoryQuery
* Query Parameters for Accessories
type AccessoryQuery struct {
Limit int `url:"limit,omitempty"` // Specify the number of results you wish to return. Defaults to 50.
Offset int `url:"offset,omitempty"` // Specify the number of results to skip before starting to return items. Defaults to 0.
Search string `url:"search,omitempty"` // Search for an asset by asset tag, serial, or model number.
OrderNumber string `url:"order_number,omitempty"` // Return only assets associated with the specified order number.
Sort string `url:"sort,omitempty"` // Sort the results by the specified column. Defaults to id.
Order string `url:"order,omitempty"` // Sort the results in the specified order. Defaults to asc.
Expand string `url:"expand,omitempty"` // Expand the results to include full details of the associated model, category, and manufacturer.
}
func (*AccessoryQuery) Copy
func (q *AccessoryQuery) Copy() QueryInterface
### AccessoryQuery implements QueryInterface ---------------------------------------------------------------------
func (*AccessoryQuery) GetLimit
func (q *AccessoryQuery) GetLimit() int
func (*AccessoryQuery) GetOffset
func (q *AccessoryQuery) GetOffset() int
func (*AccessoryQuery) SetLimit
func (q *AccessoryQuery) SetLimit(limit int)
func (*AccessoryQuery) SetOffset
func (q *AccessoryQuery) SetOffset(offset int)
type AssetClient
AssetClient for chaining methods
type AssetClient struct {
*Client
}
func (*AssetClient) CreateAsset
func (c *AssetClient) CreateAsset(p *Hardware[HardwarePOST]) (*Hardware[HardwarePOST], error)
* # Create an asset in Snipe-IT
- /api/v1/hardware
- - https://snipe-it.readme.io/reference/hardware-create
func (*AssetClient) DeleteAsset
func (c *AssetClient) DeleteAsset(id int64) (string, error)
* # Delete an asset in Snipe-IT
- /api/v1/hardware/{id}
- - https://snipe-it.readme.io/reference/hardware-delete
func (*AssetClient) GetAllAssets
func (c *AssetClient) GetAllAssets() (*HardwareList, error)
* List all Hardware Assets in Snipe-IT
- /api/v1/hardware
- - https://snipe-it.readme.io/reference/hardware-list
func (*AssetClient) GetAssetBySerial
func (c *AssetClient) GetAssetBySerial(serial string) (*Hardware[HardwareGET], error)
* Get Hardware Assets by Serial
- /api/v1/hardware/byserial/{serial}
- - https://snipe-it.readme.io/reference/hardware-by-serial
func (*AssetClient) GetAssetByTag
func (c *AssetClient) GetAssetByTag(tag string) (*Hardware[HardwareGET], error)
* Get Hardware Assets by Tag
- /api/v1/hardware/bytag/{tag}
- - https://snipe-it.readme.io/reference/hardware-by-asset-tag
func (*AssetClient) PartialUpdateAsset
func (c *AssetClient) PartialUpdateAsset(id uint32, h *Hardware[HardwarePUTPATCH]) (*Hardware[HardwarePUTPATCH], error)
Partially updates a specific asset in Snipe-IT
- /api/v1/hardware/{id}
- - https://snipe-it.readme.io/reference/hardware-partial-update
type AssetQuery
* Query Parameters for Assets
type AssetQuery struct {
Limit int `url:"limit,omitempty"` // Specify the number of results you wish to return. Defaults to 50.
Offset int `url:"offset,omitempty"` // Specify the number of results to skip before starting to return items. Defaults to 0.
Search string `url:"search,omitempty"` // Search for an asset by asset tag, serial, or model number.
OrderNumber string `url:"order_number,omitempty"` // Return only assets associated with the specified order number.
Sort string `url:"sort,omitempty"` // Sort the results by the specified column. Defaults to id.
Order string `url:"order,omitempty"` // Sort the results in the specified order. Defaults to asc.
ModelID int `url:"model_id,omitempty"` // Return only assets associated with the specified model ID.
CategoryID int `url:"category_id,omitempty"` // Return only assets associated with the specified category ID.
ManufacturerID int `url:"manufacturer_id,omitempty"` // Return only assets associated with the specified manufacturer ID.
CompanyID int `url:"company_id,omitempty"` // Return only assets associated with the specified company ID.
LocationID int `url:"location_id,omitempty"` // Return only assets associated with the specified location ID.
Status string `url:"status,omitempty"` // Optionally restrict asset results to one of these status types: RTD, Deployed, Undeployable, Deleted, Archived, Requestable
StatusID int `url:"status_id,omitempty"` // Return only assets associated with the specified status ID.
}
func (*AssetQuery) Copy
func (q *AssetQuery) Copy() QueryInterface
### AssetQuery implements QueryInterface ---------------------------------------------------------------------
func (*AssetQuery) GetLimit
func (q *AssetQuery) GetLimit() int
func (*AssetQuery) GetOffset
func (q *AssetQuery) GetOffset() int
func (*AssetQuery) SetLimit
func (q *AssetQuery) SetLimit(limit int)
func (*AssetQuery) SetOffset
func (q *AssetQuery) SetOffset(offset int)
type AvailableActions
AvailableActions represents the available actions for a hardware item.
type AvailableActions struct {
Checkin bool `json:"checkin,omitempty"` // Whether check-in action is available.
Checkout bool `json:"checkout,omitempty"` // Whether check-out action is available.
Clone bool `json:"clone,omitempty"` // Whether clone action is available.
Delete bool `json:"delete,omitempty"` // Whether delete action is available.
Restore bool `json:"restore,omitempty"` // Whether restore action is available.
Update bool `json:"update,omitempty"` // Whether update action is available.
}
type Category
type Category[M any] struct {
*CategoryBase `json:",inline"`
Method M `json:",inline"`
}
func (Category[M]) MarshalJSON
func (c Category[M]) MarshalJSON() ([]byte, error)
func (*Category[M]) UnmarshalJSON
func (c *Category[M]) UnmarshalJSON(data []byte) error
type CategoryBase
Category represents an individual category. https://snipe-it.readme.io/reference/categories#sortable-columns
type CategoryBase struct {
*SnipeIT `json:",inline"`
Type string `json:"category_type,omitempty"`
UseDefaultEULA bool `json:"use_default_eula,omitempty,omitzero"`
RequireAcceptance bool `json:"require_acceptance,omitempty,omitzero"`
CheckinEmail bool `json:"checkin_email,omitempty,omitzero"`
}
type CategoryClient
CategoryClient for chaining methods
type CategoryClient struct {
*Client
}
func (*CategoryClient) CreateCategory
func (c *CategoryClient) CreateCategory(p *Category[CategoryPOST]) (*Category[CategoryPOST], error)
* # Create a category in Snipe-IT
- /api/v1/categories
- https://snipe-it.readme.io/reference/categories-2
func (*CategoryClient) GetAllCategories
func (c *CategoryClient) GetAllCategories() (*CategoryList, error)
* List all Categories in Snipe-IT
- /api/v1/categories
- https://snipe-it.readme.io/reference/categories-1
type CategoryGET
type CategoryGET struct {
GET `json:",inline"`
Image *string `json:"image,omitempty"`
HasEULA bool `json:"has_eula,omitempty,omitzero"`
EULA string `json:"use_default_eula,omitempty"`
AssetsCount uint32 `json:"assets_count,omitempty"`
AccessoriesCount uint32 `json:"accessories_count,omitempty"`
ConsumablesCount uint32 `json:"consumables_count,omitempty"`
ComponentsCount uint32 `json:"components_count,omitempty"`
LicensesCount uint32 `json:"licenses_count,omitempty"`
Notes string `json:"notes,omitempty"`
}
type CategoryList
### Categories ------------------------------------------------------------------------- Source: https://snipe-it.readme.io/reference/categories
type CategoryList = PaginatedList[Category[CategoryGET]]
type CategoryPOST
type CategoryPOST struct {
PPPD `json:",inline"`
}
type CategoryQuery
* Query Parameters for Categories
type CategoryQuery struct {
Name string `url:"string,omitempty"` // Specify the name of the category.
Limit int `url:"limit,omitempty"` // Specify the number of results you wish to return. Defaults to 50.
Offset int `url:"offset,omitempty"` // Specify the number of results to skip before starting to return items. Defaults to 0.
Search string `url:"search,omitempty"` // Search for an asset by asset tag, serial, or model number.
Sort string `url:"sort,omitempty"` // Sort the results by the specified column. Defaults to id.
Order string `url:"order,omitempty"` // Sort the results in the specified order. Defaults to asc.
CategoryID int `url:"category_id,omitempty"` // Return only assets associated with the specified category ID.
Type string `url:"category_type,omitempty"` // Type of category
UseDefaultEULA bool `url:"use_default_eula,omitempty,omitzero"` // If a category is using the default EULA
RequireAcceptance bool `url:"require_acceptance,omitempty,omitzero"` // If the category required acceptance of the EULA
CheckinEmail bool `url:"checkin_email,omitempty,omitzero"` // Email
}
func (*CategoryQuery) Copy
func (q *CategoryQuery) Copy() QueryInterface
### CategoryQuery implements QueryInterface ---------------------------------------------------------------------
func (*CategoryQuery) GetLimit
func (q *CategoryQuery) GetLimit() int
func (*CategoryQuery) GetOffset
func (q *CategoryQuery) GetOffset() int
func (*CategoryQuery) SetLimit
func (q *CategoryQuery) SetLimit(limit int)
func (*CategoryQuery) SetOffset
func (q *CategoryQuery) SetOffset(offset int)
type Client
### SnipeIT Client Structs ---------------------------------------------------------------------
type Client struct {
BaseURL string // BaseURL is the base URL for the SnipeIT API.
HTTP *requests.Client // HTTP client for the SnipeIT API.
Log *log.Logger // Log is the logger for the SnipeIT API.
Cache *cache.Cache // Cache for the SnipeIT API.
}
func NewClient
func NewClient(verbosity int) *Client
func (*Client) Accessories
func (c *Client) Accessories() *AccessoryClient
Entry point for accessories-related operations
func (*Client) Assets
func (c *Client) Assets() *AssetClient
Entry point for asset-related operations
func (*Client) BuildURL
func (c *Client) BuildURL(endpoint string, identifiers ...interface{}) string
BuildURL builds a URL for a given resource and identifiers.
func (*Client) Categories
func (c *Client) Categories() *CategoryClient
Entry point for asset-related operations
func (*Client) GetCache
func (c *Client) GetCache(key string, target interface{}) bool
* GetCache retrieves a SnipeIT API response from the cache
func (*Client) Licenses
func (c *Client) Licenses() *LicenseClient
Entry point for asset-related operations
func (*Client) Locations
func (c *Client) Locations() *LocationClient
Entry point for locations-related operations
func (*Client) SetCache
func (c *Client) SetCache(key string, value interface{}, duration time.Duration)
* SetCache stores a SnipeIT API response in the cache
type DateInfo
DateInfo represents a date and its formatted representation.
type DateInfo struct {
Date string `json:"datetime,omitempty"` // The date in yyyy-mm-dd format.
Formatted string `json:"formatted,omitempty"` // The formatted date.
}
type GET
SnipeIT {GET} fields
type GET struct {
CreatedAt *DateInfo `json:"created_at,omitempty"` // Time when the item was created.
UpdatedAt *DateInfo `json:"updated_at,omitempty"` // Time when the item was last updated.
DeletedAt *DateInfo `json:"deleted_at,omitempty"` // Time when the item was deleted.
Category *Record `json:"category,omitempty"` // Category of the hardware item.
Company *Record `json:"company,omitempty"` // {HARDWARE,USER,LICENSE} Company
Department *Record `json:"department,omitempty"` // {USER} Department
Depreciation *Record `json:"depreciation,omitempty"` // {MODEL} Depreciation
Location *Record `json:"location,omitempty"` // {HARDWARE,MODEL,USER} Location of the entity
Manager *Record `json:"manager,omitempty"` // {LOCATION,USER} Manager
Manufacturer *Record `json:"manufacturer,omitempty"` // {ACCESSORY,HARDWARE} Manufacturer
Parent *Record `json:"parent,omitempty"` // {Location} Parent of the location
RTDLocation *Record `json:"rtd_location,omitempty"` // {HARDWARE} RTD [Ready to Deploy] location
Supplier *Record `json:"supplier,omitempty"` // {HARDWARE,LICENSE} Supplier of the item.
}
type Hardware
Hardware represents an individual hardware item. https://snipe-it.readme.io/reference/hardware-list#sortable-columns
type Hardware[M any] struct {
*HardwareBase `json:",inline"`
Method M `json:",inline"`
Model *Model[GET] `json:"model,omitempty"` // Model of the hardware item.
ModelNumber string `json:"model_number,omitempty"` // Model number of the hardware item.
EOL *Timestamp `json:"eol,omitempty"` // End of life of a hardware item.
AssetEOLDate *Timestamp `json:"asset_eol_date,omitempty"` // Asset end of life date of the hardware item.
StatusLabel *StatusLabel `json:"status_label,omitempty"` // Status label of the hardware item.
Image string `json:"image,omitempty"` // Image of the hardware item.
QR string `json:"qr,omitempty"` // QR code of the hardware item.
AltBarcode string `json:"alt_barcode,omitempty"` // Alternate barcode of the hardware item.
WarrantyExpires string `json:"warranty_expires,omitempty"` // Warranty expiry date of the hardware item.
LastAuditDate *string `json:"last_audit_date,omitempty"` // Last audit date of the hardware item.
NextAuditDate *string `json:"next_audit_date,omitempty"` // Next audit date of the hardware item.
Age string `json:"age,omitempty"` // Age of the hardware item.
LastCheckout *Timestamp `json:"last_checkout,omitempty"` // Time when the hardware item was last checked out.
ExpectedCheckin *Timestamp `json:"expected_checkin,omitempty"` // Expected check-in date of the hardware item.
CheckinCounter int `json:"checkin_counter,omitempty"` // Check-in counter of the hardware item.
CheckoutCounter int `json:"checkout_counter,omitempty"` // Check-out counter of the hardware item.
RequestsCounter int `json:"requests_counter,omitempty"` // Request counter of the hardware item.
UserCanCheckout bool `json:"user_can_checkout,omitempty"` // Whether the user can check-out the hardware item.
CustomFields *map[string]map[string]string `json:"custom_fields,omitempty"` // Custom fields of a Snipe-IT asset (This will typically be the `DB Field` property in the WebUI)
}
func (*Hardware[M]) UnmarshalJSON
func (h *Hardware[M]) UnmarshalJSON(data []byte) error
type HardwareBase
type HardwareBase struct {
*SnipeIT `json:",inline"`
AssetTag string `json:"asset_tag,omitempty"` // Asset tag of the hardware item.
Serial string `json:"serial,omitempty"` // Serial number of the hardware item.
OrderNumber string `json:"order_number,omitempty"` // Order number of the hardware item.
Notes string `json:"notes,omitempty"` // Notes associated with the hardware item.
WarrantyMonths *string `json:"warranty_months,omitempty"` // Warranty months of the hardware item.
}
type HardwareGET
type HardwareGET struct {
GET `json:",inline"`
Archived string `json:"archived,omitempty"` // Whether the hardware item is archived (string on GET, bool on PPPD)
AssignedTo *User `json:"assigned_to,omitempty"` // User to whom the hardware item is assigned. (object on GET, string on POST)
PurchaseCost string `json:"purchase_cost,omitempty"` // Purchase cost of the hardware item. (string on GET, float on POST)
PurchaseDate *DateInfo `json:"purchase_date,omitempty"` // Purchase date of the hardware item. (object on GET, string on PPPD)
}
type HardwareList
### Assets ------------------------------------------------------------------------- Source: https://snipe-it.readme.io/reference/hardware-list
type HardwareList = PaginatedList[Hardware[HardwareGET]]
type HardwarePOST
type HardwarePOST struct {
/*
You can do a checkout on creation if you add one of the following fields: assigned_user, assigned_asset, or assigned_location. This should be a valid primary key of the user, asset or location you wish to checkout to.
*/
PPPD `json:",inline"`
Archived bool `json:"archived,omitempty"` // Whether the hardware item is archived (string on GET, bool on PPPD)
AssignedTo *string `json:"assigned_to,omitempty"` // User to whom the hardware item is assigned. (object on GET, string on POST)
BYOD bool `json:"byod,omitempty"` // Whether the hardware item is BYOD (bool on POST, int32 on PUT,PATCH)
PurchaseCost *float64 `json:"purchase_cost,omitempty"` // Purchase cost of the hardware item. (string on GET, float on POST,PATCH)
}
type HardwarePUTPATCH
type HardwarePUTPATCH struct {
PPPD `json:",inline"`
Archived bool `json:"archived,omitempty"` // Whether the hardware item is archived (string on GET, bool on PPPD)
AssignedTo uint32 `json:"assigned_to,omitempty"` // User ID to whom the hardware item is assigned. (object on GET, string on POST)
BYOD uint32 `json:"byod,omitempty"` // Whether the hardware item is BYOD (bool on POST, int32 on PUT,PATCH)
PurchaseCost *float64 `json:"purchase_cost,omitempty"` // Purchase cost of the hardware item. (string on GET, float on POST,PATCH)
}
type License
type License[M any] struct {
*LicenseBase `json:",inline"`
Method M `json:",inline"`
}
func (License[M]) MarshalJSON
func (l License[M]) MarshalJSON() ([]byte, error)
func (*License[M]) UnmarshalJSON
func (l *License[M]) UnmarshalJSON(data []byte) error
type LicenseBase
type LicenseBase struct {
*SnipeIT `json:",inline"`
LicenseName string `json:"license_name,omitempty"` // Owner/contact name
LicenseEmail string `json:"license_email,omitempty"` // Owner/contact email
Maintained bool `json:"maintained,omitempty"` // Whether the license is maintained
Notes string `json:"notes,omitempty"` // Notes associated with the license
OrderNumber string `json:"order_number,omitempty"` // Order number of the license
PurchaseOrder string `json:"purchase_order,omitempty"` // Purchase order of the license
PurchaseDate *Timestamp `json:"purchase_date,omitempty"` // Purchase date of the license
ExpirationDate *Timestamp `json:"expiration_date,omitempty"` // Expiration date of the license
}
type LicenseBuilder
type LicenseBuilder func() *License[LicensePOST]
func NewLicense
func NewLicense(name string) LicenseBuilder
NewLicense starts a fresh *License[LicensePOST] and hands the builder back. Philosophy is that we build licenses for PPPD methods but not for GET, which is why LicensePOST is hard-coded instead of using a Generic type
func (LicenseBuilder) Build
func (b LicenseBuilder) Build() *License[LicensePOST]
func (LicenseBuilder) CategoryID
func (b LicenseBuilder) CategoryID(v uint32) LicenseBuilder
func (LicenseBuilder) ExpirationDate
func (b LicenseBuilder) ExpirationDate(v string) LicenseBuilder
func (LicenseBuilder) LicenseEmail
func (b LicenseBuilder) LicenseEmail(v string) LicenseBuilder
func (LicenseBuilder) LicenseName
func (b LicenseBuilder) LicenseName(v string) LicenseBuilder
func (LicenseBuilder) Maintained
func (b LicenseBuilder) Maintained(v bool) LicenseBuilder
func (LicenseBuilder) Notes
func (b LicenseBuilder) Notes(v string) LicenseBuilder
func (LicenseBuilder) OrderNumber
func (b LicenseBuilder) OrderNumber(v string) LicenseBuilder
func (LicenseBuilder) ProductKey
func (b LicenseBuilder) ProductKey(v string) LicenseBuilder
func (LicenseBuilder) PurchaseCost
func (b LicenseBuilder) PurchaseCost(v float64) LicenseBuilder
func (LicenseBuilder) PurchaseDate
func (b LicenseBuilder) PurchaseDate(v string) LicenseBuilder
func (LicenseBuilder) PurchaseOrder
func (b LicenseBuilder) PurchaseOrder(v string) LicenseBuilder
func (LicenseBuilder) Reassignable
func (b LicenseBuilder) Reassignable(v bool) LicenseBuilder
func (LicenseBuilder) Seats
func (b LicenseBuilder) Seats(v string) LicenseBuilder
type LicenseClient
LicenseClient for chaining methods
type LicenseClient struct {
*Client
}
func (*LicenseClient) CreateLicense
func (c *LicenseClient) CreateLicense(p *License[LicensePOST]) (*License[LicensePOST], error)
* # Create an license in Snipe-IT
- /api/v1/licenses
- - https://snipe-it.readme.io/reference/testinput (Yes, this is the correct link)
func (*LicenseClient) GetAllLicenses
func (c *LicenseClient) GetAllLicenses() (*LicenseList, error)
* List all Licenses in Snipe-IT
- /api/v1/licenses
- - https://snipe-it.readme.io/reference/licenses
type LicenseGET
type LicenseGET struct {
GET `json:",inline"`
ProductKey string `json:"product_key,omitempty"` // Product key of the license
PurchaseCost string `json:"purchase_cost,omitempty"` // Purchase cost of the license
Seats int `json:"seats,omitempty"` // Number of seats for the license (int on GET, string on POST)
FreeSeats int `json:"free_seats_count,omitempty"` // Number of free seats for the license
}
type LicenseList
### Licenses ------------------------------------------------------------------------- Source: https://snipe-it.readme.io/reference/licenses
type LicenseList = PaginatedList[License[LicenseGET]]
type LicensePOST
type LicensePOST struct {
PPPD `json:",inline"`
Seats string `json:"seats,omitempty"` // Number of seats for the license (int on GET, string on POST)
ProductKey string `json:"serial,omitempty"` // Product key of the license (but POSTs as serial)
PurchaseCost *float64 `json:"purchase_cost,omitempty"` // Purchase cost of the license. (string on GET, float on POST,PATCH)
Reassignable bool `json:"reassignable,omitempty"` // Whether the license is reassignable
}
type LicenseQuery
* Query Parameters for Licenses
type LicenseQuery struct {
Name string `url:"string,omitempty"` // Specify the name of the license.
ProductKey string `url:"product_key,omitempty"` // Specify the product key of the license.
Limit int `url:"limit,omitempty"` // Specify the number of results you wish to return. Defaults to 50.
Offset int `url:"offset,omitempty"` // Specify the number of results to skip before starting to return items. Defaults to 0.
Search string `url:"search,omitempty"` // Search for an asset by asset tag, serial, or model number.
OrderNumber string `url:"order_number,omitempty"` // Return only licenses associated with the specified order number.
Sort string `url:"sort,omitempty"` // Sort the results by the specified column. Defaults to id.
Order string `url:"order,omitempty"` // Sort the results in the specified order. Defaults to asc.
Expand string `url:"expand,omitempty"` // Whether to include detailed information on categories, etc (true) or just the text name (false)
PurchaseOrder string `url:"purchase_order,omitempty"` // Return only assets associated with the specified purchase order.
LicenseName string `url:"license_name,omitempty"` // Name of the person on the license
LicenseEmail string `url:"license_email,omitempty"` // Email address associated with license
ManufacturerID int `url:"manufacturer_id,omitempty"` // Return only assets associated with the specified manufacturer ID.
SupplierID int `url:"supplier_id,omitempty"` // Return only assets associated with the specified supplier ID.
CategoryID int `url:"category_id,omitempty"` // Return only assets associated with the specified category ID.
DepreciationID int `url:"depreciation_id,omitempty"` // Return only assets associated with the specified depreciation ID.
Maintained bool `url:"maintained,omitempty"` // True to return only maintained licenses
Deleted string `url:"deleted,omitempty"` // Set to true to return deleted licenses
}
func (*LicenseQuery) Copy
func (q *LicenseQuery) Copy() QueryInterface
### LicenseQuery implements QueryInterface ---------------------------------------------------------------------
func (*LicenseQuery) GetLimit
func (q *LicenseQuery) GetLimit() int
func (*LicenseQuery) GetOffset
func (q *LicenseQuery) GetOffset() int
func (*LicenseQuery) SetLimit
func (q *LicenseQuery) SetLimit(limit int)
func (*LicenseQuery) SetOffset
func (q *LicenseQuery) SetOffset(offset int)
type Location
type Location struct {
*SnipeIT `json:",inline"`
Image string `json:"image,omitempty"` // The URL of the location's image.
Address string `json:"address,omitempty"` // The address of the location.
Address2 string `json:"address2,omitempty"` // The second address line of the location.
City string `json:"city,omitempty"` // The city of the location.
State string `json:"state,omitempty"` // The state of the location.
Country string `json:"country,omitempty"` // The country of the location.
Zip string `json:"zip,omitempty"` // The zip code of the location.
AssetsAssigned int `json:"assigned_assets_count,omitempty"` // The number of assets assigned to the location.
Assets int `json:"assets_count,omitempty"` // The number of assets at the location.
RTDAssets int `json:"rtd_assets_count,omitempty"` // The number of assets ready to deploy at the location.
Users int `json:"users_count,omitempty"` // The number of users at the location.
Currency string `json:"currency,omitempty"` // The currency of the location.
LDAP interface{} `json:"ldap_ou,omitempty"` // The LDAP OU of the location.
Children []Location `json:"children,omitempty"` // The children of the location.
}
type LocationClient
LocationClient for chaining methods
type LocationClient struct {
*Client
}
func (*LocationClient) CreateLocation
func (c *LocationClient) CreateLocation(p *Location) (*Location, error)
* # Create a new Location in Snipe-IT
- /api/v1/locations
- - https://snipe-it.readme.io/reference/locations-2
func (*LocationClient) DeleteLocation
func (c *LocationClient) DeleteLocation(id int) error
* # Delete a Location in Snipe-IT
- /api/v1/locations/{locationId}
- - https://snipe-it.readme.io/reference/locationsid-2
func (*LocationClient) GetAllLocations
func (c *LocationClient) GetAllLocations() (*LocationList, error)
* # List all Locations in Snipe-IT
- /api/v1/locations
- - https://snipe-it.readme.io/reference/locations
func (*LocationClient) GetLocation
func (c *LocationClient) GetLocation(id int) (*Location, error)
Get Location Details by ID
- /api/v1/locations/{id}
- - https://snipe-it.readme.io/reference/locations-1
func (*LocationClient) PartialUpdateLocation
func (c *LocationClient) PartialUpdateLocation(id int, p *Location) (*Location, error)
Partially update a Location in Snipe-IT
- /api/v1/locations/{locationId}
- - https://snipe-it.readme.io/reference/locationsid
func (*LocationClient) UpdateLocation
func (c *LocationClient) UpdateLocation(id int, p *Location) (*Location, error)
* # Update a Location in Snipe-IT
- /api/v1/locations/{id}
- - https://snipe-it.readme.io/reference/locations-3
type LocationList
### Locations -------------------------------------------------------------------------
type LocationList = PaginatedList[Location]
type LocationQuery
* Query Parameters for Locations
type LocationQuery struct {
Name string `url:"name,omitempty"` // Search for a location by name.
Limit int `url:"limit,omitempty"` // Specify the number of results you wish to return. Defaults to 50.
Offset int `url:"offset,omitempty"` // Specify the number of results to skip before starting to return items. Defaults to 0.
Search string `url:"search,omitempty"` // Search for a location by name or address.
Sort string `url:"sort,omitempty"` // Sort the results by the specified column. Defaults to id.
Order string `url:"order,omitempty"` // Sort the results in the specified order. Defaults to asc.
Address string `url:"address,omitempty"` // Search for a location by address.
Address2 string `url:"address2,omitempty"` // Search for a location by address2.
City string `url:"city,omitempty"` // Search for a location by city.
State string `url:"state,omitempty"` // Search for a location by state.
Country string `url:"country,omitempty"` // Search for a location by country.
Expand string `url:"expand,omitempty"` // Expand the results to include full details of the associated model, category, and manufacturer.
}
func (*LocationQuery) Copy
func (q *LocationQuery) Copy() QueryInterface
### LocationQuery implements QueryInterface ---------------------------------------------------------------------
func (*LocationQuery) GetLimit
func (q *LocationQuery) GetLimit() int
func (*LocationQuery) GetOffset
func (q *LocationQuery) GetOffset() int
func (*LocationQuery) SetLimit
func (q *LocationQuery) SetLimit(limit int)
func (*LocationQuery) SetOffset
func (q *LocationQuery) SetOffset(offset int)
type Messages
type Messages struct {
StringValue string
MapValue map[string][]string
IsString bool
}
func (*Messages) UnmarshalJSON
func (m *Messages) UnmarshalJSON(data []byte) error
type Model
type Model[M any] struct {
*ModelBase `json:",inline"`
Method M `json:",inline"`
}
type ModelBase
type ModelBase struct {
*SnipeIT `json:",inline"`
ModelNumber string `json:"model_number,omitempty"` // Model number of the hardware item.
Image string `json:"image,omitempty"` // Image of the hardware model.
//Requestable bool `json:"requestable,omitempty"` // Whether the hardware model is requestable.
Notes string `json:"notes,omitempty"` // Notes of the hardware model.
MinAmt *float64 `json:"min_amt,omitempty"` // Minimum amount of the hardware model.
EOL int `json:"eol,omitempty"` // End of life of the hardware model.
DeprecatedMACAddress any `json:"deprecated_mac_address,omitempty"` // Deprecated MAC address of the hardware model. (string on GET, number on PATCH)
}
type ModelList
### Models ------------------------------------------------------------------------- Source: https://snipe-it.readme.io/reference/models
type ModelList = PaginatedList[Model[GET]]
type PPPD
SnipeIT {POST, PUT, PATCH, DELETE} fields
type PPPD struct {
CreatedAt *string `json:"created_at,omitempty"` // Time when the item was created.
UpdatedAt *string `json:"updated_at,omitempty"` // Time when the item was last updated.
DeletedAt *string `json:"deleted_at,omitempty"` // Time when the item was deleted.
CategoryID *uint32 `json:"category_id,omitempty"` // {MODEL,LICENSE} Category ID
CompanyID *uint32 `json:"company_id,omitempty"` // {HARDWARE,LICENSE} Company ID
DepartmentID *uint32 `json:"department_id,omitempty"` // Department ID
DepreciationID *uint32 `json:"depreciation_id,omitempty"` // {MODEL} Depreciation ID
FieldsetID *uint32 `json:"fieldset_id,omitempty"` // {MODEL} Fieldset ID
LocationID *uint32 `json:"location_id,omitempty"` // Location ID
ManufacturerID *uint32 `json:"manufacturer_id,omitempty"` // {MODEL,LICENSE} Manufacturer ID
ModelID *uint32 `json:"model_id,omitempty"` // Model ID
ParentID *uint32 `json:"parent_id,omitempty"` // {Location} Parent ID
RTDLocationID *uint32 `json:"rtd_location_id,omitempty"` // RTD Location ID
StatusID *uint32 `json:"status_id,omitempty"` // {HARDWARE} Status ID
SupplierID *uint32 `json:"supplier_id,omitempty"` // {HARDWARE,LICENSE} Supplier ID
}
type PaginatedList
PaginatedList is a generic structure representing a paginated response from SnipeIT with items of any type.
type PaginatedList[E any] struct {
Total int `json:"total,omitempty"` // The total number of items.
Rows *[]*E `json:"rows,omitempty"` // An array of items.
}
func (PaginatedList[E]) Append
func (pl PaginatedList[E]) Append(elements *[]*E)
func (PaginatedList[E]) Elements
func (pl PaginatedList[E]) Elements() *[]*E
func (PaginatedList[E]) Map
func (pl PaginatedList[E]) Map() map[any]*E
func (PaginatedList[E]) TotalCount
func (pl PaginatedList[E]) TotalCount() int
type PaginatedResponse
PaginatedResponse is an interface for SnipeIT API responses involving pagination
type PaginatedResponse[E any] interface {
TotalCount() int
Append(*[]*E)
Elements() *[]*E
}
type QueryInterface
QueryInterface defines methods for queries with pagination and filtering
type QueryInterface interface {
Copy() QueryInterface
GetLimit() int
SetLimit(int)
GetOffset() int
SetOffset(int)
}
type Record
END OF LICENSE STRUCTS ------------------------------------------------------------------------- ### Common Asset types ------------------------------------------------------------------------- Record represents an id:name pairing for many types of records in Snipe-IT.
type Record struct {
ID uint32 `json:"id,omitzero"` // ID of the record {category, company, department, location, manufacturer, supplier, etc.}
Name string `json:"name"` // Name of the record {category, company, department, location, manufacturer, supplier, etc.}
}
type SnipeIT
SnipeIT Common fields
type SnipeIT struct {
*Record `json:",inline"`
AvailableActions *AvailableActions `json:"available_actions,omitempty"` // Available actions for the entity
}
type SnipeITResponse
SnipeITResponse is an interface for Snipe-IT API responses
type SnipeITResponse[E any] struct {
Status string `json:"status,omitempty"` // Status of the response
Messages Messages `json:"messages,omitempty"` // Messages associated with the response
Error string `json:"error,omitempty"` // Error associated with the response
Payload *E `json:"payload,omitempty"` // Payload of the response -- can be an object of any type
}
type StatusLabel
StatusLabel represents the status label of a hardware item.
type StatusLabel struct {
*Record `json:",inline"`
StatusMeta string `json:"status_meta,omitempty"` // Meta status of the status label.
StatusType string `json:"status_type,omitempty"` // Type of the status label.
}
type Timestamp
Timestamp is a time.Time but JSON marshals/unmarshals as a string in the format “2006-01-02 15:04:05”
type Timestamp struct {
time.Time `json:",omitzero"`
}
func (Timestamp) MarshalJSON
func (ts Timestamp) MarshalJSON() ([]byte, error)
func (*Timestamp) ParseDate
func (ts *Timestamp) ParseDate(dateStr string) error
parseDate attempts to parse a date string in ISO 8601 format first, then falls back to MySQL DATETIME format.
func (*Timestamp) UnmarshalJSON
func (ts *Timestamp) UnmarshalJSON(b []byte) error
type User
type User struct {
*SnipeIT `json:",inline"`
Activated bool `json:"activated"` // Specifies if the user is active or not
Address string `json:"address,omitempty"` // Address of the user
AssetsCount int64 `json:"assets_count,omitempty"` // Number of assets associated with the user
AutoassignLicenses bool `json:"autoassign_licenses,omitempty"` // Specifies if the licenses are automatically assigned to the user
Avatar string `json:"avatar,omitempty"` // URL of the user's avatar
City string `json:"city,omitempty"` // City of the user
ConsumablesCount int64 `json:"consumables_count,omitempty"` // Count of consumables associated with the user
Country string `json:"country,omitempty"` // Country of the user
CreatedBy *DateInfo `json:"created_by,omitempty"` // Who created the user
Email string `json:"email,omitempty"` // Email of the user
EmployeeNum string `json:"employee_num,omitempty"` // Employee number of the user
EndDate *DateInfo `json:"end_date,omitempty"` // End date of the user
FirstName string `json:"first_name,omitempty"` // First name of the user
Groups interface{} `json:"groups,omitempty"` // Groups that the user belongs to
ID int64 `json:"id,omitempty"` // ID of the user
Jobtitle string `json:"jobtitle,omitempty"` // Job title of the user
LastLogin string `json:"last_login,omitempty"` // Last login time of the user
LastName string `json:"last_name,omitempty"` // Last name of the user
LdapImport bool `json:"ldap_import,omitempty"` // Specifies if the user is imported from LDAP
Locale string `json:"locale,omitempty"` // Locale of the user
Name string `json:"name,omitempty"` // Full name of the user
Notes string `json:"notes,omitempty"` // Notes associated with the user
Permissions map[string]string `json:"permissions,omitempty"` // Permissions of the user
Phone string `json:"phone,omitempty"` // Phone number of the user
Remote bool `json:"remote,omitempty"` // Specifies if the user is remote
StartDate *DateInfo `json:"start_date,omitempty"` // Start date of the user
State string `json:"state,omitempty"` // State of the user
TwoFactorEnrolled bool `json:"two_factor_enrolled,omitempty"` // Specifies if the user has enrolled for two factor authentication
TwoFactorOptin bool `json:"two_factor_optin,omitempty"` // Specifies if the user has opted for two factor authentication
Username string `json:"username,omitempty"` // Username of the user
Vip bool `json:"vip,omitempty"` // Specifies if the user is a VIP
Website string `json:"website,omitempty"` // Website of the user
Zip string `json:"zip,omitempty"` // Zip code of the user
}
type UserList
### Users -------------------------------------------------------------------------
type UserList = PaginatedList[User]
Generated by gomarkdoc