bovine.activitystreams
bovine.activitystreams
Actor
dataclass
Bases: WithPublicKey
, Controller
Actor class represents the basic ActivityStreams actor.
>>> actor = Actor(id="http://actor.example",
... inbox="http://actor.example/inbox",
... outbox="http://actor.example/outbox")
>>> actor.build()
{'@context': 'https://www.w3.org/ns/activitystreams',
'id': 'http://actor.example',
'type': 'Person',
'inbox': 'http://actor.example/inbox',
'outbox': 'http://actor.example/outbox'}
By using properties, one can specify additional information, e.g.
>>> actor = Actor(id="http://actor.example",
... properties={"@context": {"PropertyValue": "https://schema.org/PropertyValue",
... "value": "https://schema.org/value"},
... "attachment": [{"type": "PropertyValue",
... "name": "key", "value": "value"}]})
>>> actor.build()
{'@context': ['https://www.w3.org/ns/activitystreams',
{'PropertyValue': 'https://schema.org/PropertyValue', 'value': 'https://schema.org/value'}],
'attachment': [{'type': 'PropertyValue',
'name': 'key',
'value': 'value'}],
'id': 'http://actor.example',
'type': 'Person',
'inbox': 'http://actor.example',
'outbox': 'http://actor.example'}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
assertion_method
|
List[Multikey]
|
Built-in mutable sequence. If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified. |
<dynamic>
|
authentication
|
List[Multikey]
|
Built-in mutable sequence. If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified. |
<dynamic>
|
public_key
|
str | None
|
|
None
|
public_key_name
|
str | None
|
|
None
|
id
|
str | None
|
|
None
|
type
|
str
|
|
'Person'
|
name
|
str | None
|
Display name used fro the actor. |
None
|
preferred_username
|
str | None
|
|
None
|
inbox
|
str | None
|
URI of the inbox |
None
|
outbox
|
str | None
|
URI of the outbox |
None
|
followers
|
str | None
|
URI of the followers collection |
None
|
following
|
str | None
|
URI of the following collection |
None
|
event_source
|
str | None
|
|
None
|
proxy_url
|
str | None
|
|
None
|
summary
|
str | None
|
Short description of the actor |
None
|
icon
|
dict | None
|
|
None
|
url
|
str | None
|
URL of the actor |
None
|
Source code in bovine/bovine/activitystreams/__init__.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
|
build
build(visibility: Visibility = PUBLIC) -> dict
Creates the json-ld representation of the actor.
>>> actor = Actor(id="http://actor.example",
... inbox="http://actor.example/inbox",
... outbox="http://actor.example/outbox",
... followers="http://actor.example/followers",
... public_key="PEM", public_key_name="name")
>>> actor.build(visibility=Visibility.WEB)
{'@context': ['https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'],
'publicKey': {'id': 'http://actor.example#name',
'owner': 'http://actor.example',
'publicKeyPem': 'PEM'},
'id': 'http://actor.example',
'type': 'Person'}
>>> actor.build(visibility=Visibility.PUBLIC)
{'@context': ['https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'],
'publicKey': {'id': 'http://actor.example#name',
'owner': 'http://actor.example',
'publicKeyPem': 'PEM'},
'id': 'http://actor.example',
'type': 'Person',
'inbox': 'http://actor.example/inbox',
'outbox': 'http://actor.example/outbox'}
>>> actor.build(visibility=Visibility.OWNER)
{'@context': ['https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1'],
'publicKey': {'id': 'http://actor.example#name',
'owner': 'http://actor.example',
'publicKeyPem': 'PEM'},
'id': 'http://actor.example',
'type': 'Person',
'inbox': 'http://actor.example/inbox',
'outbox': 'http://actor.example/outbox',
'followers': 'http://actor.example/followers'}
Note
The visibility parameter might change if the community decides on best practices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
visibility
|
Visibility
|
Determines which properties of the actor to show |
PUBLIC
|
Source code in bovine/bovine/activitystreams/__init__.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
Collection
dataclass
Represents a Collection
See Collection
>>> Collection("http://list.example",
... items=["http://item.example"]).build()
{'@context': 'https://www.w3.org/ns/activitystreams',
'id': 'http://list.example',
'type': 'Collection',
'items': ['http://item.example']}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
|
required |
items
|
list
|
|
required |
Source code in bovine/bovine/activitystreams/__init__.py
OrderedCollection
dataclass
Represents an OrderedCollection
See Collection
>>> OrderedCollection("http://list.example").build()
{'@context': 'https://www.w3.org/ns/activitystreams',
'id': 'http://list.example',
'type': 'OrderedCollection'}
One can set totalItems
via count
>>> OrderedCollection("http://list.example", count=0).build()
{'@context': 'https://www.w3.org/ns/activitystreams',
'id': 'http://list.example',
'type': 'OrderedCollection',
'totalItems': 0}
If items is set, count is automatically updated
>>> OrderedCollection("http://list.example",
... items=["http://item.example"]).build()
{'@context': 'https://www.w3.org/ns/activitystreams',
'id': 'http://list.example',
'type': 'OrderedCollection',
'totalItems': 1,
'orderedItems': ['http://item.example']}
Finally, one can use this as
>>> OrderedCollection("http://list.example",
... first="http://list.example/first",
... last="http://list.example/last").build()
{'@context': 'https://www.w3.org/ns/activitystreams',
'id': 'http://list.example',
'type': 'OrderedCollection',
'first': 'http://list.example/first',
'last': 'http://list.example/last'}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
|
required |
items
|
list | None
|
|
None
|
count
|
int | None
|
|
None
|
first
|
str | None
|
|
None
|
last
|
str | None
|
|
None
|
Source code in bovine/bovine/activitystreams/__init__.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
|
OrderedCollectionPage
dataclass
Represents an OrderedCollectionPage
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
|
required |
items
|
list
|
|
required |
part_of
|
str
|
|
required |
next
|
str | None
|
|
None
|
prev
|
str | None
|
|
None
|
Source code in bovine/bovine/activitystreams/__init__.py
WithPublicKey
dataclass
Represents an object having a legacy public key specified under the publicKey
key
Parameters:
Name | Type | Description | Default |
---|---|---|---|
public_key
|
str | None
|
|
None
|
public_key_name
|
str | None
|
|
None
|
Source code in bovine/bovine/activitystreams/__init__.py
factories_for_actor_object
factories_for_actor_object(
actor_profile: dict,
id_generator: Callable[[], str] | None = None,
) -> Tuple[ActivityFactory, ObjectFactory]
Builds activity and object factories from actor object
Parameters:
Name | Type | Description | Default |
---|---|---|---|
actor_profile
|
dict
|
The actor profile as a dictionary |
required |
id_generator
|
Callable[[], str] | None
|
A function returning an id for objects |
None
|
Returns:
Type | Description |
---|---|
Tuple[ActivityFactory, ObjectFactory]
|
Activity- and object factory |