Skip to content

Commit

Permalink
Change request contents for OT creation (#4416)
Browse files Browse the repository at this point in the history
* Change request contents for OT creation

* test fix
  • Loading branch information
DanielRyanSmith authored Oct 3, 2024
1 parent 51f228f commit eb3b8f0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
16 changes: 10 additions & 6 deletions framework/origin_trials_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ class InternalRegistrationConfig(TypedDict):
class CreateOriginTrialRequest(TypedDict):
trial: RequestTrial
registration_config: InternalRegistrationConfig
trial_contacts: list[str]


class SetUpTrialRequest(TypedDict):
Expand Down Expand Up @@ -166,7 +165,6 @@ def _send_create_trial_request(
if ot_stage.ot_is_deprecation_trial else 'ORIGIN_TRIAL'),
},
'registration_config': {'approval_type': 'NONE'},
'trial_contacts': []
}
if ot_stage.ot_require_approvals:
json['registration_config'] = {
Expand Down Expand Up @@ -224,7 +222,11 @@ def _send_set_up_trial_request(
url = f'{settings.OT_API_URL}/v1/trials/{trial_id}:setup'
try:
response = requests.post(
url, headers=headers, params={'key': api_key}, json=json)
url,
headers=headers,
params={'key': api_key},
json=json,
timeout=(10, 60))
logging.info(f'SetUpTrial response text: {response.text}')
response.raise_for_status()
except requests.exceptions.RequestException:
Expand Down Expand Up @@ -266,8 +268,10 @@ def create_origin_trial(ot_stage: Stage) -> tuple[str|None, str|None]:
return None, 'No trial contacts found in google.com domain'

access_token = _get_ot_access_token()
origin_trial_id, error_text = _send_create_trial_request(
ot_stage, key, access_token)
origin_trial_id = ot_stage.origin_trial_id
if not ot_stage.origin_trial_id:
origin_trial_id, error_text = _send_create_trial_request(
ot_stage, key, access_token)

if origin_trial_id is None:
return None, error_text
Expand Down Expand Up @@ -297,7 +301,7 @@ def activate_origin_trial(origin_trial_id: str) -> None:
if key is None:
return None

json = {'id': origin_trial_id}
json = {'trial_id': origin_trial_id}
access_token = _get_ot_access_token()
headers = {'Authorization': f'Bearer {access_token}'}
url = (f'{settings.OT_API_URL}/v1/trials/{origin_trial_id}:start')
Expand Down
2 changes: 1 addition & 1 deletion framework/origin_trials_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,5 +289,5 @@ def test_activate_origin_trial__with_api_key(
f'{settings.OT_API_URL}/v1/trials/-1234567890:start',
headers={'Authorization': 'Bearer access_token'},
params={'key': 'api_key_value'},
json={'id': '-1234567890'}
json={'trial_id': '-1234567890'}
)
4 changes: 2 additions & 2 deletions internals/notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ def process_post_data(self, **kwargs):
self.require_task_header()
stage = self.get_param('stage', required=True)
contacts = stage['ot_emails'] or []
contacts.append('ot_owner_email')
contacts.append(stage['ot_owner_email'])
send_emails([self.build_email(stage, contacts)])
return {'message': 'OK'}

Expand Down Expand Up @@ -685,7 +685,7 @@ def process_post_data(self, **kwargs):
self.require_task_header()
stage = self.get_param('stage', required=True)
contacts = stage['ot_emails'] or []
contacts.append('ot_owner_email')
contacts.append(stage['ot_owner_email'])
send_emails([self.build_email(stage, contacts)])
return {'message': 'OK'}

Expand Down

0 comments on commit eb3b8f0

Please sign in to comment.