def create_service_gateway(virtual_network_client, module):
    create_service_gateway_details = CreateServiceGatewayDetails()
    for attribute in create_service_gateway_details.attribute_map.keys():
        if attribute in module.params:
            setattr(create_service_gateway_details, attribute,
                    module.params[attribute])

    list_of_request_details = []
    if module.params['services'] is not None:
        for req in module.params['services']:
            req_details = ServiceIdRequestDetails()
            req_details.service_id = req['service_id']
            list_of_request_details.append(req_details)
    create_service_gateway_details.services = list_of_request_details
    result = oci_utils.create_and_wait(
        resource_type="service_gateway",
        create_fn=virtual_network_client.create_service_gateway,
        kwargs_create={
            "create_service_gateway_details": create_service_gateway_details
        },
        client=virtual_network_client,
        get_fn=virtual_network_client.get_service_gateway,
        get_param="service_gateway_id",
        module=module)
    return result
def update_service_gateway(virtual_network_client, module):
    serviceid_requests = None
    if module.params['services'] is not None:
        serviceid_requests = []
        for service in module.params['services']:
            req = ServiceIdRequestDetails()
            req.service_id = service['service_id']
            serviceid_requests.append(req)
    result = oci_utils.check_and_update_resource(
        resource_type="service_gateway",
        get_fn=virtual_network_client.get_service_gateway,
        kwargs_get={"service_gateway_id": module.params["service_gateway_id"]},
        update_fn=virtual_network_client.update_service_gateway,
        primitive_params_update=['service_gateway_id'],
        kwargs_non_primitive_update={
            UpdateServiceGatewayDetails: "update_service_gateway_details"
        },
        module=module,
        update_attributes=UpdateServiceGatewayDetails().attribute_map.keys(),
        sub_attributes_of_update_model={'services': serviceid_requests})
    return result