Class: PassiveTotal::Client::Artifact

Inherits:
Base
  • Object
show all
Defined in:
lib/passivetotal/clients/artifact.rb

Constant Summary

Constants inherited from Base

Base::BASE_URL, Base::HOST, Base::VERSION

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from PassiveTotal::Client::Base

Instance Method Details

#bulk_create(artifacts) ⇒ Hash

Parameters:

  • artifacts (Array<Hash>)

    a list of dictionaries that match the /v2/artifact interface (has query, type, tags, and project fields per dictionary)

Returns:

  • (Hash)


14
15
16
17
18
19
20
# File 'lib/passivetotal/clients/artifact.rb', line 14

def bulk_create(artifacts)
  params = {
    artifacts: artifacts,
  }.compact

  _put("/artifact/bulk", params) { |json| json }
end

#bulk_delete(artifacts) ⇒ Hash

Parameters:

  • artifacts (Array<String>)

    the artifact ids to delete

Returns:

  • (Hash)


30
31
32
33
34
35
36
# File 'lib/passivetotal/clients/artifact.rb', line 30

def bulk_delete(artifacts)
  params = {
    artifacts: artifacts,
  }.compact

  _delete("/artifact/bulk", params) { |json| json }
end

#bulk_update(artifacts) ⇒ Hash

Parameters:

  • artifacts (Array<Hash>)

    a list of dictionaries which match the fields for the /v2/artifact (artifact, monitor, tags)

Returns:

  • (Hash)


46
47
48
49
50
51
52
# File 'lib/passivetotal/clients/artifact.rb', line 46

def bulk_update(artifacts)
  params = {
    artifacts: artifacts,
  }.compact

  _post("/artifact/bulk", params) { |json| json }
end

#create(project:, query:, type: nil, tags: nil) ⇒ Hash

Parameters:

  • project (String)

    the project id the artifact will live on

  • query (String)

    the actual artifact query (passivetotal.org, 8.8.8.8, etc).

  • type (String, nil) (defaults to: nil)

    the type of the artifact (domain, ip, etc), or inferred by query string if domain or ip (optional).

  • tags (String, nil) (defaults to: nil)

    the tags the new artifact will have

Returns:

  • (Hash)


65
66
67
68
69
70
71
72
73
74
# File 'lib/passivetotal/clients/artifact.rb', line 65

def create(project:, query:, type: nil, tags: nil)
  params = {
    project: project,
    query: query,
    type: type,
    tags: tags,
  }.compact

  _put("/artifact", params) { |json| json }
end

#delete(artifact) ⇒ Hash

Parameters:

  • artifact (String)

    the artifact id

Returns:

  • (Hash)


84
85
86
87
88
89
90
# File 'lib/passivetotal/clients/artifact.rb', line 84

def delete(artifact)
  params = {
    artifact: artifact,
  }.compact

  _delete("/artifact", params) { |json| json }
end

#find(artifact: nil, project: nil, owner: nil, creator: nil, organization: nil, query: nil, type: nil) ⇒ Hash

Read existing artifacts. If no filters are passed, this returns all your personal artifacts created by you or your organization. api.passivetotal.org/api/docs/#api-Artifact-GetV2Artifact

Parameters:

  • artifact (String) (defaults to: nil)

    the artifact id

  • project (String) (defaults to: nil)

    filter by project id

  • owner (String) (defaults to: nil)

    filter by owner (an email or organization id)

  • creator (String) (defaults to: nil)

    filter by creator

  • organization (String) (defaults to: nil)

    filter by organization

  • query (String) (defaults to: nil)

    filter by query (passivetotal.org, etc)

  • type (String) (defaults to: nil)

    filter by artifact type (domain, ip, etc)

Returns:

  • (Hash)


106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/passivetotal/clients/artifact.rb', line 106

def find(artifact: nil, project: nil, owner: nil, creator: nil, organization: nil, query: nil, type: nil)
  params = {
    artifact: artifact,
    project: project,
    owner: owner,
    creator: creator,
    organization: organization,
    query: query,
    type: type,
  }.compact

  _get("/artifact", params) { |json| json }
end

#update(artifact, monitor: nil, tags: nil) ⇒ Hash

Update artifact, or toggle monitoring status. If you want to change the query or artifact type, simply delete it and create a new one. Use /v2/artifact/tag to add or delete tags without setting everything at once. api.passivetotal.org/api/docs/#api-Artifact-PostV2Artifact

Parameters:

  • artifact (String)

    the artifact id to update

  • monitor (String, nil) (defaults to: nil)

    whether to monitor the artifact

  • tags (Array<String>, nil) (defaults to: nil)

    sets the artifact’s tags to this list

Returns:

  • (Hash)


130
131
132
133
134
135
136
137
138
# File 'lib/passivetotal/clients/artifact.rb', line 130

def update(artifact, monitor: nil, tags: nil)
  params = {
    artifact: artifact,
    monitor: monitor,
    tags: tags,
  }.compact

  _post("/artifact", params) { |json| json }
end