Net::G...:Query(3pm)

๐Ÿ“ฆ
version 1.05 ยท 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

๐ŸŽ€ NAME ๐ŸŽ€

Net::GitHub::V3::Query โ€” it's the Base Query role for Net::GitHub::V3, bestie ๐Ÿ’–

(also this whole thing lives in the User Contributed Perl Documentation section, just so u know where u are ๐Ÿ‘‘)


โœจ SYNOPSIS โœจ

okay so this is the whole vibe, copy-paste core:

package Net::GitHub::V3::XXX;

use Moo;
with 'Net::GitHub::V3::Query';

that's it. that's the whole ritual ๐Ÿซถ


๐ŸŒธ DESCRIPTION ๐ŸŒธ

literally just: set your Authentication and call the API. that's the entire job description ๐Ÿ’…


๐Ÿฆ‹ ATTRIBUTES ๐Ÿฆ‹

the little settings u can poke at, no cap:

  • login โ€” ur login, bestie ๐Ÿ™ˆ
  • pass โ€” ur password, keep it secret fr fr
  • access_token โ€” you either set access_token from OAuth, or you do login:pass for Basic Authentication. pick ur fighter ๐Ÿ’œ

http://developer.github.com/

  • raw_string โ€” the raw string, iconic as ever โญ
  • raw_response โ€” the raw response, its sibling ๐ŸŒˆ
  • api_throttle โ€” API throttling is on by default! set api_throttle to 0 to turn it off. it's giving "leave it alone unless u know what ur doing" ๐Ÿ’€
  • rate_limit โ€” the maximum number of queries allowed per hour. it's 60 for anonymous users and 5,000 for authenticated users ๐Ÿ‘‘
  • rate_limit_remaining โ€” how many requests u still have left in the current rate limit window ๐Ÿ“
  • rate_limit_reset โ€” when the current rate limit resets, in UTC epoch seconds โฐ
  • update_rate_limit โ€” queries the /rate_limit API (for free!!) to update the cached values for rate_limit, rate_limit_remaining, rate_limit_reset. free is free bestie ๐Ÿ’–
  • last_page โ€” denotes the index of the last page in the pagination ๐Ÿ“–
  • RaiseError โ€” yes it exists, and yes it's named like that ๐Ÿงš

๐Ÿ’… METHODS ๐Ÿ’…

  • query โ€” refer Net::GitHub::V3 ๐Ÿซถ
  • next_page โ€” calls query with next_url. see Net::GitHub::V3 โžก๏ธ
  • prev_page โ€” calls query with prev_url. see Net::GitHub::V3 โฌ…๏ธ
  • first_page โ€” calls query with first_url. see Net::GitHub::V3 โฎ๏ธ
  • last_page โ€” calls query with last_url. see Net::GitHub::V3 โญ๏ธ
  • set_next_page โ€” adjusts next_url to be a new url in the pagination space, I.E. you are jumping to a new index in the pagination ๐Ÿฆ˜
  • iterate($method_name, $arguments, $callback) โ€” this is the helper that iterates over APIs calls using pagination, doing the combo has_next_page, next_page... for you. it's giving personal assistant energy ngl โœจ

the arguments can be either a scalar if the function is using a single argument, an ArrayRef when the function is using multiple arguments. you can also use one HashRef for functions supporting named parameters ๐ŸŽ€

the callback function is called with a single item. the return value of the callback function can be used to stop the iteration when returning a 'false' value ๐Ÿ›‘

in common cases, you want to return a true value: '1' โœ…

sample usage, keep it exact bestie:

$gh->org->iterate( 'repos', 'OrganizationName', sub {
    my $item = shift;

    print "Repo Name is $item->{name}"

    return 1; # if you want to continue iterating
    return;   # use a false value when you want to interrupt the iteration
} );
  • result_sets โ€” for internal use by the item-per-item pagination: this is a store of the state(s) for the pagination. each entry maps the initial URL of a GitHub query to a Net::GitHub::V3::ResultSet object ๐Ÿ“ฆ
  • next($url) โ€” returns the next item for the query which started at $url, or undef if there are no more items ๐Ÿซ 
  • close($url) โ€” terminates the item-per-item pagination for the query which started at $url ๐Ÿšช

๐Ÿ”ฅ NG_DEBUG ๐Ÿ”ฅ

  • export NG_DEBUG=1 to view the request URL ๐Ÿ‘€
  • NG_DEBUG > 1 to view request/response string ๐Ÿ“œ

refer Net::GitHub ๐Ÿ’–


and that's the whole page, bestie โ€” documented for perl v5.36.0, dated 2022-10-08, filed under Net::G...:Query(3pm) ๐Ÿฆ‹ slay, go forth and paginate โœจ

๐Ÿ“ฆ where this page comes from