Base Classes
All of the command/request/response classes for Broadworks are built on top of these base classes:
Broadworks OCI-P Interface Base Classes
Base classes used by the types, requests and responses as well as other components like ElementInfo that are used by those.
ElementInfo
ElementInfo - information on each element of a Broadsoft OCIType
Used to describe the element when serialising to/from XML
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
name of this element (in python snake case) |
xmlname |
str
|
name of this element (in Java like camel case) |
type |
the type of the resulting element |
|
is_complex |
bool
|
is this a complex element - containing another OCIType derived class |
is_required |
bool
|
Is this required (True) or Optional (False) |
is_array |
bool
|
Is this an array/list of element values |
is_table |
bool
|
Is this a Broadworks table type - only seen in Responses |
Source code in broadworks_ocip/base.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
ErrorResponse
Bases: OCIResponse
The ErrorResponse is concrete response sent whenever a transaction fails and does not return any data.
As this an error, when it is created from an incoming command response, a
OCIErrorResponse
exception is raised in post_xml_decode_
.
Attributes:
Name | Type | Description |
---|---|---|
error_code |
int
|
The error code |
summary |
str
|
Summary of the error |
summary_english |
str
|
Summary of the error in english! |
detail |
str
|
Detail of the error |
type |
str
|
Type of the error |
Source code in broadworks_ocip/base.py
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 |
|
post_xml_decode_()
Raise an exception as this is an error
Source code in broadworks_ocip/base.py
669 670 671 672 673 674 |
|
OCICommand
Bases: OCIType
OCICommand - base class for all OCI Command (Request/Response) types
Attributes:
Name | Type | Description |
---|---|---|
session_id |
str
|
The session ID used for the command exchange. We use UUIDs by default, although this is not required. The default is fixed on here (but normally passed in from the containing API object) - do not use the default in production - its simply there to give a known value for testing. |
Source code in broadworks_ocip/base.py
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 |
|
build_from_etree_non_parameters_(element, initialiser)
classmethod
Pick up the session id from the command set
Overrides the class method defined in OCIType.
Source code in broadworks_ocip/base.py
565 566 567 568 569 570 571 572 573 574 575 576 577 578 |
|
build_xml_()
Build an XML document of the current Command (Request/Response)
Returns:
Name | Type | Description |
---|---|---|
xml |
bytes
|
byte string containing XML document |
Source code in broadworks_ocip/base.py
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
|
build_xml_command_element_(root)
Build the XML etree of the main command element of the current Command Intended to be overridden in a subclass for the few elements that do things a little differently (for example errors).
Returns:
Name | Type | Description |
---|---|---|
wrapped_element |
_Element
|
The wrapped commane element tree |
Source code in broadworks_ocip/base.py
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
|
to_dict()
Convert object to dict representation of itself
This was provided as part of the Classforge system, which we have moved away from, so this is a local re-implementation. This is only used within the test suite at present.
Source code in broadworks_ocip/base.py
580 581 582 583 584 585 586 587 588 589 |
|
OCIRequest
Bases: OCICommand
OCIRequest - base class for all OCI Command Request types
Source code in broadworks_ocip/base.py
592 593 594 595 596 597 |
|
OCIResponse
Bases: OCICommand
OCIResponse - base class for all OCI Command Response types
Source code in broadworks_ocip/base.py
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 |
|
build_xml_command_element_(root)
Build the XML etree of the main command element of the current Command Responses have an echo attribute in the element.
Returns:
Name | Type | Description |
---|---|---|
etree |
_Element
|
The XML etree of the main command element |
Source code in broadworks_ocip/base.py
605 606 607 608 609 610 611 612 613 614 615 616 617 618 |
|
OCIType
OCIType - Base type for all the OCI-P component classes
There are no attributes of this base class (the _frozen
attribute is
used as a flag to lock the instance). The attributes are added in the
various subclasses.
Source code in broadworks_ocip/base.py
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 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 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 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 |
|
type_
property
Return the typename of the class
__repr__()
Convert object to string representation of itself.
Source code in broadworks_ocip/base.py
484 485 486 487 488 |
|
__str__()
Convert object to string representation of itself.
Source code in broadworks_ocip/base.py
490 491 492 |
|
build_from_etree_(api, element, extras={})
classmethod
Create an OciType based instance from an XML etree element
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element
|
_Element
|
The OCIType XML element |
required |
Returns:
Name | Type | Description |
---|---|---|
results |
Object instance for this class |
Source code in broadworks_ocip/base.py
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
|
build_from_etree_non_parameters_(element, initialiser)
classmethod
Handle any items outside the parameter set
Intended for use by subclasses where they need to take actions immediately after they are created from an incoming XML document.
Source code in broadworks_ocip/base.py
342 343 344 345 346 347 348 349 350 351 352 353 354 |
|
build_from_node_(api, elem, node)
classmethod
Creates an OCI subelement from a single XML etree node
Parameters:
Name | Type | Description | Default |
---|---|---|---|
elem
|
ElementInfo
|
The subelement descriptor |
required |
node
|
_Element
|
The OCITable XML element node |
required |
Returns:
Name | Type | Description |
---|---|---|
results |
Any
|
Object instance for this class |
Source code in broadworks_ocip/base.py
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 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
|
class_to_property_(name)
classmethod
Map a XML class name to the associated property
Source code in broadworks_ocip/base.py
159 160 161 162 |
|
column_header_snake_case_(header)
classmethod
Converts an XML name into a pythonic snake case name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
header
|
str
|
The header name in space separated words |
required |
Returns:
Name | Type | Description |
---|---|---|
snake |
str
|
lower cased and underscore separated result name |
Source code in broadworks_ocip/base.py
293 294 295 296 297 298 299 300 301 302 303 304 |
|
decode_table_(element)
classmethod
Decode a table (used in a OCIResponse) into a list of named tuples
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element
|
_Element
|
The OCITable XML element |
required |
Returns:
Name | Type | Description |
---|---|---|
results |
List[NamedTuple]
|
List of namedtuple elements, one for each table row |
Source code in broadworks_ocip/base.py
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
|
etree_components_(name=None)
Build XML etree element tree for this OCIType
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
The name or tag of the element - defaults to the |
None
|
Returns:
Name | Type | Description |
---|---|---|
etree |
etree.Element() for this class |
Source code in broadworks_ocip/base.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
etree_sub_components_(element)
Build XML etree subelements for the components within this OCIType
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element
|
_Element
|
The parent element that the components are to be attached to |
required |
Returns:
Name | Type | Description |
---|---|---|
etree |
_Element
|
etree.Element() for this class |
Source code in broadworks_ocip/base.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
|
etree_sub_element_(element, sub_element, value)
Build XML etree subelement for one element within this OCIType
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element
|
_Element
|
The parent element that the components are to be attached to |
required |
sub_element
|
ElementInfo
|
The definition of the sub element to be attached |
required |
value
|
Value of the sub element - quite possibly None |
required |
Returns:
Name | Type | Description |
---|---|---|
etree |
_Element
|
etree.Element() for this class |
Source code in broadworks_ocip/base.py
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 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
|
post_xml_decode_()
Carry out any operations after the XML decode
Intended for use by subclasses where they need to take actions immediately after they are created from an incoming XML document.
Source code in broadworks_ocip/base.py
164 165 166 167 168 169 170 171 |
|
snake_case_to_column_header(snake_str)
Converts a pythonic snake case name into a column header name
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snake_str
|
str
|
The header name in snake lower case |
required |
Returns:
Name | Type | Description |
---|---|---|
column_header |
str
|
initial capital and space separated result name |
Source code in broadworks_ocip/base.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
|
to_dict()
Convert object to dict representation of itself
This was provided as part of the Classforge system, which we have moved away from, so this is a local re-implementation. This is only used within the test suite at present.
Source code in broadworks_ocip/base.py
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 |
|
SuccessResponse
Bases: OCIResponse
The SuccessResponse is concrete response sent whenever a transaction is successful and does not return any data.
Source code in broadworks_ocip/base.py
621 622 623 624 625 626 627 628 629 630 631 |
|