Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Credentials

Imports

Python modules

from typing import Union

Third-party modules

from sgqlc.operation import Operation

newrelic_sb_sdk module

from newrelic_sb_sdk.client import NewRelicClient
from newrelic_sb_sdk.graphql.objects import Account, User
from newrelic_sb_sdk.utils.response import raise_response_errors

Functions

validate

Performs an authentication test confirming that the tied credentials grant valid New Relic access.

def validate(*, client: NewRelicClient, account: Account | None = None) -> User:
    """Validate SDK configuration with New Relic credentials.

    Args:
        client: The New Relic API client instance for authentication.
        account: The target New Relic account object. Defaults to None.

    Returns:
        The verified User profile object.
    """

    operation = Operation(
        client.schema.query_type,
    )
    operation.actor.user.__fields__(
        "id",
        "email",
        "name",
    )

    response = client.execute(operation)

    raise_response_errors(
        response=response,
        account=account,
    )

    data = operation + response.json()
    data = data.actor.user

    return data