@@ -736,3 +736,144 @@ def members_patch(
736736 log (
737737 f'Member "{ membership ["member" ]} " changed role in organization "{ membership ["organization" ]} " to role "{ membership ["role" ]} ".'
738738 )
739+
740+
741+ @cli .command (short_help = "Get a list of organization teams." )
742+ @click .argument ("organization" )
743+ @click .pass_context
744+ def teams_list (ctx : Context , organization : str ) -> None :
745+ """Get a list of organization teams."""
746+ teams_list = ctx .obj ["client" ].get_organization_teams (organization )
747+
748+ if ctx .obj ["format_json" ]:
749+ print_json (teams_list )
750+ else :
751+ log (f'Teams members in organization "{ organization } ":' )
752+ for object_team in teams_list :
753+ log (f'{ object_team ["team" ]} ' )
754+
755+
756+ @cli .command (name = "teams-create" , short_help = "Create an organization team." )
757+ @click .argument ("organization" )
758+ @click .argument ("team_name" )
759+ @click .pass_context
760+ def teams_create (ctx : Context , organization : str , team_name : str ) -> None :
761+ """Create a new team named TEAM_NAME in ORGANIZATION."""
762+ object_team = ctx .obj ["client" ].create_organization_team (organization , team_name )
763+
764+ if ctx .obj ["format_json" ]:
765+ print_json (object_team )
766+ else :
767+ log (f'Team "{ object_team ["team" ]} " created in organization "{ organization } ".' )
768+
769+
770+ @cli .command (name = "teams-get" , short_help = "Get a list of teams on an organization." )
771+ @click .argument ("organization" )
772+ @click .argument ("team_name" )
773+ @click .pass_context
774+ def teams_get (ctx : Context , organization : str , team_name : str ) -> None :
775+ """Get details of team TEAM_NAME in ORGANIZATION."""
776+ object_team = ctx .obj ["client" ].get_organization_team (organization , team_name )
777+
778+ if ctx .obj ["format_json" ]:
779+ print_json (object_team )
780+ else :
781+ log (
782+ f'Team "{ object_team ["team" ]} " in organization "{ object_team ["organization" ]} ":'
783+ )
784+ log (f' Members: { ", " .join (object_team ["members" ])} ' )
785+
786+
787+ @cli .command (name = "teams-patch" , short_help = "Rename an organization team." )
788+ @click .argument ("organization" )
789+ @click .argument ("team_name" )
790+ @click .option ("--name" , "new_team_name" )
791+ @click .pass_context
792+ def teams_patch (
793+ ctx : Context , organization : str , team_name : str , new_team_name : str
794+ ) -> None :
795+ """Rename team TEAM_NAME to NEW_TEAM_NAME in ORGANIZATION."""
796+ object_team = ctx .obj ["client" ].patch_organization_team (
797+ organization , team_name , new_team_name
798+ )
799+
800+ if ctx .obj ["format_json" ]:
801+ print_json (object_team )
802+ else :
803+ log (
804+ f'Team "{ team_name } " in organization "{ organization } " was renamed to "{ object_team ["team" ]} ".'
805+ )
806+
807+
808+ @cli .command (name = "teams-delete" , short_help = "Delete an organization team." )
809+ @click .argument ("organization" )
810+ @click .argument ("team_name" )
811+ @click .pass_context
812+ def teams_delete (ctx : Context , organization : str , team_name : str ) -> None :
813+ """Delete team TEAM_NAME from ORGANIZATION."""
814+ ctx .obj ["client" ].delete_organization_team (organization , team_name )
815+
816+ if not ctx .obj ["format_json" ]:
817+ log (f'Team "{ team_name } " was deleted from organization "{ organization } ".' )
818+
819+
820+ @cli .command (
821+ name = "team-members-list" , short_help = "List members of an organization team."
822+ )
823+ @click .argument ("organization" )
824+ @click .argument ("team_name" )
825+ @click .pass_context
826+ def team_members_list (ctx : Context , organization : str , team_name : str ) -> None :
827+ """List members of team TEAM_NAME in ORGANIZATION"""
828+ members = ctx .obj ["client" ].get_organization_team_members (organization , team_name )
829+ if ctx .obj ["format_json" ]:
830+ print_json (members )
831+ else :
832+ log (f'Members of team "{ team_name } " in organization "{ organization } ":' )
833+
834+ for object_member in members :
835+ log (object_member ["member" ])
836+
837+
838+ @cli .command (
839+ name = "team-members-add" , short_help = "Add a member to an organization team."
840+ )
841+ @click .argument ("organization" )
842+ @click .argument ("team_name" )
843+ @click .argument ("member_username" )
844+ @click .pass_context
845+ def team_members_add (
846+ ctx : Context , organization : str , team_name : str , member_username : str
847+ ) -> None :
848+ """Add member MEMBER_USERNAME to team TEAM_NAME in ORGANIZATION."""
849+ object_member = ctx .obj ["client" ].add_organization_team_member (
850+ organization , team_name , member_username
851+ )
852+
853+ if ctx .obj ["format_json" ]:
854+ print_json (object_member )
855+ else :
856+ log (
857+ f'Member "{ object_member ["member" ]} " added to team "{ team_name } " in organization "{ organization } ".'
858+ )
859+
860+
861+ @cli .command (
862+ name = "team-members-remove" , short_help = "Remove a member from an organization team."
863+ )
864+ @click .argument ("organization" )
865+ @click .argument ("team_name" )
866+ @click .argument ("member_username" )
867+ @click .pass_context
868+ def team_members_remove (
869+ ctx : Context , organization : str , team_name : str , member_username : str
870+ ) -> None :
871+ """Remove member MEMBER_USERNAME from team TEAM_NAME in ORGANIZATION."""
872+ ctx .obj ["client" ].remove_organization_team_member (
873+ organization , team_name , member_username
874+ )
875+
876+ if not ctx .obj ["format_json" ]:
877+ log (
878+ f'Member "{ member_username } " removed from team "{ team_name } " in organization "{ organization } ".'
879+ )
0 commit comments