@@ -38,7 +38,7 @@ def main(client, customer_id, manager_customer_id):
38
38
# Extend an invitation to the client while authenticating as the manager.
39
39
client_link_operation = client .get_type ("CustomerClientLinkOperation" )
40
40
client_link = client_link_operation .create
41
- client_link .client_customer = f"customers/ { customer_id } "
41
+ client_link .client_customer = customer_client_link_service . customer_path ( customer_id )
42
42
client_link .status = client .enums .ManagerLinkStatusEnum .PENDING
43
43
44
44
response = customer_client_link_service .mutate_customer_client_link (
@@ -97,31 +97,14 @@ def main(client, customer_id, manager_customer_id):
97
97
protobuf_helpers .field_mask (None , manager_link ._pb ),
98
98
)
99
99
100
- try :
101
- response = customer_manager_link_service .mutate_customer_manager_link (
102
- customer_id = manager_customer_id , operations = [manager_link_operation ]
103
- )
104
- resource_name = response .results [0 ].resource_name
105
- print (
106
- "Client accepted invitation with resource_name: "
107
- f'"{ resource_name } "'
108
- )
109
- except GoogleAdsException as ex :
110
- _handle_googleads_exception (ex )
111
- # [END link_manager_to_client]
112
-
113
-
114
- def _handle_googleads_exception (exception ):
100
+ response = customer_manager_link_service .mutate_customer_manager_link (
101
+ customer_id = manager_customer_id , operations = [manager_link_operation ]
102
+ )
115
103
print (
116
- f'Request with ID " { exception . request_id } " failed with status '
117
- f'"{ exception . error . code (). name } " and includes the following errors: '
104
+ "Client accepted invitation with resource_name: "
105
+ f'"{ response . results [ 0 ]. resource_name } " '
118
106
)
119
- for error in exception .failure .errors :
120
- print (f'\t Error with message "{ error .message } ".' )
121
- if error .location :
122
- for field_path_element in error .location .field_path_elements :
123
- print (f"\t \t On field: { field_path_element .field_name } " )
124
- sys .exit (1 )
107
+ # [END link_manager_to_client]
125
108
126
109
127
110
if __name__ == "__main__" :
@@ -150,4 +133,13 @@ def _handle_googleads_exception(exception):
150
133
try :
151
134
main (googleads_client , args .customer_id , args .manager_customer_id )
152
135
except GoogleAdsException as ex :
153
- _handle_googleads_exception (ex )
136
+ print (
137
+ f'Request with ID "{ exception .request_id } " failed with status '
138
+ f'"{ exception .error .code ().name } " and includes the following errors:'
139
+ )
140
+ for error in exception .failure .errors :
141
+ print (f'\t Error with message "{ error .message } ".' )
142
+ if error .location :
143
+ for field_path_element in error .location .field_path_elements :
144
+ print (f"\t \t On field: { field_path_element .field_name } " )
145
+ sys .exit (1 )
0 commit comments