Skip to main content

pspring-rest-client

This framework is member of pspring based family of frameworks. It provides a means to create rest clients with minimal code. requests library is used internally for http requests.

Annotations / Decorators that come along with this framework are listed below

  • @RestClient(url="") This decorator will add few boiler plate code that is required to interact with any rest endpoint. The methods significant are send, getUrl, addHeader.

    The send method would accept all arguments that requests.request method would. This method will throw PayloadException for all not HTTP 200 responses. The PayloadException has response and statusCode attributes which can be further used for error handling. The addHeader(name,value) method would add an header The getUrl will get the url that is configured along with @RestClient decorator. The handleError method is exists on the object will be invoked when received a non http 200 response.

  • @Mapping(method="",url="") This decorator will take care of replacing parameters in the url from arguments passed, send the request and return the response

Useful classes in this framework

RegExResponseMapper - this class can be used to tranform one dictionary to another using regex. An example is shown below. The source dictionary fields can be accessed using $ notation. In the below example message is a field inside the `response dictionary.

regexmapper = RegExResponseMapper({
    ".*Customer does not exist.*" :  {
        "statusCode" : "404",
        "code" : "APS-1001",
        "message" : "$response.message"
    },
    ".*" : {
        "statusCode" : "500",
        "code" : "APS-1002",
        "message" : "$response.message"
    }
})

@RestClient(url="https://myapi.com")
class MyRestClient():

  @Mapping(method="GET",url="/user/{firstName}")
  def getCustomer(self,firstName):
    pass

  @Mapping(method="POST",url="/user/",data=json)
  def saveCustomer(self):
    pass

  @Mapping(method="POST",url="/user/")
  def saveCustomer(self,customer):
    self.json=customer

  def handleError(self,response):
        return regexmapper.map(response)

Documentation at pspring-rest-client

To do:

  • To return objects based on the return type from the response received.

Metadata

Release files for pspring-rest-client 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pspring-rest-client 0.2.3
File Size Uploaded Provenance Actions
pspring-rest-client-0.2.3.tar.gz 6.9 kB Without provenance Details for pspring-rest-client-0.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pspring-rest-client 0.2.3
File Interpreter ABI Platform Actions
pspring_rest_client-0.2.3-py3-none-any.whl Python 3 none any Details for pspring_rest_client-0.2.3-py3-none-any.whl

Total release size: 13.5 kB

Release files / pspring-rest-client-0.2.3.tar.gz

Download URL pspring-rest-client-0.2.3.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6f14a29e6f2b6d9bb92acf2254f12273ccfbd836d4a03fa67a0b5d6857a7a4cf
BLAKE2b-256 checksum
How to use checksums
0453cdd1cad8a45904834229cb668d64e0314c391e750a870b9826fed019d586
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release files / pspring_rest_client-0.2.3-py3-none-any.whl

Download URL pspring_rest_client-0.2.3-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c6b47a8efed5de355a3d167cef60c85594b4e245b6fa622e5c49310b70a8c517
BLAKE2b-256 checksum
How to use checksums
d1683696492b3eb80edd4c5dfd7cb7042624a1f2e1438e7d47c11203790a3d67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Security for pspring-rest-client 0.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page