(a) The city council shall appoint a city attorney, together with such assistant city attorneys as may be necessary, and shall provide for the payment of such attorney or attorneys for services rendered to the city. The city attorney shall be responsible for representing and defending the city in all anticipated or pending litigation in which the city is a party; shall attend the meetings of the city council as directed; shall be allowed to participate in discussions but not vote; shall advise the city council, mayor, and other officers, and employees of the city concerning legal aspects of the city's affairs; shall be a special prosecuting attorney to prosecute offenses arising out of violations of zoning ordinances, subdivision regulations, similar land use regulations, or other ordinance violations; and shall perform such other duties as may be required of him or her by virtue of his or her position as city attorney or as required by the city council or the city manager.