Skip to content

Commit

Permalink
Update MANRS API endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
barryo committed Nov 2, 2024
1 parent b62a8ea commit 309f5a7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/Console/Commands/InManrs.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
use Illuminate\Support\Facades\DB;

use Illuminate\Support\Facades\Http;
use IXP\Models\Customer;
/**
* Artisan command to update the in_peeringdb flag of members
Expand Down Expand Up @@ -59,12 +60,18 @@ class InManrs extends Command
public function handle(): int
{
// get list of peeringdb networks:
if( !( $json = file_get_contents( 'https://www.manrs.org/wp-json/manrs/v1/asn' ) ) ) {
$this->error( 'Could not load ASNs via MANRS\'s API' );
try {
$resp = Http::withHeaders( [
'X-Request-Client' => 'IXP Manager',
'X-Request-Client-Version' => APPLICATION_VERSION,

Check failure on line 66 in app/Console/Commands/InManrs.php

View workflow job for this annotation

GitHub Actions / ci-ex-dusk

UndefinedConstant

app/Console/Commands/InManrs.php:66:47: UndefinedConstant: Const APPLICATION_VERSION is not defined (see https://psalm.dev/020)
] )->throw()->acceptJson()
->get( 'https://api.manrs.org/asns' );
} catch(\Exception $e) {
$this->error( 'Could not load ASNs via MANRS\'s API: ' . $e->getMessage() );
return 1;
}

$asns = json_decode( $json, true );
$asns = $resp['asns'];

if( !is_array( $asns ) || !count( $asns ) ) {
$this->error( 'Empty or no ASNs returned from MANRS\'s API' );
Expand Down

0 comments on commit 309f5a7

Please sign in to comment.