def
main
(
client
: GoogleAdsClient, customer_id
: str
, manager_customer_id
: str
) -> None
:
# This example assumes that the same credentials will work for both
# customers, but that may not be the case. If you need to use different
# credentials for each customer, then you may either update the client
# configuration or instantiate two clients, where at least one points to
# a specific configuration file so that both clients don't read the same
# file located in the $HOME dir.
customer_client_link_service: CustomerClientLinkServiceClient =
(
client.get_service( "CustomerClientLinkService"
)
)
# Extend an invitation to the client while authenticating as the manager.
client_link_operation: CustomerClientLinkOperation =
client.get_type(
"CustomerClientLinkOperation"
)
client_link: CustomerClientLink =
client_link_operation.create
client_link.client_customer =
customer_client_link_service.customer_path(
customer_id
)
# client_link.status expects an enum value (int)
client_link.status =
client.enums.ManagerLinkStatusEnum.PENDING.value
response: MutateCustomerClientLinkResponse =
(
customer_client_link_service.mutate_customer_client_link(
customer_id
=
manager_customer_id, operation
=
client_link_operation
)
)
resource_name: str
=
response.results[ 0
].resource_name
print
(
f
'Extended an invitation from customer "
{
manager_customer_id }
" to '
f
'customer "
{
customer_id }
" with client link resource_name '
f
'"
{
resource_name }
"'
)
print
( "✅ Invitation sent successfully! Client should see the invitation in their Google Ads interface."
)
# [END link_manager_to_client]