class Dependabot::Clients::Azure

def post(url, json) # rubocop:disable Metrics/PerceivedComplexity

rubocop:disable Metrics/PerceivedComplexity
def post(url, json) # rubocop:disable Metrics/PerceivedComplexity
  response = T.let(nil, T.nilable(Excon::Response))
  retry_connection_failures do
    response = Excon.post(
      url,
      body: json,
      user: credentials&.fetch("username", nil),
      password: credentials&.fetch("password", nil),
      idempotent: true,
      **SharedHelpers.excon_defaults(
        headers: auth_header.merge(
          {
            "Content-Type" => "application/json"
          }
        )
      )
    )
    raise InternalServerError if response&.status == 500
    raise BadGateway if response&.status == 502
    raise ServiceNotAvailable if response&.status == 503
  end
  raise Unauthorized if response&.status == 401
  if response&.status == 403
    raise TagsCreationForbidden if tags_creation_forbidden?(T.must(response))
    raise Forbidden
  end
  raise NotFound if response&.status == 404
  T.must(response)
end