Data Structures

pydantic model Topic[source]

Show JSON schema
{
   "title": "Topic",
   "type": "object",
   "properties": {
      "id": {
         "title": "Id",
         "type": "string"
      },
      "name": {
         "title": "Name",
         "type": "string"
      },
      "volume": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Volume"
      },
      "description": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Description"
      },
      "topic": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "title": "Topic"
      },
      "topicGroup": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "title": "Topicgroup"
      },
      "entityType": {
         "const": "TOPC",
         "default": "TOPC",
         "title": "Entitytype",
         "type": "string"
      }
   },
   "required": [
      "id",
      "name",
      "topic",
      "topicGroup"
   ]
}

Fields:
Validators:
field description: str | None = None
Validated by:
field entity_type: Literal['TOPC'] = 'TOPC' (alias 'entityType')
Validated by:
field id: str [Required]
Validated by:
field name: str [Required]
Validated by:
field topic: str | None [Required]
Validated by:
field topic_group: str | None [Required] (alias 'topicGroup')
Validated by:
field volume: int | None = None
Validated by:
validator apply_second_alias_generator  »  all fields[source]

Applied before validating to replace some alias in the input @values so we can make the model in 3 ways: snake_case/camel_case/alias. This is required because not all endpoints are resolving the groupN into the correct field name.

pydantic model Source[source]

A source of news and information for RavenPack

Show JSON schema
{
   "title": "Source",
   "description": "A source of news and information for RavenPack",
   "type": "object",
   "properties": {
      "id": {
         "title": "Id",
         "type": "string"
      },
      "name": {
         "title": "Name",
         "type": "string"
      },
      "volume": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Volume"
      },
      "description": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Description"
      },
      "entityType": {
         "const": "SRCE",
         "default": "SRCE",
         "title": "Entitytype",
         "type": "string"
      },
      "publicationType": {
         "title": "Publicationtype",
         "type": "string"
      },
      "language": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Language"
      },
      "country": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Country"
      },
      "sourceRank": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Sourcerank"
      },
      "providerId": {
         "title": "Providerid",
         "type": "string"
      },
      "url": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Url"
      }
   },
   "required": [
      "id",
      "name",
      "publicationType",
      "providerId"
   ]
}

Fields:
Validators:
field country: str | None = None
Validated by:
field description: str | None = None
Validated by:
field entity_type: Literal['SRCE'] = 'SRCE' (alias 'entityType')
Validated by:
field id: str [Required]
Validated by:
field language: str | None = None
Validated by:
field name: str [Required]
Validated by:
field provider_id: str [Required] (alias 'providerId')
Validated by:
field publication_type: str [Required] (alias 'publicationType')
Validated by:
field source_rank: str | None = None (alias 'sourceRank')
Validated by:
field url: str | None = None
Validated by:
field volume: int | None = None
Validated by:
validator apply_second_alias_generator  »  all fields[source]

Applied before validating to replace some alias in the input @values so we can make the model in 3 ways: snake_case/camel_case/alias. This is required because not all endpoints are resolving the groupN into the correct field name.

make_copy()[source]
Return type:

QueryComponent

to_expression()[source]
Return type:

Expression

pydantic model Language[source]

Show JSON schema
{
   "title": "Language",
   "type": "object",
   "properties": {
      "key": {
         "title": "Key",
         "type": "string"
      },
      "name": {
         "title": "Name",
         "type": "string"
      },
      "volume": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Volume"
      },
      "description": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Description"
      },
      "queryType": {
         "const": "language",
         "default": "language",
         "title": "Querytype",
         "type": "string"
      }
   },
   "required": [
      "key",
      "name"
   ]
}

Fields:
field description: str | None = None
field id: str [Required]
field name: str [Required]
field query_type: Literal['language'] = 'language'
field volume: int | None = None
make_copy()[source]
Return type:

QueryComponent

to_expression()[source]
Return type:

Expression

pydantic model Watchlist[source]

Used to represent a watchlist

Show JSON schema
{
   "title": "Watchlist",
   "description": "Used to represent a watchlist",
   "type": "object",
   "properties": {
      "key": {
         "title": "Key",
         "type": "string"
      },
      "name": {
         "title": "Name",
         "type": "string"
      },
      "dateCreated": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Datecreated"
      },
      "lastUpdated": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Lastupdated"
      },
      "queryType": {
         "const": "watchlist",
         "default": "watchlist",
         "title": "Querytype",
         "type": "string"
      },
      "companySharedPermission": {
         "$ref": "#/$defs/SharePermission",
         "default": "undefined"
      }
   },
   "$defs": {
      "SharePermission": {
         "enum": [
            "read",
            "undefined"
         ],
         "title": "SharePermission",
         "type": "string"
      }
   },
   "required": [
      "key",
      "name"
   ]
}

Fields:
field company_shared_permission: SharePermission = SharePermission.UNDEFINED (alias 'companySharedPermission')
field date_created: datetime | None = None (alias 'dateCreated')
field id: str [Required]
field last_updated: datetime | None = None (alias 'lastUpdated')
field name: str [Required]
field query_type: Literal['watchlist'] = 'watchlist' (alias 'queryType')
__init__(**kwargs)[source]

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

delete()[source]

Delete the watchlist

make_copy()[source]
Return type:

QueryComponent

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

Return type:

None

save()[source]

Save a watchlist

share_with_company()[source]

Share this watchlist with every member of the company

to_expression()[source]
Return type:

Expression

unshare_with_company()[source]

Stop sharing this watchlist with every member of the company

property items: list[str]
pydantic model File[source]

Representation of a file.

Show JSON schema
{
   "title": "File",
   "description": "Representation of a file.",
   "type": "object",
   "properties": {
      "id": {
         "title": "Id",
         "type": "string"
      },
      "name": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Name"
      },
      "status": {
         "anyOf": [
            {
               "$ref": "#/$defs/FileStatus"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "uploaded_at": {
         "anyOf": [
            {
               "format": "date-time",
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Uploaded At"
      },
      "raw_size": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Raw Size"
      },
      "folder_id": {
         "anyOf": [
            {
               "type": "string"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Folder Id"
      },
      "tags": {
         "items": {
            "type": "string"
         },
         "title": "Tags",
         "type": "array"
      },
      "company_shared_permission": {
         "anyOf": [
            {
               "$ref": "#/$defs/SharePermission"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      }
   },
   "$defs": {
      "FileStatus": {
         "enum": [
            "PENDING",
            "PROCESSING",
            "COMPLETED",
            "FAILED",
            "DELETED"
         ],
         "title": "FileStatus",
         "type": "string"
      },
      "SharePermission": {
         "enum": [
            "read",
            "undefined"
         ],
         "title": "SharePermission",
         "type": "string"
      }
   },
   "required": [
      "id"
   ]
}

Fields:
field company_shared_permission: SharePermission | None = None
field folder_id: str | None = None
field id: str [Required]
field name: str | None = None
field raw_size: int | None = None
field status: FileStatus | None = None
field tags: list[str] [Optional]
field uploaded_at: datetime | None = None
__init__(**data)[source]

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

add_tags(value)[source]

Add tags to a file.

Parameters:

value (list[str]) – Tags to be added.

Returns:

File information.

Return type:

dict

Raises:
  • ValueError – If ‘value’ parameter is not a list.

  • ValueError – If ‘value’ parameter is empty.

delete()[source]

Deletes the file from the server. The file must be fully processed before deleting.

download_analytics(filename)[source]

Downloads the analytics in the file.

Parameters:

filename (str) –

download_annotated(filename)[source]

Downloads the annotated version of the file.

Parameters:

filename (str) –

download_original(filename)[source]

Downloads the original content of the file.

Parameters:

filename (str) –

get_analytics_dict()[source]

Retrieves the analytics in the file, as a dictionary.

get_annotated_dict()[source]

Retrieves the annotated version of the file, as a dictionary.

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialise private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

Return type:

None

reload_status()[source]

Updates the status of the file.

remove_tags(value)[source]

Remove tags to a file.

Parameters:

value (list[str]) – Tags to be removed.

Returns:

File information.

Return type:

dict

Raises:
  • ValueError – If ‘value’ parameter is not a list.

  • ValueError – If ‘value’ parameter is empty.

set_tags(value)[source]

Remove tags to a file.

Parameters:

value (list[str]) – Tags to be removed.

Returns:

File information.

Return type:

dict

Raises:
  • ValueError – If ‘value’ parameter is not a list.

  • ValueError – If ‘value’ parameter is empty.

share_with_company()[source]

Shares a file with the whole company.

unshare_with_company()[source]

Stops sharing a file with the whole company.

wait_for_completion(timeout=None)[source]

Waits for the file to be completed.

Parameters:

timeout (int | None) –

pydantic model UploadQuota[source]

Show JSON schema
{
   "title": "UploadQuota",
   "type": "object",
   "properties": {
      "files": {
         "$ref": "#/$defs/UploadQuotaFiles"
      },
      "quota": {
         "$ref": "#/$defs/UploadQuotaSubscriptionUsage"
      }
   },
   "$defs": {
      "UploadQuotaFiles": {
         "properties": {
            "available": {
               "title": "Available",
               "type": "integer"
            },
            "error": {
               "title": "Error",
               "type": "integer"
            },
            "total": {
               "title": "Total",
               "type": "integer"
            }
         },
         "required": [
            "available",
            "error",
            "total"
         ],
         "title": "UploadQuotaFiles",
         "type": "object"
      },
      "UploadQuotaSubscriptionUsage": {
         "properties": {
            "current_month": {
               "$ref": "#/$defs/UploadQuotaUsage"
            },
            "subscription": {
               "$ref": "#/$defs/UploadQuotaUsage"
            }
         },
         "required": [
            "current_month",
            "subscription"
         ],
         "title": "UploadQuotaSubscriptionUsage",
         "type": "object"
      },
      "UploadQuotaUsage": {
         "properties": {
            "max_units_allowed": {
               "title": "Max Units Allowed",
               "type": "integer"
            },
            "storage_bytes_used": {
               "title": "Storage Bytes Used",
               "type": "integer"
            },
            "units_remaining": {
               "title": "Units Remaining",
               "type": "integer"
            },
            "units_used": {
               "title": "Units Used",
               "type": "integer"
            }
         },
         "required": [
            "max_units_allowed",
            "storage_bytes_used",
            "units_remaining",
            "units_used"
         ],
         "title": "UploadQuotaUsage",
         "type": "object"
      }
   },
   "required": [
      "files",
      "quota"
   ]
}

Fields:
field files: UploadQuotaFiles [Required]
field quota: UploadQuotaSubscriptionUsage [Required]
pydantic model UploadQuotaFiles[source]

Show JSON schema
{
   "title": "UploadQuotaFiles",
   "type": "object",
   "properties": {
      "available": {
         "title": "Available",
         "type": "integer"
      },
      "error": {
         "title": "Error",
         "type": "integer"
      },
      "total": {
         "title": "Total",
         "type": "integer"
      }
   },
   "required": [
      "available",
      "error",
      "total"
   ]
}

Fields:
field available: int [Required]
field error: int [Required]
field total: int [Required]
pydantic model UploadQuotaSubscriptionUsage[source]

Show JSON schema
{
   "title": "UploadQuotaSubscriptionUsage",
   "type": "object",
   "properties": {
      "current_month": {
         "$ref": "#/$defs/UploadQuotaUsage"
      },
      "subscription": {
         "$ref": "#/$defs/UploadQuotaUsage"
      }
   },
   "$defs": {
      "UploadQuotaUsage": {
         "properties": {
            "max_units_allowed": {
               "title": "Max Units Allowed",
               "type": "integer"
            },
            "storage_bytes_used": {
               "title": "Storage Bytes Used",
               "type": "integer"
            },
            "units_remaining": {
               "title": "Units Remaining",
               "type": "integer"
            },
            "units_used": {
               "title": "Units Used",
               "type": "integer"
            }
         },
         "required": [
            "max_units_allowed",
            "storage_bytes_used",
            "units_remaining",
            "units_used"
         ],
         "title": "UploadQuotaUsage",
         "type": "object"
      }
   },
   "required": [
      "current_month",
      "subscription"
   ]
}

Fields:
field current_month: UploadQuotaUsage [Required]
field subscription: UploadQuotaUsage [Required]
pydantic model UploadQuotaUsage[source]

Show JSON schema
{
   "title": "UploadQuotaUsage",
   "type": "object",
   "properties": {
      "max_units_allowed": {
         "title": "Max Units Allowed",
         "type": "integer"
      },
      "storage_bytes_used": {
         "title": "Storage Bytes Used",
         "type": "integer"
      },
      "units_remaining": {
         "title": "Units Remaining",
         "type": "integer"
      },
      "units_used": {
         "title": "Units Used",
         "type": "integer"
      }
   },
   "required": [
      "max_units_allowed",
      "storage_bytes_used",
      "units_remaining",
      "units_used"
   ]
}

Fields:
field max_units_allowed: int [Required]
field storage_bytes_used: int [Required]
field units_remaining: int [Required]
field units_used: int [Required]
human_readable_date(date)[source]

Returns a human readable date of the given date.

Parameters:

date (datetime) –

Return type:

str

human_readable_size(num_bytes)[source]

Returns a human readable string of the given size in bytes.

It displays the size in the highest unit possible

>>> human_readable_size(1)
'1'
>>> human_readable_size(32)
'32'
>>> human_readable_size(512 * 1024)
'512K'
>>> human_readable_size(3 * 1024 * 1024)
'3M'
>>> human_readable_size(1024 * 1024 * 1024)
'1G'

It only shows the decimal part for units between 1 and 9.9, and only if they are not 0:

>>> human_readable_size(1.1 * 1024)
'1.1K'
>>> human_readable_size(2.1 * 1024)
'2.1K'
>>> human_readable_size(9.9 * 1024)
'9.9K'
>>> human_readable_size(10.01 * 1024)
'10K'
>>> human_readable_size(52.5 * 1024)
'52K'
>>> human_readable_size(0.9 * 1024 * 1024)
'921K'

Finally, it rounds the number to the nearest integer

>>> human_readable_size(1000)
'1K'
>>> human_readable_size(1023)
'1K'
>>> human_readable_size(1024 * 1024 - 1)
'1M'
Parameters:

num_bytes (int) –

Return type:

str

padded(value, length)[source]

Returns a string with the given value padded to the right.

Parameters:
  • value (str) –

  • length (int) –

Return type:

str