Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add organization and storage endpoints (read only) #46

Merged
merged 1 commit into from
Mar 28, 2023

Conversation

peetucket
Copy link
Member

@peetucket peetucket commented Mar 16, 2023

Why was this change made? 🤔

Fixes #43 - add fetch organization, org interface and interface detail endpoints to folio_client.

Notes:

  • This does not use paging to move through a large results set ... you can give it a very large limit though if performance is not a concern (or possibly implement paging at the consumer level). Using this on okapi-test, there are a few hundred organizations, and the complete set comes back in about ~20-30 seconds
  • This PR only implements the "get" endpoints, the documentation shows their are update endpoints (e.g. PUT, POST, etc.).
  • This PR does not parse the results coming back ... it returns a JSON response that comes from the API which can be used by the consumer.

Perhaps future work can parse and produce different results if needed.

How was this change tested? 🤨

Added new tests

@aaron-collier
Copy link
Contributor

@peetucket I think this might be a credential issue if you are using the sdr_app user or whatever. I had to have some specific rights turned on for me and https://okapi-test.stanford.edu/organizations/organizations returns a big set. May check with libsys about either your account or the API one.

@peetucket
Copy link
Member Author

Ok, I'll check with libsys.

@mjgiarlo mjgiarlo assigned mjgiarlo and unassigned mjgiarlo Mar 21, 2023
@peetucket
Copy link
Member Author

Verified it works on okapi-test after using app_libsys account.

@peetucket peetucket changed the title add organization and storage endpoints add organization and storage endpoints (read only) Mar 28, 2023
.....],....
"totalRecords"=>100}

client.organization_interfaces(query: 'name="tes"')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that a query could also use the ID, correct? Like query: 'id="some-uuid-of-an-interface"'?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, you just need to do GET /organizations-storage/interfaces/{id}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it will take any query that is supported by the API (it just passes it along without parsing).

result = FolioClient.organization_interfaces(query: 'id="c6f7470e-6229-45ce-b3f9-32006e9affcf"')
result
 =>
{"interfaces"=>
  [{"id"=>"c6f7470e-6229-45ce-b3f9-32006e9affcf",
    "name"=>"tes",
    "type"=>["Invoices"],
    "metadata"=>
     {"createdDate"=>"2023-02-16T22:27:51.515+00:00",
      "createdByUserId"=>"38524916-598d-4edf-a2ef-04bba7e78ad6",
      "updatedDate"=>"2023-02-16T22:27:51.515+00:00",
      "updatedByUserId"=>"38524916-598d-4edf-a2ef-04bba7e78ad6"}}],
 "totalRecords"=>1}

This is basically the same thing as using the interface details query:

result = FolioClient.interface_details(id: 'c6f7470e-6229-45ce-b3f9-32006e9affcf')
result
 =>
{"id"=>"c6f7470e-6229-45ce-b3f9-32006e9affcf",
 "name"=>"tes",
 "type"=>["Invoices"],
 "metadata"=>
  {"createdDate"=>"2023-02-16T22:27:51.515+00:00",
   "createdByUserId"=>"38524916-598d-4edf-a2ef-04bba7e78ad6",
   "updatedDate"=>"2023-02-16T22:27:51.515+00:00",
   "updatedByUserId"=>"38524916-598d-4edf-a2ef-04bba7e78ad6"}}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, you could do /organizations-storage/interfaces?query=id==c6f7470e-6229-45ce-b3f9-32006e9affcf if you wanted to...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't pass any query to the organization_interfaces it will return everything.

result = FolioClient.organization_interfaces
result
{"interfaces"=>
  [{"id"=>"c6f7470e-6229-45ce-b3f9-32006e9affcf",
    "name"=>"tes",
    "type"=>["Invoices"],
    "metadata"=>
     {"createdDate"=>"2023-02-16T22:27:51.515+00:00",
      "createdByUserId"=>"38524916-598d-4edf-a2ef-04bba7e78ad6",
      "updatedDate"=>"2023-02-16T22:27:51.515+00:00",
      "updatedByUserId"=>"38524916-598d-4edf-a2ef-04bba7e78ad6"}},
   {"id"=>"65d30c15-a560-4064-be92-f90e38eeb351",
    "name"=>"GOBI-FTP",
    "uri"=>"ftp://ftp.ybp.com",
    "notes"=>"THIS IS AN EXAMPLE - IF ANY PROBLEMS ARRISE, DELETE",
    "type"=>["Other"],
    "metadata"=>
     {"createdDate"=>"2023-03-09T22:30:53.993+00:00",
      "createdByUserId"=>"ef452e80-116b-4e6a-b820-3827a3c87c17",
      "updatedDate"=>"2023-03-09T22:30:53.993+00:00",
      "updatedByUserId"=>"ef452e80-116b-4e6a-b820-3827a3c87c17"}},
   {"id"=>"3a00800c-c6a9-447d-96b5-cf5786d69df3",
    "name"=>"Test Interface",
    "type"=>["Other"],
    "metadata"=>
     {"createdDate"=>"2023-03-27T20:16:45.467+00:00",
      "createdByUserId"=>"950344dc-af40-58e1-aa90-c015b7ac51f2",
      "updatedDate"=>"2023-03-27T20:16:45.467+00:00",
      "updatedByUserId"=>"950344dc-af40-58e1-aa90-c015b7ac51f2"}}],
 "totalRecords"=>3}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I see it now, that's the interface_details method. We may also need to add a method for the /organizations-storage/interfaces/{id}/credentials endpoint, but I want to chat with @jermnelson about the API requirements first, so that could easily be a follow up PR.

@aaron-collier aaron-collier merged commit 3b04545 into main Mar 28, 2023
@aaron-collier aaron-collier deleted the 43-org-endpoint branch March 28, 2023 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add organization endpoints to the client
4 participants