Closed budda closed 6 years ago
This is by design.
If you get an EnvironmentStateException, it's because the information you're trying to get (or the action you're trying to perform) is not applicable for the environment in that state.
You can catch the exception, and I guess you could also obtain the public URL at another time (while the environment is active) and cache it or save it. Could you describe your use case?
Alternatively, if you look at the method's docblock, you'll see getRoutes() is an alternative. Can you use that?
Use case is to tie a monitoring system (nodeping.com) API together with the Platform projects. The only common thing between them both is the public url / target origin url being monitored.
The script code is run by somebody when they wish to create a monthly report on performance of each project within each of the Platform plans.
At present when backups are running, or data syncing or deployments are in progress at Platform this hampers the service desk staff from being able to run the report when they need it.
Why is the querying of the public url attached to a project environment not available "by design"? What use case is there for withholding information temporarily ?
I'll take a look at getRoutes() next week - thanks for the pointer.
OK, I've added getRouteUrls()
which is closer to what you want, and I've (hastily) tagged that as v0.1.26. It is supposed to be available regardless of the environment's state, although I have not experimented with this much yet.
I meant 'by design' in this library, in that it is supposed to be merely a consumer of the API.
That new method works good @pjcdawkins - although nicer if the array key could indicate which was the default domain as configured in the UI.
I'm not going to have to loop through the array and find a match each time.
On a side note - the output isn't consistent in the getRouteUrls() array.
[0] => http://*.sg
[1] => https://*.sg
[2] => https://*.digital/
[3] => http://*.digital/
The 2nd has a slash at the end. Checking in the PlatformUI both domains are entered without a slash on.
I believe the public URL is now visible more often in the API, and there's nothing else that can be done on the client side.
If I call getPublicUrl() on my master environment whilst its being snapshotted the API throws an exception.