Additional Actions

These are the additional Actions added by ScreenPy Requests.

AddHeader

Aliases: AddHeaders

class AddHeader(*header_pairs: str | Iterable, **header_kwargs: str)

Add one or more headers to the Actor’s API session.

Abilities Required:

MakeAPIRequests

Examples:

the_actor.attempts_to(AddHeader(Authorization=TOKEN_AUTH_STRING))

the_actor.attempts_to(
    AddHeader(Authorization=TOKEN_AUTH_STRING).which_should_be_kept_secret()
)

the_actor.attempts_to(AddHeader({"Authorization": TOKEN_AUTH_STRING}))

the_actor.attempts_to(AddHeader("Authorization", TOKEN_AUTH_STRING))

the_actor.attempts_to(
    AddHeaders(
        (
            ("Authorization", TOKEN_AUTH_STRING),
            ("ContentType", "application/JSON"),
        )
    )
)
which_should_be_kept_secret() AddHeader

Indicate the added headers should not be written to the log.

secretly() AddHeader

Indicate the added headers should not be written to the log.

SendAPIRequest

This Action is a bit special. For code DRYness’ sake, all of the Send{METHOD}Request Actions use this Action; but for readability’s sake, you will want to use the appropriate Send{METHOD}Request Action listed below.

class SendAPIRequest(method: str, url: str)

Send an API request.

You can use this Action class directly if you wish, but the Send{METHOD}Request Actions are easier to read.

Abilities Required:

MakeAPIRequests

Examples:

the_actor.attempts_to(SendAPIRequest("GET", "http://www.example.com"))

the_actor.attempts_to(
    SendAPIRequest("POST", "http://www.example.com").with_(
        data={"screenplay": "Citizen Kane"}
    )
)
with_(**kwargs: Any) SendAPIRequest

Set additional kwargs to send through to the session’s request.

Args:

kwargs: keyword arguments that correspond to Session.request’s API.

which_should_be_kept_secret() SendAPIRequest

Indicate the extra data should not be written to the log.

secretly() SendAPIRequest

Indicate the extra data should not be written to the log.

SendDELETERequest

Aliases: Delete

SendDELETERequest

Send a DELETE request to a URL.

Abilities Required:

MakeAPIRequests

Examples:

the_actor.attempts_to(SendDELETERequest.to("https://www.example.com"))

the_actor.attempts_to(
    SendDELETERequest.to("https://www.example.com").secretly()
)

the_actor.attempts_to(
    SendDELETERequest.to("https://www.example.com").with_(auth=(USER, PASS))
)

SendGETRequest

Aliases: Get

SendGETRequest

Send a GET request to a URL.

Abilities Required:

MakeAPIRequests

Examples:

the_actor.attempts_to(SendGETRequest.to("https://www.example.com"))

the_actor.attempts_to(
    SendGETRequest.to("https://www.example.com").secretly()
)

the_actor.attempts_to(
    SendGETRequest.to("https://www.example.com").with_(auth=(USER, PASS))
)

SendHEADRequest

Aliases: Head

SendHEADRequest

Send a HEAD request to a URL.

Abilities Required:

MakeAPIRequests

Examples:

the_actor.attempts_to(SendHEADRequest.to("https://www.example.com"))

the_actor.attempts_to(
    SendHEADRequest.to("https://www.example.com").secretly()
)

the_actor.attempts_to(
    SendHEADRequest.to("https://www.example.com").with_(auth=(USER, PASS))
)

SendOPTIONSRequest

Aliases: Options

SendOPTIONSRequest

Send an OPTIONS request to a URL.

Abilities Required:

MakeAPIRequests

Examples:

the_actor.attempts_to(SendOPTIONSRequest.to("https://www.example.com"))

the_actor.attempts_to(
    SendOPTIONSRequest.to("https://www.example.com").secretly()
)

the_actor.attempts_to(
    SendOPTIONSRequest.to("https://www.example.com").with_(auth=(USER, PASS))
)

SendPATCHRequest

Aliases: Patch

SendPATCHRequest

Send a PATCH request to a URL.

Abilities Required:

MakeAPIRequests

Examples:

the_actor.attempts_to(SendPATCHRequest.to("https://www.example.com"))

the_actor.attempts_to(
    SendPATCHRequest.to("https://www.example.com").secretly()
)

the_actor.attempts_to(
    SendPATCHRequest.to("https://www.example.com").with_(auth=(USER, PASS))
)

SendPOSTRequest

Aliases: Post

SendPOSTRequest

Send a POST request to a URL.

Abilities Required:

MakeAPIRequests

Examples:

the_actor.attempts_to(SendPOSTRequest.to("https://www.example.com"))

the_actor.attempts_to(
    SendPOSTRequest.to("https://www.example.com").secretly()
)

the_actor.attempts_to(
    SendPOSTRequest.to("https://www.example.com").with_(auth=(USER, PASS))
)

SendPUTRequest

Aliases: Put

SendPUTRequest

Send a PUT request to a URL.

Abilities Required:

MakeAPIRequests

Examples:

the_actor.attempts_to(SendPUTRequest.to("https://www.example.com"))

the_actor.attempts_to(
    SendPUTRequest.to("https://www.example.com").secretly()
)

the_actor.attempts_to(
    SendPUTRequest.to("https://www.example.com").with_(auth=(USER, PASS))
)

SetHeaders

class SetHeaders(*header_pairs: str | Iterable, **header_kwargs: str)

Set the headers of the Actor’s API session to this specific set.

Note this will remove all other headers on your session.

Abilities Required:

MakeAPIRequests

Examples:

the_actor.attempts_to(SetHeaders(Cookies="csrf_token=1234"))

the_actor.attempst_to(SetHeaders.to(Cookies="csrf_token=1234"))

the_actor.attempts_to(
    SetHeaders(Cookies="csrf_token=1234").which_should_be_kept_secret()
)

the_actor.attempts_to(SetHeaders({"Cookies": "csrf_token=1234"}))

the_actor.attempts_to(SetHeaders("Cookies", "csrf_token=1234"))

the_actor.attempts_to(
    SetHeaders(
        (
            ("Cookies", "csrf_token=1234"),
            ("ContentType", "application/JSON"),
        )
    )
)
static to(**kwargs: str) SetHeaders

Specify the headers to set.

which_should_be_kept_secret() SetHeaders

Indicate these headers should not be written to the log.

secretly() SetHeaders

Indicate these headers should not be written to the log.