The director of public safety of a city shall classify the service in the police and fire departments in conformity with the ordinance of the legislative authority thereof determining the number of persons to be employed in the departments, and shall make all rules for the regulation and discipline of such departments, except as otherwise provided by law.