Best Python code snippet using slash
schemas.py
Source:schemas.py
1from django.urls import reverse_lazy2SCHEMAS = [3 {4 u"attributes": [5 {6 u"caseExact": False,7 u"description": u"An HTTP-addressable URL pointing to the service provider's human-consumable help documentation.",8 u"multiValued": False,9 u"mutability": u"readOnly",10 u"name": u"documentationUri",11 u"referenceTypes": [u"external"],12 u"required": False,13 u"returned": u"default",14 u"type": u"reference",15 u"uniqueness": u"none",16 },17 {18 u"description": u"A complex type that specifies PATCH configuration options.",19 u"multiValued": False,20 u"mutability": u"readOnly",21 u"name": u"patch",22 u"required": True,23 u"returned": u"default",24 u"subAttributes": [25 {26 u"description": u"A Boolean value specifying whether or not the operation is supported.",27 u"multiValued": False,28 u"mutability": u"readOnly",29 u"name": u"supported",30 u"required": True,31 u"returned": u"default",32 u"type": u"boolean",33 }34 ],35 u"type": u"complex",36 },37 {38 u"description": u"A complex type that specifies bulk configuration options.",39 u"multiValued": False,40 u"mutability": u"readOnly",41 u"name": u"bulk",42 u"required": True,43 u"returned": u"default",44 u"subAttributes": [45 {46 u"description": u"A Boolean value specifying whether or not the operation is supported.",47 u"multiValued": False,48 u"mutability": u"readOnly",49 u"name": u"supported",50 u"required": True,51 u"returned": u"default",52 u"type": u"boolean",53 },54 {55 u"description": u"An integer value specifying the maximum number of operations.",56 u"multiValued": False,57 u"mutability": u"readOnly",58 u"name": u"maxOperations",59 u"required": True,60 u"returned": u"default",61 u"type": u"integer",62 u"uniqueness": u"none",63 },64 {65 u"description": u"An integer value specifying the maximum payload size in bytes.",66 u"multiValued": False,67 u"mutability": u"readOnly",68 u"name": u"maxPayloadSize",69 u"required": True,70 u"returned": u"default",71 u"type": u"integer",72 u"uniqueness": u"none",73 },74 ],75 u"type": u"complex",76 },77 {78 u"description": u"A complex type that specifies FILTER options.",79 u"multiValued": False,80 u"mutability": u"readOnly",81 u"name": u"filter",82 u"required": True,83 u"returned": u"default",84 u"subAttributes": [85 {86 u"description": u"A Boolean value specifying whether or not the operation is supported.",87 u"multiValued": False,88 u"mutability": u"readOnly",89 u"name": u"supported",90 u"required": True,91 u"returned": u"default",92 u"type": u"boolean",93 },94 {95 u"description": u"An integer value specifying the maximum number of resources returned in a response.",96 u"multiValued": False,97 u"mutability": u"readOnly",98 u"name": u"maxResults",99 u"required": True,100 u"returned": u"default",101 u"type": u"integer",102 u"uniqueness": u"none",103 },104 ],105 u"type": u"complex",106 },107 {108 u"description": u"A complex type that specifies configuration options related to changing a password.",109 u"multiValued": False,110 u"mutability": u"readOnly",111 u"name": u"changePassword",112 u"required": True,113 u"returned": u"default",114 u"subAttributes": [115 {116 u"description": u"A Boolean value specifying whether or not the operation is supported.",117 u"multiValued": False,118 u"mutability": u"readOnly",119 u"name": u"supported",120 u"required": True,121 u"returned": u"default",122 u"type": u"boolean",123 }124 ],125 u"type": u"complex",126 },127 {128 u"description": u"A complex type that specifies sort result options.",129 u"multiValued": False,130 u"mutability": u"readOnly",131 u"name": u"sort",132 u"required": True,133 u"returned": u"default",134 u"subAttributes": [135 {136 u"description": u"A Boolean value specifying whether or not the operation is supported.",137 u"multiValued": False,138 u"mutability": u"readOnly",139 u"name": u"supported",140 u"required": True,141 u"returned": u"default",142 u"type": u"boolean",143 }144 ],145 u"type": u"complex",146 },147 {148 u"description": u"A complex type that specifies supported authentication scheme properties.",149 u"multiValued": True,150 u"mutability": u"readOnly",151 u"name": u"authenticationSchemes",152 u"required": True,153 u"returned": u"default",154 u"subAttributes": [155 {156 u"caseExact": False,157 u"description": u"The common authentication scheme name, e.g., HTTP Basic.",158 u"multiValued": False,159 u"mutability": u"readOnly",160 u"name": u"name",161 u"required": True,162 u"returned": u"default",163 u"type": u"string",164 u"uniqueness": u"none",165 },166 {167 u"caseExact": False,168 u"description": u"A description of the authentication scheme.",169 u"multiValued": False,170 u"mutability": u"readOnly",171 u"name": u"description",172 u"required": True,173 u"returned": u"default",174 u"type": u"string",175 u"uniqueness": u"none",176 },177 {178 u"caseExact": False,179 u"description": u"An HTTP-addressable URL pointing to the authentication scheme's specification.",180 u"multiValued": False,181 u"mutability": u"readOnly",182 u"name": u"specUri",183 u"referenceTypes": [u"external"],184 u"required": False,185 u"returned": u"default",186 u"type": u"reference",187 u"uniqueness": u"none",188 },189 {190 u"caseExact": False,191 u"description": u"An HTTP-addressable URL pointing to the authentication scheme's usage documentation.",192 u"multiValued": False,193 u"mutability": u"readOnly",194 u"name": u"documentationUri",195 u"referenceTypes": [u"external"],196 u"required": False,197 u"returned": u"default",198 u"type": u"reference",199 u"uniqueness": u"none",200 },201 ],202 u"type": u"complex",203 },204 ],205 u"description": u"Schema for representing the service provider's configuration",206 u"id": u"urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig",207 "meta": {208 u"location": reverse_lazy(209 "scim-schema-detail",210 args=("urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig",),211 ),212 u"resourceType": u"Schema",213 },214 u"name": u"Service Provider Configuration",215 },216 {217 u"attributes": [218 {219 u"caseExact": False,220 u"description": u"The unique URI of the schema. When applicable, service providers MUST specify the URI.",221 u"multiValued": False,222 u"mutability": u"readOnly",223 u"name": u"id",224 u"required": True,225 u"returned": u"default",226 u"type": u"string",227 u"uniqueness": u"none",228 },229 {230 u"caseExact": False,231 u"description": u"The schema's human-readable name. When applicable, service providers MUST specify the name, e.g., 'User'.",232 u"multiValued": False,233 u"mutability": u"readOnly",234 u"name": u"name",235 u"required": True,236 u"returned": u"default",237 u"type": u"string",238 u"uniqueness": u"none",239 },240 {241 u"caseExact": False,242 u"description": u"The schema's human-readable name. When applicable, service providers MUST specify the name, e.g., 'User'.",243 u"multiValued": False,244 u"mutability": u"readOnly",245 u"name": u"description",246 u"required": False,247 u"returned": u"default",248 u"type": u"string",249 u"uniqueness": u"none",250 },251 {252 u"description": u"A complex attribute that includes the attributes of a schema.",253 u"multiValued": True,254 u"mutability": u"readOnly",255 u"name": u"attributes",256 u"required": True,257 u"returned": u"default",258 u"subAttributes": [259 {260 u"caseExact": True,261 u"description": u"The attribute's name.",262 u"multiValued": False,263 u"mutability": u"readOnly",264 u"name": u"name",265 u"required": True,266 u"returned": u"default",267 u"type": u"string",268 u"uniqueness": u"none",269 },270 {271 u"canonicalValues": [272 u"string",273 u"complex",274 u"boolean",275 u"decimal",276 u"integer",277 u"dateTime",278 u"reference",279 ],280 u"caseExact": False,281 u"description": u"The attribute's data type. Valid values include 'string', 'complex', 'boolean', 'decimal', 'integer', 'dateTime', 'reference'.",282 u"multiValued": False,283 u"mutability": u"readOnly",284 u"name": u"type",285 u"required": True,286 u"returned": u"default",287 u"type": u"string",288 u"uniqueness": u"none",289 },290 {291 u"description": u"A Boolean value indicating an attribute's plurality.",292 u"multiValued": False,293 u"mutability": u"readOnly",294 u"name": u"multiValued",295 u"required": True,296 u"returned": u"default",297 u"type": u"boolean",298 },299 {300 u"caseExact": True,301 u"description": u"A human-readable description of the attribute.",302 u"multiValued": False,303 u"mutability": u"readOnly",304 u"name": u"description",305 u"required": False,306 u"returned": u"default",307 u"type": u"string",308 u"uniqueness": u"none",309 },310 {311 u"description": u"A boolean value indicating whether or not the attribute is required.",312 u"multiValued": False,313 u"mutability": u"readOnly",314 u"name": u"required",315 u"required": False,316 u"returned": u"default",317 u"type": u"boolean",318 },319 {320 u"caseExact": True,321 u"description": u"A collection of canonical values. When applicable, service providers MUST specify the canonical types, e.g., 'work', 'home'.",322 u"multiValued": True,323 u"mutability": u"readOnly",324 u"name": u"canonicalValues",325 u"required": False,326 u"returned": u"default",327 u"type": u"string",328 u"uniqueness": u"none",329 },330 {331 u"description": u"A Boolean value indicating whether or not a string attribute is case sensitive.",332 u"multiValued": False,333 u"mutability": u"readOnly",334 u"name": u"caseExact",335 u"required": False,336 u"returned": u"default",337 u"type": u"boolean",338 },339 {340 u"canonicalValues": [341 u"readOnly",342 u"readWrite",343 u"immutable",344 u"writeOnly",345 ],346 u"caseExact": True,347 u"description": u"Indicates whether or not an attribute is modifiable.",348 u"multiValued": False,349 u"mutability": u"readOnly",350 u"name": u"mutability",351 u"required": False,352 u"returned": u"default",353 u"type": u"string",354 u"uniqueness": u"none",355 },356 {357 u"canonicalValues": [358 u"always",359 u"never",360 u"default",361 u"request",362 ],363 u"caseExact": True,364 u"description": u"Indicates when an attribute is returned in a response (e.g., to a query).",365 u"multiValued": False,366 u"mutability": u"readOnly",367 u"name": u"returned",368 u"required": False,369 u"returned": u"default",370 u"type": u"string",371 u"uniqueness": u"none",372 },373 {374 u"canonicalValues": [u"none", u"server", u"global"],375 u"caseExact": True,376 u"description": u"Indicates how unique a value must be.",377 u"multiValued": False,378 u"mutability": u"readOnly",379 u"name": u"uniqueness",380 u"required": False,381 u"returned": u"default",382 u"type": u"string",383 u"uniqueness": u"none",384 },385 {386 u"caseExact": True,387 u"description": u"Used only with an attribute of type 'reference'. Specifies a SCIM resourceType that a reference attribute MAY refer to, e.g., 'User'.",388 u"multiValued": True,389 u"mutability": u"readOnly",390 u"name": u"referenceTypes",391 u"required": False,392 u"returned": u"default",393 u"type": u"string",394 u"uniqueness": u"none",395 },396 {397 u"description": u"Used to define the sub-attributes of a complex attribute.",398 u"multiValued": True,399 u"mutability": u"readOnly",400 u"name": u"subAttributes",401 u"required": False,402 u"returned": u"default",403 u"subAttributes": [404 {405 u"caseExact": True,406 u"description": u"The attribute's name.",407 u"multiValued": False,408 u"mutability": u"readOnly",409 u"name": u"name",410 u"required": True,411 u"returned": u"default",412 u"type": u"string",413 u"uniqueness": u"none",414 },415 {416 u"canonicalValues": [417 u"string",418 u"complex",419 u"boolean",420 u"decimal",421 u"integer",422 u"dateTime",423 u"reference",424 ],425 u"caseExact": False,426 u"description": u"The attribute's data type. Valid values include 'string', 'complex', 'boolean', 'decimal', 'integer', 'dateTime', 'reference'.",427 u"multiValued": False,428 u"mutability": u"readOnly",429 u"name": u"type",430 u"required": True,431 u"returned": u"default",432 u"type": u"string",433 u"uniqueness": u"none",434 },435 {436 u"description": u"A Boolean value indicating an attribute's plurality.",437 u"multiValued": False,438 u"mutability": u"readOnly",439 u"name": u"multiValued",440 u"required": True,441 u"returned": u"default",442 u"type": u"boolean",443 },444 {445 u"caseExact": True,446 u"description": u"A human-readable description of the attribute.",447 u"multiValued": False,448 u"mutability": u"readOnly",449 u"name": u"description",450 u"required": False,451 u"returned": u"default",452 u"type": u"string",453 u"uniqueness": u"none",454 },455 {456 u"description": u"A boolean value indicating whether or not the attribute is required.",457 u"multiValued": False,458 u"mutability": u"readOnly",459 u"name": u"required",460 u"required": False,461 u"returned": u"default",462 u"type": u"boolean",463 },464 {465 u"caseExact": True,466 u"description": u"A collection of canonical values. When applicable, service providers MUST specify the canonical types, e.g., 'work', 'home'.",467 u"multiValued": True,468 u"mutability": u"readOnly",469 u"name": u"canonicalValues",470 u"required": False,471 u"returned": u"default",472 u"type": u"string",473 u"uniqueness": u"none",474 },475 {476 u"description": u"A Boolean value indicating whether or not a string attribute is case sensitive.",477 u"multiValued": False,478 u"mutability": u"readOnly",479 u"name": u"caseExact",480 u"required": False,481 u"returned": u"default",482 u"type": u"boolean",483 },484 {485 u"canonicalValues": [486 u"readOnly",487 u"readWrite",488 u"immutable",489 u"writeOnly",490 ],491 u"caseExact": True,492 u"description": u"Indicates whether or not an attribute is modifiable.",493 u"multiValued": False,494 u"mutability": u"readOnly",495 u"name": u"mutability",496 u"required": False,497 u"returned": u"default",498 u"type": u"string",499 u"uniqueness": u"none",500 },501 {502 u"canonicalValues": [503 u"always",504 u"never",505 u"default",506 u"request",507 ],508 u"caseExact": True,509 u"description": u"Indicates when an attribute is returned in a response (e.g., to a query).",510 u"multiValued": False,511 u"mutability": u"readOnly",512 u"name": u"returned",513 u"required": False,514 u"returned": u"default",515 u"type": u"string",516 u"uniqueness": u"none",517 },518 {519 u"canonicalValues": [u"none", u"server", u"global"],520 u"caseExact": True,521 u"description": u"Indicates how unique a value must be.",522 u"multiValued": False,523 u"mutability": u"readOnly",524 u"name": u"uniqueness",525 u"required": False,526 u"returned": u"default",527 u"type": u"string",528 u"uniqueness": u"none",529 },530 {531 u"caseExact": True,532 u"description": u"Used only with an attribute of type 'reference'. Specifies a SCIM resourceType that a reference attribute MAY refer to, e.g., 'User'.",533 u"multiValued": False,534 u"mutability": u"readOnly",535 u"name": u"referenceTypes",536 u"required": False,537 u"returned": u"default",538 u"type": u"string",539 u"uniqueness": u"none",540 },541 ],542 u"type": u"complex",543 },544 ],545 u"type": u"complex",546 },547 ],548 u"description": u"Specifies the schema that describes a SCIM schema",549 u"id": u"urn:ietf:params:scim:schemas:core:2.0:Schema",550 "meta": {551 u"location": reverse_lazy(552 "scim-schema-detail",553 args=("urn:ietf:params:scim:schemas:core:2.0:Schema",),554 ),555 u"resourceType": u"Schema",556 },557 u"name": u"Schema",558 },559 {560 u"attributes": [561 {562 u"caseExact": False,563 u"description": u"Unique identifier for the User, typically used by the user to directly authenticate to the service provider. Each User MUST include a non-empty userName value. This identifier MUST be unique across the service provider's entire set of Users. REQUIRED.",564 u"multiValued": False,565 u"mutability": u"readWrite",566 u"name": u"userName",567 u"required": False,568 u"returned": u"default",569 u"type": u"string",570 u"uniqueness": u"server",571 },572 {573 u"description": u"The components of the user's real name. Providers MAY return just the full name as a single string in the formatted sub-attribute, or they MAY return just the individual component attributes using the other sub-attributes, or they MAY return both. If both variants are returned, they SHOULD be describing the same name, with the formatted name indicating how the component attributes should be combined.",574 u"multiValued": False,575 u"mutability": u"readWrite",576 u"name": u"name",577 u"required": False,578 u"returned": u"default",579 u"subAttributes": [580 {581 u"caseExact": False,582 u"description": u"The full name, including all middle names, titles, and suffixes as appropriate, formatted for display (e.g., 'Ms. Barbara J Jensen, III').",583 u"multiValued": False,584 u"mutability": u"readWrite",585 u"name": u"formatted",586 u"required": False,587 u"returned": u"default",588 u"type": u"string",589 u"uniqueness": u"none",590 },591 {592 u"caseExact": False,593 u"description": u"The family name of the User, or last name in most Western languages (e.g., 'Jensen' given the full name 'Ms. Barbara J Jensen, III').",594 u"multiValued": False,595 u"mutability": u"readWrite",596 u"name": u"familyName",597 u"required": False,598 u"returned": u"default",599 u"type": u"string",600 u"uniqueness": u"none",601 },602 {603 u"caseExact": False,604 u"description": u"The given name of the User, or first name in most Western languages (e.g., 'Barbara' given the full name 'Ms. Barbara J Jensen, III').",605 u"multiValued": False,606 u"mutability": u"readWrite",607 u"name": u"givenName",608 u"required": False,609 u"returned": u"default",610 u"type": u"string",611 u"uniqueness": u"none",612 },613 {614 u"caseExact": False,615 u"description": u"The middle name(s) of the User (e.g., 'Jane' given the full name 'Ms. Barbara J Jensen, III').",616 u"multiValued": False,617 u"mutability": u"readWrite",618 u"name": u"middleName",619 u"required": False,620 u"returned": u"default",621 u"type": u"string",622 u"uniqueness": u"none",623 },624 {625 u"caseExact": False,626 u"description": u"The honorific prefix(es) of the User, or title in most Western languages (e.g., 'Ms.' given the full name 'Ms. Barbara J Jensen, III').",627 u"multiValued": False,628 u"mutability": u"readWrite",629 u"name": u"honorificPrefix",630 u"required": False,631 u"returned": u"default",632 u"type": u"string",633 u"uniqueness": u"none",634 },635 {636 u"caseExact": False,637 u"description": u"The honorific suffix(es) of the User, or suffix in most Western languages (e.g., 'III' given the full name 'Ms. Barbara J Jensen, III').",638 u"multiValued": False,639 u"mutability": u"readWrite",640 u"name": u"honorificSuffix",641 u"required": False,642 u"returned": u"default",643 u"type": u"string",644 u"uniqueness": u"none",645 },646 ],647 u"type": u"complex",648 u"uniqueness": u"none",649 },650 {651 u"caseExact": False,652 u"description": u"The name of the User, suitable for display to end-users. The name SHOULD be the full name of the User being described, if known.",653 u"multiValued": False,654 u"mutability": u"readWrite",655 u"name": u"displayName",656 u"required": False,657 u"returned": u"default",658 u"type": u"string",659 u"uniqueness": u"none",660 },661 {662 u"caseExact": False,663 u"description": u"The casual way to address the user in real life, e.g., 'Bob' or 'Bobby' instead of 'Robert'. This attribute SHOULD NOT be used to represent a User's username (e.g., 'bjensen' or 'mpepperidge').",664 u"multiValued": False,665 u"mutability": u"readWrite",666 u"name": u"nickName",667 u"required": False,668 u"returned": u"default",669 u"type": u"string",670 u"uniqueness": u"none",671 },672 {673 u"caseExact": False,674 u"description": u"A fully qualified URL pointing to a page representing the User's online profile.",675 u"multiValued": False,676 u"mutability": u"readWrite",677 u"name": u"profileUrl",678 u"referenceTypes": [u"external"],679 u"required": False,680 u"returned": u"default",681 u"type": u"reference",682 u"uniqueness": u"none",683 },684 {685 u"caseExact": False,686 u"description": u'The user\'s title, such as "Vice President."',687 u"multiValued": False,688 u"mutability": u"readWrite",689 u"name": u"title",690 u"required": False,691 u"returned": u"default",692 u"type": u"string",693 u"uniqueness": u"none",694 },695 {696 u"caseExact": False,697 u"description": u"Used to identify the relationship between the organization and the user. Typical values used might be 'Contractor', 'Employee', 'Intern', 'Temp', 'External', and 'Unknown', but any value may be used.",698 u"multiValued": False,699 u"mutability": u"readWrite",700 u"name": u"userType",701 u"required": False,702 u"returned": u"default",703 u"type": u"string",704 u"uniqueness": u"none",705 },706 {707 u"caseExact": False,708 u"description": u"Indicates the User's preferred written or spoken language. Generally used for selecting a localized user interface; e.g., 'en_US' specifies the language English and country US.",709 u"multiValued": False,710 u"mutability": u"readWrite",711 u"name": u"preferredLanguage",712 u"required": False,713 u"returned": u"default",714 u"type": u"string",715 u"uniqueness": u"none",716 },717 {718 u"caseExact": False,719 u"description": u"Used to indicate the User's default location for purposes of localizing items such as currency, date time format, or numerical representations.",720 u"multiValued": False,721 u"mutability": u"readWrite",722 u"name": u"locale",723 u"required": False,724 u"returned": u"default",725 u"type": u"string",726 u"uniqueness": u"none",727 },728 {729 u"caseExact": False,730 u"description": u"The User's time zone in the 'Olson' time zone database format, e.g., 'America/Los_Angeles'.",731 u"multiValued": False,732 u"mutability": u"readWrite",733 u"name": u"timezone",734 u"required": False,735 u"returned": u"default",736 u"type": u"string",737 u"uniqueness": u"none",738 },739 {740 u"description": u"A Boolean value indicating the User's administrative status.",741 u"multiValued": False,742 u"mutability": u"readWrite",743 u"name": u"active",744 u"required": False,745 u"returned": u"default",746 u"type": u"boolean",747 },748 {749 u"caseExact": False,750 u"description": u"The User's cleartext password. This attribute is intended to be used as a means to specify an initial password when creating a new User or to reset an existing User's password.",751 u"multiValued": False,752 u"mutability": u"writeOnly",753 u"name": u"password",754 u"required": False,755 u"returned": u"never",756 u"type": u"string",757 u"uniqueness": u"none",758 },759 {760 u"description": u"Email addresses for the user. The value SHOULD be canonicalized by the service provider, e.g., 'bjensen@example.com' instead of 'bjensen@EXAMPLE.COM'. Canonical type values of 'work', 'home', and 'other'.",761 u"multiValued": True,762 u"mutability": u"readWrite",763 u"name": u"emails",764 u"required": False,765 u"returned": u"default",766 u"subAttributes": [767 {768 u"caseExact": False,769 u"description": u"Email addresses for the user. The value SHOULD be canonicalized by the service provider, e.g., 'bjensen@example.com' instead of 'bjensen@EXAMPLE.COM'. Canonical type values of 'work', 'home', and 'other'.",770 u"multiValued": False,771 u"mutability": u"readWrite",772 u"name": u"value",773 u"required": False,774 u"returned": u"default",775 u"type": u"string",776 u"uniqueness": u"none",777 },778 {779 u"caseExact": False,780 u"description": u"A human-readable name, primarily used for display purposes. READ-ONLY.",781 u"multiValued": False,782 u"mutability": u"readWrite",783 u"name": u"display",784 u"required": False,785 u"returned": u"default",786 u"type": u"string",787 u"uniqueness": u"none",788 },789 {790 u"canonicalValues": [u"work", u"home", u"other"],791 u"caseExact": False,792 u"description": u"A label indicating the attribute's function, e.g., 'work' or 'home'.",793 u"multiValued": False,794 u"mutability": u"readWrite",795 u"name": u"type",796 u"required": False,797 u"returned": u"default",798 u"type": u"string",799 u"uniqueness": u"none",800 },801 {802 u"description": u"A Boolean value indicating the 'primary' or preferred attribute value for this attribute, e.g., the preferred mailing address or primary email address. The primary attribute value 'true' MUST appear no more than once.",803 u"multiValued": False,804 u"mutability": u"readWrite",805 u"name": u"primary",806 u"required": False,807 u"returned": u"default",808 u"type": u"boolean",809 },810 ],811 u"type": u"complex",812 u"uniqueness": u"none",813 },814 {815 u"description": u"Phone numbers for the User. The value SHOULD be canonicalized by the service provider according to the format specified in RFC 3966, e.g., 'tel:+1-201-555-0123'. Canonical type values of 'work', 'home', 'mobile', 'fax', 'pager', and 'other'.",816 u"multiValued": True,817 u"mutability": u"readWrite",818 u"name": u"phoneNumbers",819 u"required": False,820 u"returned": u"default",821 u"subAttributes": [822 {823 u"caseExact": False,824 u"description": u"Phone number of the User.",825 u"multiValued": False,826 u"mutability": u"readWrite",827 u"name": u"value",828 u"required": False,829 u"returned": u"default",830 u"type": u"string",831 u"uniqueness": u"none",832 },833 {834 u"caseExact": False,835 u"description": u"A human-readable name, primarily used for display purposes. READ-ONLY.",836 u"multiValued": False,837 u"mutability": u"readWrite",838 u"name": u"display",839 u"required": False,840 u"returned": u"default",841 u"type": u"string",842 u"uniqueness": u"none",843 },844 {845 u"canonicalValues": [846 u"work",847 u"home",848 u"mobile",849 u"fax",850 u"pager",851 u"other",852 ],853 u"caseExact": False,854 u"description": u"A label indicating the attribute's function, e.g., 'work', 'home', 'mobile'.",855 u"multiValued": False,856 u"mutability": u"readWrite",857 u"name": u"type",858 u"required": False,859 u"returned": u"default",860 u"type": u"string",861 u"uniqueness": u"none",862 },863 {864 u"description": u"A Boolean value indicating the 'primary' or preferred attribute value for this attribute, e.g., the preferred phone number or primary phone number. The primary attribute value 'true' MUST appear no more than once.",865 u"multiValued": False,866 u"mutability": u"readWrite",867 u"name": u"primary",868 u"required": False,869 u"returned": u"default",870 u"type": u"boolean",871 },872 ],873 u"type": u"complex",874 },875 {876 u"description": u"Instant messaging addresses for the User.",877 u"multiValued": True,878 u"mutability": u"readWrite",879 u"name": u"ims",880 u"required": False,881 u"returned": u"default",882 u"subAttributes": [883 {884 u"caseExact": False,885 u"description": u"Instant messaging address for the User.",886 u"multiValued": False,887 u"mutability": u"readWrite",888 u"name": u"value",889 u"required": False,890 u"returned": u"default",891 u"type": u"string",892 u"uniqueness": u"none",893 },894 {895 u"caseExact": False,896 u"description": u"A human-readable name, primarily used for display purposes. READ-ONLY.",897 u"multiValued": False,898 u"mutability": u"readWrite",899 u"name": u"display",900 u"required": False,901 u"returned": u"default",902 u"type": u"string",903 u"uniqueness": u"none",904 },905 {906 u"canonicalValues": [907 u"aim",908 u"gtalk",909 u"icq",910 u"xmpp",911 u"msn",912 u"skype",913 u"qq",914 u"yahoo",915 ],916 u"caseExact": False,917 u"description": u"A label indicating the attribute's function, e.g., 'aim', 'gtalk', 'xmpp'.",918 u"multiValued": False,919 u"mutability": u"readWrite",920 u"name": u"type",921 u"required": False,922 u"returned": u"default",923 u"type": u"string",924 u"uniqueness": u"none",925 },926 {927 u"description": u"A Boolean value indicating the 'primary' or preferred attribute value for this attribute, e.g., the preferred messenger or primary messenger. The primary attribute value 'true' MUST appear no more than once.",928 u"multiValued": False,929 u"mutability": u"readWrite",930 u"name": u"primary",931 u"required": False,932 u"returned": u"default",933 u"type": u"boolean",934 },935 ],936 u"type": u"complex",937 },938 {939 u"description": u"URLs of photos of the User.",940 u"multiValued": True,941 u"mutability": u"readWrite",942 u"name": u"photos",943 u"required": False,944 u"returned": u"default",945 u"subAttributes": [946 {947 u"caseExact": False,948 u"description": u"URL of a photo of the User.",949 u"multiValued": False,950 u"mutability": u"readWrite",951 u"name": u"value",952 u"referenceTypes": [u"external"],953 u"required": False,954 u"returned": u"default",955 u"type": u"reference",956 u"uniqueness": u"none",957 },958 {959 u"caseExact": False,960 u"description": u"A human-readable name, primarily used for display purposes. READ-ONLY.",961 u"multiValued": False,962 u"mutability": u"readWrite",963 u"name": u"display",964 u"required": False,965 u"returned": u"default",966 u"type": u"string",967 u"uniqueness": u"none",968 },969 {970 u"canonicalValues": [u"photo", u"thumbnail"],971 u"caseExact": False,972 u"description": u"A label indicating the attribute's function, i.e., 'photo' or 'thumbnail'.",973 u"multiValued": False,974 u"mutability": u"readWrite",975 u"name": u"type",976 u"required": False,977 u"returned": u"default",978 u"type": u"string",979 u"uniqueness": u"none",980 },981 {982 u"description": u"A Boolean value indicating the 'primary' or preferred attribute value for this attribute, e.g., the preferred photo or thumbnail. The primary attribute value 'true' MUST appear no more than once.",983 u"multiValued": False,984 u"mutability": u"readWrite",985 u"name": u"primary",986 u"required": False,987 u"returned": u"default",988 u"type": u"boolean",989 },990 ],991 u"type": u"complex",992 },993 {994 u"description": u"A physical mailing address for this User. Canonical type values of 'work', 'home', and 'other'. This attribute is a complex type with the following sub-attributes.",995 u"multiValued": True,996 u"mutability": u"readWrite",997 u"name": u"addresses",998 u"required": False,999 u"returned": u"default",1000 u"subAttributes": [1001 {1002 u"caseExact": False,1003 u"description": u"The full mailing address, formatted for display or use with a mailing label. This attribute MAY contain newlines.",1004 u"multiValued": False,1005 u"mutability": u"readWrite",1006 u"name": u"formatted",1007 u"required": False,1008 u"returned": u"default",1009 u"type": u"string",1010 u"uniqueness": u"none",1011 },1012 {1013 u"caseExact": False,1014 u"description": u"The full street address component, which may include house number, street name, P.O. box, and multi-line extended street address information. This attribute MAY contain newlines.",1015 u"multiValued": False,1016 u"mutability": u"readWrite",1017 u"name": u"streetAddress",1018 u"required": False,1019 u"returned": u"default",1020 u"type": u"string",1021 u"uniqueness": u"none",1022 },1023 {1024 u"caseExact": False,1025 u"description": u"The city or locality component.",1026 u"multiValued": False,1027 u"mutability": u"readWrite",1028 u"name": u"locality",1029 u"required": False,1030 u"returned": u"default",1031 u"type": u"string",1032 u"uniqueness": u"none",1033 },1034 {1035 u"caseExact": False,1036 u"description": u"The state or region component.",1037 u"multiValued": False,1038 u"mutability": u"readWrite",1039 u"name": u"region",1040 u"required": False,1041 u"returned": u"default",1042 u"type": u"string",1043 u"uniqueness": u"none",1044 },1045 {1046 u"caseExact": False,1047 u"description": u"The zip code or postal code component.",1048 u"multiValued": False,1049 u"mutability": u"readWrite",1050 u"name": u"postalCode",1051 u"required": False,1052 u"returned": u"default",1053 u"type": u"string",1054 u"uniqueness": u"none",1055 },1056 {1057 u"caseExact": False,1058 u"description": u"The country name component.",1059 u"multiValued": False,1060 u"mutability": u"readWrite",1061 u"name": u"country",1062 u"required": False,1063 u"returned": u"default",1064 u"type": u"string",1065 u"uniqueness": u"none",1066 },1067 {1068 u"canonicalValues": [u"work", u"home", u"other"],1069 u"caseExact": False,1070 u"description": u"A label indicating the attribute's function, e.g., 'work' or 'home'.",1071 u"multiValued": False,1072 u"mutability": u"readWrite",1073 u"name": u"type",1074 u"required": False,1075 u"returned": u"default",1076 u"type": u"string",1077 u"uniqueness": u"none",1078 },1079 ],1080 u"type": u"complex",1081 u"uniqueness": u"none",1082 },1083 {1084 u"description": u"A list of groups to which the user belongs, either through direct membership, through nested groups, or dynamically calculated.",1085 u"multiValued": True,1086 u"mutability": u"readOnly",1087 u"name": u"groups",1088 u"required": False,1089 u"returned": u"default",1090 u"subAttributes": [1091 {1092 u"caseExact": False,1093 u"description": u"The identifier of the User's group.",1094 u"multiValued": False,1095 u"mutability": u"readOnly",1096 u"name": u"value",1097 u"required": False,1098 u"returned": u"default",1099 u"type": u"string",1100 u"uniqueness": u"none",1101 },1102 {1103 u"caseExact": False,1104 u"description": u"The URI of the corresponding 'Group' resource to which the user belongs.",1105 u"multiValued": False,1106 u"mutability": u"readOnly",1107 u"name": u"$ref",1108 u"referenceTypes": [u"User", u"Group"],1109 u"required": False,1110 u"returned": u"default",1111 u"type": u"reference",1112 u"uniqueness": u"none",1113 },1114 {1115 u"caseExact": False,1116 u"description": u"A human-readable name, primarily used for display purposes. READ-ONLY.",1117 u"multiValued": False,1118 u"mutability": u"readOnly",1119 u"name": u"display",1120 u"required": False,1121 u"returned": u"default",1122 u"type": u"string",1123 u"uniqueness": u"none",1124 },1125 {1126 u"canonicalValues": [u"direct", u"indirect"],1127 u"caseExact": False,1128 u"description": u"A label indicating the attribute's function, e.g., 'direct' or 'indirect'.",1129 u"multiValued": False,1130 u"mutability": u"readOnly",1131 u"name": u"type",1132 u"required": False,1133 u"returned": u"default",1134 u"type": u"string",1135 u"uniqueness": u"none",1136 },1137 ],1138 u"type": u"complex",1139 },1140 {1141 u"description": u"A list of entitlements for the User that represent a thing the User has.",1142 u"multiValued": True,1143 u"mutability": u"readWrite",1144 u"name": u"entitlements",1145 u"required": False,1146 u"returned": u"default",1147 u"subAttributes": [1148 {1149 u"caseExact": False,1150 u"description": u"The value of an entitlement.",1151 u"multiValued": False,1152 u"mutability": u"readWrite",1153 u"name": u"value",1154 u"required": False,1155 u"returned": u"default",1156 u"type": u"string",1157 u"uniqueness": u"none",1158 },1159 {1160 u"caseExact": False,1161 u"description": u"A human-readable name, primarily used for display purposes. READ-ONLY.",1162 u"multiValued": False,1163 u"mutability": u"readWrite",1164 u"name": u"display",1165 u"required": False,1166 u"returned": u"default",1167 u"type": u"string",1168 u"uniqueness": u"none",1169 },1170 {1171 u"caseExact": False,1172 u"description": u"A label indicating the attribute's function.",1173 u"multiValued": False,1174 u"mutability": u"readWrite",1175 u"name": u"type",1176 u"required": False,1177 u"returned": u"default",1178 u"type": u"string",1179 u"uniqueness": u"none",1180 },1181 {1182 u"description": u"A Boolean value indicating the 'primary' or preferred attribute value for this attribute. The primary attribute value 'true' MUST appear no more than once.",1183 u"multiValued": False,1184 u"mutability": u"readWrite",1185 u"name": u"primary",1186 u"required": False,1187 u"returned": u"default",1188 u"type": u"boolean",1189 },1190 ],1191 u"type": u"complex",1192 },1193 {1194 u"description": u"A list of roles for the User that collectively represent who the User is, e.g., 'Student', 'Faculty'.",1195 u"multiValued": True,1196 u"mutability": u"readWrite",1197 u"name": u"roles",1198 u"required": False,1199 u"returned": u"default",1200 u"subAttributes": [1201 {1202 u"caseExact": False,1203 u"description": u"The value of a role.",1204 u"multiValued": False,1205 u"mutability": u"readWrite",1206 u"name": u"value",1207 u"required": False,1208 u"returned": u"default",1209 u"type": u"string",1210 u"uniqueness": u"none",1211 },1212 {1213 u"caseExact": False,1214 u"description": u"A human-readable name, primarily used for display purposes. READ-ONLY.",1215 u"multiValued": False,1216 u"mutability": u"readWrite",1217 u"name": u"display",1218 u"required": False,1219 u"returned": u"default",1220 u"type": u"string",1221 u"uniqueness": u"none",1222 },1223 {1224 u"canonicalValues": [],1225 u"caseExact": False,1226 u"description": u"A label indicating the attribute's function.",1227 u"multiValued": False,1228 u"mutability": u"readWrite",1229 u"name": u"type",1230 u"required": False,1231 u"returned": u"default",1232 u"type": u"string",1233 u"uniqueness": u"none",1234 },1235 {1236 u"description": u"A Boolean value indicating the 'primary' or preferred attribute value for this attribute. The primary attribute value 'true' MUST appear no more than once.",1237 u"multiValued": False,1238 u"mutability": u"readWrite",1239 u"name": u"primary",1240 u"required": False,1241 u"returned": u"default",1242 u"type": u"boolean",1243 },1244 ],1245 u"type": u"complex",1246 },1247 {1248 u"caseExact": False,1249 u"description": u"A list of certificates issued to the User.",1250 u"multiValued": True,1251 u"mutability": u"readWrite",1252 u"name": u"x509Certificates",1253 u"required": False,1254 u"returned": u"default",1255 u"subAttributes": [1256 {1257 u"caseExact": False,1258 u"description": u"The value of an X.509 certificate.",1259 u"multiValued": False,1260 u"mutability": u"readWrite",1261 u"name": u"value",1262 u"required": False,1263 u"returned": u"default",1264 u"type": u"binary",1265 u"uniqueness": u"none",1266 },1267 {1268 u"caseExact": False,1269 u"description": u"A human-readable name, primarily used for display purposes. READ-ONLY.",1270 u"multiValued": False,1271 u"mutability": u"readWrite",1272 u"name": u"display",1273 u"required": False,1274 u"returned": u"default",1275 u"type": u"string",1276 u"uniqueness": u"none",1277 },1278 {1279 u"canonicalValues": [],1280 u"caseExact": False,1281 u"description": u"A label indicating the attribute's function.",1282 u"multiValued": False,1283 u"mutability": u"readWrite",1284 u"name": u"type",1285 u"required": False,1286 u"returned": u"default",1287 u"type": u"string",1288 u"uniqueness": u"none",1289 },1290 {1291 u"description": u"A Boolean value indicating the 'primary' or preferred attribute value for this attribute. The primary attribute value 'true' MUST appear no more than once.",1292 u"multiValued": False,1293 u"mutability": u"readWrite",1294 u"name": u"primary",1295 u"required": False,1296 u"returned": u"default",1297 u"type": u"boolean",1298 },1299 ],1300 u"type": u"complex",1301 },1302 ],1303 u"description": u"User Account",1304 u"id": u"urn:ietf:params:scim:schemas:core:2.0:User",1305 u"meta": {1306 u"location": reverse_lazy(1307 "scim-schema-detail",1308 args=("urn:ietf:params:scim:schemas:core:2.0:User",),1309 ),1310 u"resourceType": u"Schema",1311 },1312 u"name": u"User",1313 },1314 {1315 u"attributes": [1316 {1317 u"caseExact": False,1318 u"description": u"The resource type's server unique id. May be the same as the 'name' attribute.",1319 u"multiValued": False,1320 u"mutability": u"readOnly",1321 u"name": u"id",1322 u"required": False,1323 u"returned": u"default",1324 u"type": u"string",1325 u"uniqueness": u"none",1326 },1327 {1328 u"caseExact": False,1329 u"description": u"The resource type name. When applicable, service providers MUST specify the name, e.g., 'User'.",1330 u"multiValued": False,1331 u"mutability": u"readOnly",1332 u"name": u"name",1333 u"required": True,1334 u"returned": u"default",1335 u"type": u"string",1336 u"uniqueness": u"none",1337 },1338 {1339 u"caseExact": False,1340 u"description": u"The resource type's human-readable description. When applicable, service providers MUST specify the description.",1341 u"multiValued": False,1342 u"mutability": u"readOnly",1343 u"name": u"description",1344 u"required": False,1345 u"returned": u"default",1346 u"type": u"string",1347 u"uniqueness": u"none",1348 },1349 {1350 u"caseExact": False,1351 u"description": u"The resource type's HTTP-addressable endpoint relative to the Base URL, e.g., '/Users'.",1352 u"multiValued": False,1353 u"mutability": u"readOnly",1354 u"name": u"endpoint",1355 u"referenceTypes": [u"uri"],1356 u"required": True,1357 u"returned": u"default",1358 u"type": u"reference",1359 u"uniqueness": u"none",1360 },1361 {1362 u"caseExact": True,1363 u"description": u"The resource type's primary/base schema URI.",1364 u"multiValued": False,1365 u"mutability": u"readOnly",1366 u"name": u"schema",1367 u"referenceTypes": [u"uri"],1368 u"required": True,1369 u"returned": u"default",1370 u"type": u"reference",1371 u"uniqueness": u"none",1372 },1373 {1374 u"description": u"A list of URIs of the resource type's schema extensions.",1375 u"multiValued": False,1376 u"mutability": u"readOnly",1377 u"name": u"schemaExtensions",1378 u"required": True,1379 u"returned": u"default",1380 u"subAttributes": [1381 {1382 u"caseExact": True,1383 u"description": u"The URI of a schema extension.",1384 u"multiValued": False,1385 u"mutability": u"readOnly",1386 u"name": u"schema",1387 u"referenceTypes": [u"uri"],1388 u"required": True,1389 u"returned": u"default",1390 u"type": u"reference",1391 u"uniqueness": u"none",1392 },1393 {1394 u"description": u"A Boolean value that specifies whether or not the schema extension is required for the resource type. If true, a resource of this type MUST include this schema extension and also include any attributes declared as required in this schema extension. If false, a resource of this type MAY omit this schema extension.",1395 u"multiValued": False,1396 u"mutability": u"readOnly",1397 u"name": u"required",1398 u"required": True,1399 u"returned": u"default",1400 u"type": u"boolean",1401 },1402 ],1403 u"type": u"complex",1404 },1405 ],1406 u"description": u"Specifies the schema that describes a SCIM resource type",1407 u"id": u"urn:ietf:params:scim:schemas:core:2.0:ResourceType",1408 "meta": {1409 u"location": reverse_lazy(1410 "scim-schema-detail",1411 args=("urn:ietf:params:scim:schemas:core:2.0:ResourceType",),1412 ),1413 u"resourceType": u"Schema",1414 },1415 u"name": u"ResourceType",1416 },1417 {1418 u"attributes": [1419 {1420 u"caseExact": False,1421 u"description": u"A human-readable name for the Group. REQUIRED.",1422 u"multiValued": False,1423 u"mutability": u"readWrite",1424 u"name": u"displayName",1425 u"required": False,1426 u"returned": u"default",1427 u"type": u"string",1428 u"uniqueness": u"none",1429 },1430 {1431 u"description": u"A list of members of the Group.",1432 u"multiValued": True,1433 u"mutability": u"readWrite",1434 u"name": u"members",1435 u"required": False,1436 u"returned": u"default",1437 u"subAttributes": [1438 {1439 u"caseExact": False,1440 u"description": u"Identifier of the member of this Group.",1441 u"multiValued": False,1442 u"mutability": u"immutable",1443 u"name": u"value",1444 u"required": False,1445 u"returned": u"default",1446 u"type": u"string",1447 u"uniqueness": u"none",1448 },1449 {1450 u"caseExact": False,1451 u"description": u"The URI corresponding to a SCIM resource that is a member of this Group.",1452 u"multiValued": False,1453 u"mutability": u"immutable",1454 u"name": u"$ref",1455 u"referenceTypes": [u"User", u"Group"],1456 u"required": False,1457 u"returned": u"default",1458 u"type": u"reference",1459 u"uniqueness": u"none",1460 },1461 {1462 u"canonicalValues": [u"User", u"Group"],1463 u"caseExact": False,1464 u"description": u"A label indicating the type of resource, e.g., 'User' or 'Group'.",1465 u"multiValued": False,1466 u"mutability": u"immutable",1467 u"name": u"type",1468 u"required": False,1469 u"returned": u"default",1470 u"type": u"string",1471 u"uniqueness": u"none",1472 },1473 ],1474 u"type": u"complex",1475 },1476 ],1477 u"description": u"Group",1478 u"id": u"urn:ietf:params:scim:schemas:core:2.0:Group",1479 u"meta": {1480 u"location": reverse_lazy(1481 "scim-schema-detail",1482 args=("urn:ietf:params:scim:schemas:core:2.0:Group",),1483 ),1484 u"resourceType": u"Schema",1485 },1486 u"name": u"Group",1487 },1488 {1489 u"attributes": [1490 {1491 u"caseExact": False,1492 u"description": u"Numeric or alphanumeric identifier assigned to a person, typically based on order of hire or association with anorganization.",1493 u"multiValued": False,1494 u"mutability": u"readWrite",1495 u"name": u"employeeNumber",1496 u"required": False,1497 u"returned": u"default",1498 u"type": u"string",1499 u"uniqueness": u"none",1500 },1501 {1502 u"caseExact": False,1503 u"description": u"Identifies the name of a cost center.",1504 u"multiValued": False,1505 u"mutability": u"readWrite",1506 u"name": u"costCenter",1507 u"required": False,1508 u"returned": u"default",1509 u"type": u"string",1510 u"uniqueness": u"none",1511 },1512 {1513 u"caseExact": False,1514 u"description": u"Identifies the name of an organization.",1515 u"multiValued": False,1516 u"mutability": u"readWrite",1517 u"name": u"organization",1518 u"required": False,1519 u"returned": u"default",1520 u"type": u"string",1521 u"uniqueness": u"none",1522 },1523 {1524 u"caseExact": False,1525 u"description": u"Identifies the name of a division.",1526 u"multiValued": False,1527 u"mutability": u"readWrite",1528 u"name": u"division",1529 u"required": False,1530 u"returned": u"default",1531 u"type": u"string",1532 u"uniqueness": u"none",1533 },1534 {1535 u"caseExact": False,1536 u"description": u"Identifies the name of a department.",1537 u"multiValued": False,1538 u"mutability": u"readWrite",1539 u"name": u"department",1540 u"required": False,1541 u"returned": u"default",1542 u"type": u"string",1543 u"uniqueness": u"none",1544 },1545 {1546 u"description": u"The User's manager. A complex type that optionally allows service providers to represent organizational hierarchy by referencing the 'id' attribute of another User.",1547 u"multiValued": False,1548 u"mutability": u"readWrite",1549 u"name": u"manager",1550 u"required": False,1551 u"returned": u"default",1552 u"subAttributes": [1553 {1554 u"caseExact": False,1555 u"description": u"The id of the SCIM resource representingthe User's manager. REQUIRED.",1556 u"multiValued": False,1557 u"mutability": u"readWrite",1558 u"name": u"value",1559 u"required": False,1560 u"returned": u"default",1561 u"type": u"string",1562 u"uniqueness": u"none",1563 },1564 {1565 u"caseExact": False,1566 u"description": u"The URI of the SCIM resource representing the User's manager. REQUIRED.",1567 u"multiValued": False,1568 u"mutability": u"readWrite",1569 u"name": u"$ref",1570 u"referenceTypes": [u"User"],1571 u"required": False,1572 u"returned": u"default",1573 u"type": u"reference",1574 u"uniqueness": u"none",1575 },1576 {1577 u"caseExact": False,1578 u"description": u"The displayName of the User's manager. OPTIONAL and READ-ONLY.",1579 u"multiValued": False,1580 u"mutability": u"readOnly",1581 u"name": u"displayName",1582 u"required": False,1583 u"returned": u"default",1584 u"type": u"string",1585 u"uniqueness": u"none",1586 },1587 ],1588 u"type": u"complex",1589 },1590 ],1591 u"description": u"Enterprise User",1592 u"id": u"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User",1593 u"meta": {1594 u"location": u"/v2/Schemas/urn:ietf:params:scim:schemas:extension:enterprise:2.0:User",1595 u"resourceType": u"Schema",1596 },1597 u"name": u"EnterpriseUser",1598 },...
views.py
Source:views.py
1import requests2import json3import threading4import os5from django.shortcuts import render6from django.template.defaulttags import register7from django.http import HttpResponseRedirect8from django.urls import reverse9from socket import gaierror, gethostbyname10from multiprocessing.dummy import Pool as ThreadPool11from urllib.parse import urlparse12from time import gmtime, strftime13from .settings import refresh_interval, filename, site_down, number_threads, include_search14from .models import Site15from .forms import SearchForm16@register.filter17def get_item(dictionary, key):18 """ This is a custom filter for django templates allowing you to easily get19 a value from a dictionary."""20 return dictionary.get(key)21def is_reachable(url):22 """ This function checks to see if a host name has a DNS entry23 by checking for socket info."""24 try:25 gethostbyname(url)26 except gaierror:27 return False28 else:29 return True30def get_status_code(url):31 """ This function returns the status code of the url."""32 try:33 status_code = requests.get(url, timeout=30).status_code34 return status_code35 except requests.ConnectionError:36 return site_down37def check_single_url(url):38 """This function checks a single url and if connectable returns39 the status code, else returns variable site_down (default: UNREACHABLE)."""40 if is_reachable(urlparse(url).hostname) == True:41 return str(get_status_code(url))42 else:43 return site_down44def launch_checker():45 """This function launches the check_multiple_urls function every x seconds46 (defined in refresh interval variable)."""47 t = threading.Timer(refresh_interval, launch_checker)48 t.start()49 global returned_statuses50 global returned_uptimes51 returned_statuses = check_multiple_urls()52 returned_uptimes = update_uptimes()53def check_multiple_urls():54 """This function checks through urls specified in the checkurls.json file55 (specified in the filename variable) and56 returns their statuses as a dictionary."""57 statuses = {}58 temp_list_statuses = []59 global last_update_time60 pool = ThreadPool(number_threads)61 temp_list_statuses = pool.map(check_single_url, list_urls)62 for i in range(len(list_urls)):63 statuses[list_urls[i]] = temp_list_statuses[i]64 last_update_time = strftime("%Y-%m-%d %H:%M:%S", gmtime())65 return statuses66def update_uptimes():67 """ This function updates the db with the latest status codes and68 calculates the current % uptime, finally returning a dictionary containing69 urls and keys and uptimes as values. """70 uptimes = {}71 temp_list_uptimes = []72 for urly in list_urls:73 try:74 working_url = Site.objects.get(url=urly)75 except Site.DoesNotExist:76 working_url = Site()77 working_url.url = urly78 working_url.status = returned_statuses[urly]79 if returned_statuses[urly] == '200':80 working_url.was_checked += 181 working_url.was_up += 182 else:83 working_url.was_checked += 184 working_url.uptime = float((working_url.was_up / working_url.was_checked) * 100)85 working_url.save()86 temp_list_uptimes.append(working_url.uptime)87 for i in range(len(list_urls)):88 uptimes[list_urls[i]] = temp_list_uptimes[i]89 return uptimes90def compare_submitted(submitted):91 """This function checks whether the value in the dictionary is found in 92 the checkurls.json file. """93 stripped_submission = https_start_strip(submitted)94 if stripped_submission in list_urls:95 flaggy = True96 else:97 flaggy = False98 return (flaggy, stripped_submission)99def https_start_strip(url):100 """ This function strips whitespace from the user input and ensures the url101 starts with https/http."""102 url = url.strip().lower()103 if url[:7] == 'http://':104 return url105 elif url[:8] == 'https://':106 return url107 else:108 url = "https://" + url109 return url110def generate_list_urls(input_dict):111 """ Generates a current list of all urls in checkurls.json."""112 list_urls = []113 for group, urls in input_dict.items():114 for url in urls:115 list_urls.append(url)116 return list_urls117def index(request):118 """The home page for statuscheck"""119 form = SearchForm()120 context = {121 'form': form,122 'list_urls': list_urls,123 'last_update_time': last_update_time,124 'returned_statuses': returned_statuses,125 'checkurls': checkurls,126 'include_search': include_search, 'returned_uptimes': returned_uptimes127 }128 return render(request, 'statuscheck/index.html', context)129def result(request):130 """ Django view to return search results."""131 if request.method == 'POST':132 form = SearchForm(request.POST)133 if form.is_valid():134 results = compare_submitted(form.cleaned_data['submitted'])135 context = {136'results': results,137'last_update_time': last_update_time,138'returned_statuses': returned_statuses,139'checkurls': checkurls,140'include_search': include_search, 'returned_uptimes': returned_uptimes141}142 return render(request, 'statuscheck/index.html', context)143 else:144 return HttpResponseRedirect(reverse('statuscheck:index'))145### Get the current directory to open the checkurls.json file146module_dir = os.path.dirname(__file__)147file_path = os.path.join(module_dir, filename)148with open(file_path) as f:149 checkurls = json.load(f)150list_urls = generate_list_urls(checkurls)151returned_statuses = {}152returned_uptimes = {}153last_update_time = 'time string'...
rejection_resample_test.py
Source:rejection_resample_test.py
1# Copyright 2017 The TensorFlow Authors. All Rights Reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14# ==============================================================================15"""Tests for `tf.data.experimental.rejection_resample()`."""16from __future__ import absolute_import17from __future__ import division18from __future__ import print_function19from absl.testing import parameterized20import numpy as np21from tensorflow.python.data.experimental.ops import resampling22from tensorflow.python.data.kernel_tests import test_base23from tensorflow.python.data.ops import dataset_ops24from tensorflow.python.framework import combinations25from tensorflow.python.framework import dtypes26from tensorflow.python.framework import errors27from tensorflow.python.ops import math_ops28from tensorflow.python.ops import random_ops29from tensorflow.python.ops import string_ops30from tensorflow.python.platform import test31from tensorflow.python.util import compat32class RejectionResampleTest(test_base.DatasetTestBase, parameterized.TestCase):33 @combinations.generate(34 combinations.times(test_base.default_test_combinations(),35 combinations.combine(initial_known=[True, False])))36 def testDistribution(self, initial_known):37 classes = np.random.randint(5, size=(20000,)) # Uniformly sampled38 target_dist = [0.9, 0.05, 0.05, 0.0, 0.0]39 initial_dist = [0.2] * 5 if initial_known else None40 classes = math_ops.cast(classes, dtypes.int64) # needed for Windows build.41 dataset = dataset_ops.Dataset.from_tensor_slices(classes).shuffle(42 200, seed=21).map(lambda c: (c, string_ops.as_string(c))).repeat()43 get_next = self.getNext(44 dataset.apply(45 resampling.rejection_resample(46 target_dist=target_dist,47 initial_dist=initial_dist,48 class_func=lambda c, _: c,49 seed=27)))50 returned = []51 while len(returned) < 4000:52 returned.append(self.evaluate(get_next()))53 returned_classes, returned_classes_and_data = zip(*returned)54 _, returned_data = zip(*returned_classes_and_data)55 self.assertAllEqual([compat.as_bytes(str(c))56 for c in returned_classes], returned_data)57 total_returned = len(returned_classes)58 class_counts = np.array([59 len([True for v in returned_classes if v == c])60 for c in range(5)])61 returned_dist = class_counts / total_returned62 self.assertAllClose(target_dist, returned_dist, atol=1e-2)63 @combinations.generate(64 combinations.times(test_base.default_test_combinations(),65 combinations.combine(only_initial_dist=[True, False])))66 def testEdgeCasesSampleFromInitialDataset(self, only_initial_dist):67 init_dist = [0.5, 0.5]68 target_dist = [0.5, 0.5] if only_initial_dist else [0.0, 1.0]69 num_classes = len(init_dist)70 # We don't need many samples to test that this works.71 num_samples = 10072 data_np = np.random.choice(num_classes, num_samples, p=init_dist)73 dataset = dataset_ops.Dataset.from_tensor_slices(data_np)74 # Reshape distribution.75 dataset = dataset.apply(76 resampling.rejection_resample(77 class_func=lambda x: x,78 target_dist=target_dist,79 initial_dist=init_dist))80 get_next = self.getNext(dataset)81 returned = []82 with self.assertRaises(errors.OutOfRangeError):83 while True:84 returned.append(self.evaluate(get_next()))85 @combinations.generate(test_base.default_test_combinations())86 def testRandomClasses(self):87 init_dist = [0.25, 0.25, 0.25, 0.25]88 target_dist = [0.0, 0.0, 0.0, 1.0]89 num_classes = len(init_dist)90 # We don't need many samples to test a dirac-delta target distribution.91 num_samples = 10092 data_np = np.random.choice(num_classes, num_samples, p=init_dist)93 dataset = dataset_ops.Dataset.from_tensor_slices(data_np)94 # Apply a random mapping that preserves the data distribution.95 def _remap_fn(_):96 return math_ops.cast(random_ops.random_uniform([1]) * num_classes,97 dtypes.int32)[0]98 dataset = dataset.map(_remap_fn)99 # Reshape distribution.100 dataset = dataset.apply(101 resampling.rejection_resample(102 class_func=lambda x: x,103 target_dist=target_dist,104 initial_dist=init_dist))105 get_next = self.getNext(dataset)106 returned = []107 with self.assertRaises(errors.OutOfRangeError):108 while True:109 returned.append(self.evaluate(get_next()))110 classes, _ = zip(*returned)111 bincount = np.bincount(112 np.array(classes),113 minlength=num_classes).astype(np.float32) / len(classes)114 self.assertAllClose(target_dist, bincount, atol=1e-2)115if __name__ == "__main__":...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!