Parses the URL and returns enough arguments that can allow us to re- instantiate this object.
(url)
| 521 | |
| 522 | @staticmethod |
| 523 | def parse_url(url): |
| 524 | """Parses the URL and returns enough arguments that can allow us to re- |
| 525 | instantiate this object.""" |
| 526 | |
| 527 | results = NotifyBase.parse_url(url) |
| 528 | if not results: |
| 529 | # We're done early as we couldn't load the results |
| 530 | return results |
| 531 | |
| 532 | # Our URL looks like this: |
| 533 | # {schema}://{apikey}:{from_email}/{targets} |
| 534 | # |
| 535 | # which actually equates to: |
| 536 | # {schema}://{user}:{password}@{host}/{email1}/{email2}/etc.. |
| 537 | # ^ ^ ^ |
| 538 | # | | | |
| 539 | # apikey -from addr- |
| 540 | |
| 541 | if not results.get("user"): |
| 542 | # An API Key as not properly specified |
| 543 | return None |
| 544 | |
| 545 | if not results.get("password"): |
| 546 | # A From Email was not correctly specified |
| 547 | return None |
| 548 | |
| 549 | # Prepare our API Key |
| 550 | results["apikey"] = NotifySendGrid.unquote(results["user"]) |
| 551 | |
| 552 | # Prepare our From Email Address |
| 553 | results["from_email"] = "{}@{}".format( |
| 554 | NotifySendGrid.unquote(results["password"]), |
| 555 | NotifySendGrid.unquote(results["host"]), |
| 556 | ) |
| 557 | |
| 558 | # Acquire our targets |
| 559 | results["targets"] = NotifySendGrid.split_path(results["fullpath"]) |
| 560 | |
| 561 | # The 'to' makes it easier to use yaml configuration |
| 562 | if "to" in results["qsd"] and len(results["qsd"]["to"]): |
| 563 | results["targets"] += NotifySendGrid.parse_list( |
| 564 | results["qsd"]["to"] |
| 565 | ) |
| 566 | |
| 567 | # Handle Carbon Copy Addresses |
| 568 | if "cc" in results["qsd"] and len(results["qsd"]["cc"]): |
| 569 | results["cc"] = NotifySendGrid.parse_list(results["qsd"]["cc"]) |
| 570 | |
| 571 | # Handle Blind Carbon Copy Addresses |
| 572 | if "bcc" in results["qsd"] and len(results["qsd"]["bcc"]): |
| 573 | results["bcc"] = NotifySendGrid.parse_list(results["qsd"]["bcc"]) |
| 574 | |
| 575 | # Handle Blind Carbon Copy Addresses |
| 576 | if "template" in results["qsd"] and len(results["qsd"]["template"]): |
| 577 | results["template"] = NotifySendGrid.unquote( |
| 578 | results["qsd"]["template"] |
| 579 | ) |
| 580 |
nothing calls this directly
no test coverage detected