This is a court-authorized search warrant authorized by a aitting judge. It doesn't get any more legal than that, and it's Google or any other company's legal duty to comply.
When it comes to Gmail they could take an approach like password managers where the user's password is instrumental to decrypt the data and Google lacks any manner to circumvent the encryption - they just choose not to.
However, my point was that the comment I replied to was factually wrong -- there is legal action Google could choose to take instead of immediately complying.