Class: ModerationAPI::Resources::Wordlist

Inherits:
Object
  • Object
show all
Defined in:
lib/moderation_api/resources/wordlist.rb,
lib/moderation_api/resources/wordlist/words.rb

Defined Under Namespace

Classes: Words

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Wordlist

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Wordlist.

Parameters:



105
106
107
108
# File 'lib/moderation_api/resources/wordlist.rb', line 105

def initialize(client:)
  @client = client
  @words = ModerationAPI::Resources::Wordlist::Words.new(client: client)
end

Instance Attribute Details

#wordsModerationAPI::Resources::Wordlist::Words (readonly)



7
8
9
# File 'lib/moderation_api/resources/wordlist.rb', line 7

def words
  @words
end

Instance Method Details

#get_embedding_status(id, request_options: {}) ⇒ ModerationAPI::Models::WordlistGetEmbeddingStatusResponse

Get the current embedding progress status for a wordlist

Parameters:

Returns:

See Also:



93
94
95
96
97
98
99
100
# File 'lib/moderation_api/resources/wordlist.rb', line 93

def get_embedding_status(id, params = {})
  @client.request(
    method: :get,
    path: ["wordlist/%1$s/embedding-status", id],
    model: ModerationAPI::Models::WordlistGetEmbeddingStatusResponse,
    options: params[:request_options]
  )
end

#list(request_options: {}) ⇒ Array<ModerationAPI::Models::WordlistListResponseItem>

List all wordlists for the authenticated organization

Parameters:

Returns:

See Also:



73
74
75
76
77
78
79
80
# File 'lib/moderation_api/resources/wordlist.rb', line 73

def list(params = {})
  @client.request(
    method: :get,
    path: "wordlist",
    model: ModerationAPI::Internal::Type::ArrayOf[ModerationAPI::Models::WordlistListResponseItem],
    options: params[:request_options]
  )
end

#retrieve(id, request_options: {}) ⇒ ModerationAPI::Models::WordlistRetrieveResponse

Get a specific wordlist by ID

Parameters:

Returns:

See Also:



20
21
22
23
24
25
26
27
# File 'lib/moderation_api/resources/wordlist.rb', line 20

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["wordlist/%1$s", id],
    model: ModerationAPI::Models::WordlistRetrieveResponse,
    options: params[:request_options]
  )
end

#update(id, description: nil, key: nil, name: nil, strict: nil, words: nil, request_options: {}) ⇒ ModerationAPI::Models::WordlistUpdateResponse

Some parameter documentations has been truncated, see Models::WordlistUpdateParams for more details.

Update a wordlist

Parameters:

  • id (String)

    ID of the wordlist to update

  • description (String)

    New description for the wordlist

  • key (String)

    New key for the wordlist

  • name (String)

    New name for the wordlist

  • strict (Boolean)

    Deprecated. Now using threshold in project settings.

  • words (Array<String>)

    New words for the wordlist. Replace the existing words with these new ones. Dupl

  • request_options (ModerationAPI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



53
54
55
56
57
58
59
60
61
62
# File 'lib/moderation_api/resources/wordlist.rb', line 53

def update(id, params = {})
  parsed, options = ModerationAPI::WordlistUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["wordlist/%1$s", id],
    body: parsed,
    model: ModerationAPI::Models::WordlistUpdateResponse,
    options: options
  )
end