GithubHelp home page GithubHelp logo

hydrologicengineeringcenter / cwms-data-api-client Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 10.0 1.81 MB

Client Side libraries to assist with Accessing the CWMS REST API that we call RADAR.

License: MIT License

Java 99.01% Mustache 0.38% HTML 0.61%

cwms-data-api-client's People

Contributors

adamkorynta avatar dependabot[bot] avatar dreina-gei avatar mikeneilson avatar psmorris avatar rma-bryson avatar rma-psmorris avatar rma-rripken avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cwms-data-api-client's Issues

Add method to check whether the client has write access

Currently we test by checking a 401 error code with a dummy post to the catalog endpoint. From Mike Neilson:

...FYI the swagger-docs output will include security schemas if it can write, that’s better than making a request and it just pollutes the logs (the access log is one line, the failed request is like 10.)

Add OkHttp cache invalidation for CDA

OkHttp cache doesn't seem to do pro-active cache invalidation.
Scenario:

  1. User does a GET request - OkHttp will cache it.
  2. The user does a POST to modify the resource.
  3. The user then re-does the first GET request.
  4. OkHttp cache returns the previously cached results.

In step 4 we'd like users of cdac to get back fresh results.

From this okhttp issue: square/okhttp#853 and this documentation: https://square.github.io/okhttp/features/caching/#pruning-the-cache It appears that we are supposed to prune the cache when we want to invalidate something.

The only way to prune the cache is to call urls() and get a MutableIterator from the cache and then iterate over it and remove urls from it.

For the CDA use-case above. When a POST is done we'd like something to iterate the cache and throw away matching urls.

What does it mean to be matching? Definitely need to throw away exact matches. But what if the user just flipped a query parameter? We can't expect cdac to know the meaning of each parameter so it seems like we have to also match cache items with different query parameters.

What if the user had previous done a getAll style request and then updated one of the items and does a getAll request again?
In that case the url, even ignoring the query parameters, between the GET and the POST are not "exactly" the same.

GET: https://cwms-data.usace.army.mil/cwms-data/locations?office=SWT&unit=EN
PATCH: https://cwms-data.usace.army.mil/cwms-data/locations/BUCK
GET: https://cwms-data.usace.army.mil/cwms-data/locations?office=SWT&unit=EN

Therefore, for CDA usage, we'd want to evict everything from the same CDA Controller end-point. E.G everything that starts with: https://cwms-data.usace.army.mil/cwms-data/locations

But what about CDA Controllers that are related?
We have CDA controllers for Location Category and Location Group.
If you do a cascade delete on Location Category we'd really want the Location Group cache entries to be evicted.
Or Timeseries and TimeseriesIdentifier. Or Timeseries and Catalog. CDAC can't be expected to track all these dependencies.

Basically I think I've convinced myself that when the user does a POST, PUT, PATCH or DELETE to a CDA end-point then cdac should make OkHttp cache evict all cached responses from the root of the CDA server.

To be safe, anything that starts with https://cwms-data.usace.army.mil/cwms-data/ should be thrown away.

For CDA usage can we programmatically find an appropriate url prefix to match?

About to break clob

FYI, I'm about to break the clob DTO in data-api. It's the only one that uses "office" instead of "office-id".

I can go ahead and do the fix here, but I wanted to make sure y'all are aware.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.