Documentation ¶
Index ¶
- func CheckResponse(r *http.Response) error
- func Stringify(message interface{}) string
- type Client
- type Error
- type ErrorResponse
- type ListOptions
- type OTXPulseDetailService
- type OTXThreatIntelFeedService
- type OTXUserDetailService
- type PulseDetail
- type Response
- type ThreatIntelFeed
- type Timestamp
- type UserDetail
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. API error responses are expected to have either no response body, or a JSON response body that maps to ErrorResponse. Any other response body will be silently ignored.
Types ¶
type Client ¶
type Client struct { // Base URL for API requests. Defaults to the otx.alienvault.com:443. // BaseURL should always be specified with a trailing slash BaseURL *url.URL UserAgent string // OTX API Services UserDetail *OTXUserDetailService PulseDetail *OTXPulseDetailService ThreatIntel *OTXThreatIntelFeedService // contains filtered or unexported fields }
A Client manages communication with the OTX API.
func NewClient ¶
NewClient returns a new OTX API client. If a nil httpClient is provided, http.DefaultClient will be used.
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.
func (*Client) NewRequest ¶
NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
type ErrorResponse ¶
type ErrorResponse struct { Response *http.Response // HTTP response that caused this error Message string `json:"detail"` // error message }
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string
type ListOptions ¶
type ListOptions struct { // For paginated result sets, page of results to retrieve. Page int `url:"page,omitempty"` // For paginated result sets, the number of results to include per page. PerPage int `url:"limit,omitempty"` }
ListOptions specifies the optional parameters to various List methods that support pagination. our list options: ?limit=50&page_num=1
type OTXPulseDetailService ¶
type OTXPulseDetailService struct {
// contains filtered or unexported fields
}
func (*OTXPulseDetailService) Get ¶
func (c *OTXPulseDetailService) Get(id_string string) (PulseDetail, Response, error)
type OTXThreatIntelFeedService ¶
type OTXThreatIntelFeedService struct {
// contains filtered or unexported fields
}
func (*OTXThreatIntelFeedService) List ¶
func (c *OTXThreatIntelFeedService) List(opt *ListOptions) (ThreatIntelFeed, Response, error)
type OTXUserDetailService ¶
type OTXUserDetailService struct {
// contains filtered or unexported fields
}
func (*OTXUserDetailService) Get ¶
func (c *OTXUserDetailService) Get() (UserDetail, *Response, error)
type PulseDetail ¶
type PulseDetail struct { ID *string `json:"id"` Author *string `json:"author_name"` Name *string `json:"name"` Description *string `json:"description,omitempty"` CreatedAt *string `json:"created,omitempty"` ModifiedAt *string `json:"modified"` References []string `json:"references,omitempty"` Tags []string `json:"tags,omitempty"` Indicators []struct { ID *string `json:"_id"` Indicator *string `json:"indicator"` Type *string `json:"type"` Description *string `json:"description,omitempty"` } `json:"indicators,omitempty"` Revision *float32 `json:"revision,omitempty"` }
Pulse represents an OTX Pulse
func (PulseDetail) String ¶
func (r PulseDetail) String() string
type Response ¶
type Response struct { *http.Response // RawContent - raw stream RawContent []uint8 // Content - additional way to access the content body of the response. Content map[string]interface{} `json:"results,omitempty"` }
Response is a otx API response. This wraps the standard http.Response returned from OTX and provides convenient access to things like pagination links.
type ThreatIntelFeed ¶
type ThreatIntelFeed struct { Pulses []PulseDetail `json:"results"` // These fields provide the page values for paginating through a set of // results. Any or all of these may be set to the zero value for // responses that are not part of a paginated set, or for which there // are no additional pages. //NextPageNum int Coming soon //PrevPageNum int Coming soon NextPageString *string `json:"next"` PrevPageString *string `json:"prev"` Count int `json:"count"` }
func (ThreatIntelFeed) String ¶
func (r ThreatIntelFeed) String() string
type Timestamp ¶
Timestamp represents a time that can be unmarshalled from a JSON string formatted as either an RFC3339 or Unix timestamp. This is necessary for some fields since the GitHub API is inconsistent in how it represents times. All exported methods of time.Time can be called on Timestamp.
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. Time is expected in RFC3339 or Unix format.
type UserDetail ¶
type UserDetail struct { AwardCount *int `json:"award_count"` FollowerCount *int `json:"follower_count"` SubscriberCount *int `json:"subscriber_count"` IndicatorCount *int `json:"indicator_count"` PulseCount *int `json:"pulse_count"` MemberSince *string `json:"member_since"` UserId *int `json:"user_id"` Username *string `json:"username"` }
func (UserDetail) String ¶
func (r UserDetail) String() string