in src/dfcx_scrapi/core/security_settings.py [0:0]
def create_security_settings(
self,
location_id: str,
obj: types.SecuritySettings = None,
security_settings_dict: Dict[str,str] = None):
"""Create CCAI Security Settings profile in the specified project.
One of `obj` or `security_settings_dict` should be provided to create a
new security settings profile.
Args:
location_id: CX Agent ID string in the following format:
projects/<PROJECT ID>/locations/<LOCATION ID>/
obj: An object of types.SecuritySettings representing the Security
Settings object to be created
security_settings_dict: An optional dictionary of key/value pairs
that correspond to the fields and values necessary for creating a
new Security Settings profile
Returns:
A single Security Settings object of types.SecuritySettings
"""
if obj and security_settings_dict:
raise ValueError(
"Cannot provide both obj and security_settings_dict")
elif obj:
security_settings = obj
security_settings.name = ""
elif security_settings_dict:
security_settings = self.ss_types.SecuritySettings.from_json(
json.dumps(security_settings_dict)
)
else:
raise ValueError(
"Must provide either obj or security_settings_dict")
request = self.ss_types.CreateSecuritySettingsRequest()
request.parent = location_id
request.security_settings = security_settings
client_options = self._set_region(location_id)
client = self.ss_service.SecuritySettingsServiceClient(
credentials=self.creds, client_options=client_options
)
response = client.create_security_settings(request)
return response