Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOME-1781: Added role id to contributor and group endpoints #163

Merged
merged 3 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions cmd/contributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package cmd

import (
"encoding/json"

"github.com/lokalise/go-lokalise-api/v4"

"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -139,17 +139,23 @@ func init() {
_ = contributorCreateCmd.MarkFlagRequired("email")
fs.StringVar(&contributorCreate.Fullname, "fullname", "", "Full name (only valid for inviting users, who previously did not have an account in Lokalise).")
fs.BoolVar(&contributorCreate.IsAdmin, "is-admin", false, "Whether the user has Admin access to the project.")
_ = fs.MarkDeprecated("is-admin", "--is-admin is deprecated and will be removed. Use admin-rights to set permissions to the user.")
fs.BoolVar(&contributorCreate.IsReviewer, "is-reviewer", false, "Whether the user has Reviewer access to the project.")
_ = fs.MarkDeprecated("is-reviewer", "--is-reviewer is deprecated and will be removed. Use admin-rights to set permissions to the user.")
fs.Int64Var(&contributorCreate.RoleId, "role-id", 0, "Permission template id for the contributor. By setting this admin_rights will be ignored and a template will be assigned with predefined permission set.")
fs.StringVar(&contributorLanguages, "languages", "", "List of languages, accessible to the user. Required if is_admin is set to false (JSON, see https://lokalise.com/api2docs/curl/#transition-create-contributors-post).")
fs.StringSliceVar(&contributorCreate.AdminRights, "admin-rights", []string{}, "Custom list of user permissions. Possible values are upload, activity, download, settings, statistics, keys, screenshots, contributors, languages. Omitted or empty parameter will set default admin rights for user role.")
fs.StringSliceVar(&contributorCreate.AdminRights, "admin-rights", []string{}, "Custom list of user permissions. Possible values are activity, contributors, branches_create, branches_main_modify, branches_merge, custom_status_modify, download, glossary, glossary_edit, glossary_delete, keys, manage_languages, review, screenshots, settings, statistics, tasks, upload. Omitted or empty parameter will set no rights for the user.")

// Update
flagContributorId(contributorUpdateCmd)
fs = contributorUpdateCmd.Flags()
fs.BoolVar(&permissionUpdate.IsAdmin, "is-admin", false, "Whether the user has Admin access to the project.")
fs.BoolVar(&permissionUpdate.IsReviewer, "is-reviewer", false, "Whether the user has Reviewer access to the project.")
fs.BoolVar(&permissionUpdate.IsAdmin, "is-admin", false, "Whether the user has Admin access to the project. Deprecated.")
_ = fs.MarkDeprecated("is-admin", "--is-admin is deprecated and will be removed. Use admin-rights to set permissions to the user.")
fs.BoolVar(&permissionUpdate.IsReviewer, "is-reviewer", false, "Whether the user has Reviewer access to the project. Deprecated.")
_ = fs.MarkDeprecated("is-reviewer", "--is-reviewer is deprecated and will be removed. Use admin-rights to set permissions to the user.")
fs.StringVar(&contributorLanguages, "languages", "", "List of languages, accessible to the user (JSON, see https://lokalise.com/api2docs/curl/#transition-update-a-contributor-put).")
fs.StringSliceVar(&permissionUpdate.AdminRights, "admin-rights", []string{}, "Custom list of user permissions. Possible values are upload, activity, download, settings, statistics, keys, screenshots, contributors, languages. Empty parameter will set default admin rights for user role.")
fs.StringSliceVar(&permissionUpdate.AdminRights, "admin-rights", []string{}, "Custom list of user permissions. Possible values are activity, contributors, branches_create, branches_main_modify, branches_merge, custom_status_modify, download, glossary, glossary_edit, glossary_delete, keys, manage_languages, review, screenshots, settings, statistics, tasks, upload. Empty parameter will set no rights for the user.")
fs.Int64Var(&permissionUpdate.RoleId, "role-id", 0, "Permission template id for the contributor. By setting this admin_rights will be ignored and a template will be assigned with predefined permission set.")

// Retrieve, delete
flagContributorId(contributorRetrieveCmd)
Expand Down
32 changes: 32 additions & 0 deletions cmd/permissiontemplate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package cmd

import (
"github.com/spf13/cobra"
)

var permissionTemplateCmd = &cobra.Command{
Use: "permission-template",
Short: "Manage permission templates for a team",
Long: "Manage all templates for permissions inside a team.",
}

var permissionTemplateListCmd = &cobra.Command{
Use: "list",
Short: "List permission templates",
Long: "Retrieves a list of permission templates.",
RunE: func(*cobra.Command, []string) error {
c := Api.PermissionTemplates()
data, err := c.ListPermissionRoles(teamId)
if err != nil {
return err
}
return printJson(data)
},
}

func init() {
permissionTemplateCmd.AddCommand(permissionTemplateListCmd)
rootCmd.AddCommand(permissionTemplateCmd)

flagTeamId(permissionTemplateCmd)
}
22 changes: 12 additions & 10 deletions cmd/teamusergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,13 @@ func init() {
fs := teamUserGroupCreateCmd.Flags()
fs.StringVar(&newGroup.Name, "name", "", "Name of the group (required).")
_ = teamUserGroupCreateCmd.MarkFlagRequired("name")
fs.BoolVar(&newGroup.IsReviewer, "is-reviewer", false, "Whether the group has reviewer access to the project (required).")
_ = teamUserGroupCreateCmd.MarkFlagRequired("is-reviewer")
fs.BoolVar(&newGroup.IsAdmin, "is-admin", false, "Whether the group has Admin access to the project (required).")
_ = teamUserGroupCreateCmd.MarkFlagRequired("is-admin")
fs.StringSliceVar(&newGroup.AdminRights, "admin-rights", []string{}, "List of group administrative permissions. Required if group has admin rights.")
fs.BoolVar(&newGroup.IsReviewer, "is-reviewer", false, "Whether the group has reviewer access to the project. ")
_ = fs.MarkDeprecated("is-reviewer", "--is-admin is deprecated and will be removed.")
fs.BoolVar(&newGroup.IsAdmin, "is-admin", false, "Whether the group has Admin access to the project.")
_ = fs.MarkDeprecated("is-admin", "--is-admin is deprecated and will be removed.")
fs.StringSliceVar(&newGroup.AdminRights, "admin-rights", []string{}, "List of group permissions.")
fs.StringVar(&groupLanguages, "languages", "", "List of languages. Required if group doesn't have admin rights. JSON, see https://lokalise.com/api2docs/curl/#transition-create-a-group-post")
fs.Int64Var(&newGroup.RoleId, "role-id", 0, "Permission template id for the contributor. By setting this admin-rights will be ignored and a template will be assigned with predefined permission set.")

// Retrieve, delete
flagGroupId(teamUserGroupRetrieveCmd)
Expand All @@ -209,12 +210,13 @@ func init() {
fs = teamUserGroupUpdateCmd.Flags()
fs.StringVar(&updateGroup.Name, "name", "", "Name of the group (required).")
_ = teamUserGroupUpdateCmd.MarkFlagRequired("name")
fs.BoolVar(&updateGroup.IsReviewer, "is-reviewer", false, "Whether the group has reviewer access to the project (required).")
_ = teamUserGroupUpdateCmd.MarkFlagRequired("is-reviewer")
fs.BoolVar(&updateGroup.IsAdmin, "is-admin", false, "Whether the group has Admin access to the project (required).")
_ = teamUserGroupUpdateCmd.MarkFlagRequired("is-admin")
fs.StringSliceVar(&updateGroup.AdminRights, "admin-rights", []string{}, "List of group administrative permissions. Required if group has admin rights.")
fs.BoolVar(&updateGroup.IsReviewer, "is-reviewer", false, "Whether the group has reviewer access to the project. Deprecated and will be removed, with only admin-rights or role-id serving as a permission source.")
_ = fs.MarkDeprecated("is-reviewer", "--is-admin is deprecated and will be removed.")
fs.BoolVar(&updateGroup.IsAdmin, "is-admin", false, "Whether the group has Admin access to the project. Deprecated and will be removed, but still required as of now.")
_ = fs.MarkDeprecated("is-reviewer", "--is-admin is deprecated and will be removed.")
fs.StringSliceVar(&updateGroup.AdminRights, "admin-rights", []string{}, "List of group permissions.")
fs.StringVar(&groupLanguages, "languages", "", "List of languages. Required if group doesn't have admin rights.")
fs.Int64Var(&updateGroup.RoleId, "role-id", 0, "Permission template id for the contributor. By setting this admin-rights will be ignored and a template will be assigned with predefined permission set.")

// Add projects
flagGroupId(teamUserGroupAddProjectsCmd)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/lokalise/lokalise-cli-2-go
go 1.21

require (
github.com/lokalise/go-lokalise-api/v4 v4.1.2
github.com/lokalise/go-lokalise-api/v4 v4.1.4
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.16.0
Expand Down
8 changes: 2 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lokalise/go-lokalise-api/v4 v3.4.0 h1:W1uVB6kD2bZeMknBGW2cDwZapg+fHzu6KDYfzM4C7G4=
github.com/lokalise/go-lokalise-api/v4 v3.4.0/go.mod h1:STLXSf6OiwRdBRpK+BtA6deHh1Qjb69mYnI99HnMRHo=
github.com/lokalise/go-lokalise-api/v4 v4.1.1 h1:qM8HeGobvfltVXnWGUdFRc5tCLEkxR6SoPpfEl7mZaw=
github.com/lokalise/go-lokalise-api/v4 v4.1.1/go.mod h1:wBcA49IR9o4h3PLuNHbN2tu5BfY3xmO3fFyzTyD0XPs=
github.com/lokalise/go-lokalise-api/v4 v4.1.2 h1:qdzbj2lRWXF4YESy6PUkdnbDoEnOql82RXmv8pr54nU=
github.com/lokalise/go-lokalise-api/v4 v4.1.2/go.mod h1:wBcA49IR9o4h3PLuNHbN2tu5BfY3xmO3fFyzTyD0XPs=
github.com/lokalise/go-lokalise-api/v4 v4.1.4 h1:wsTC3qgTxweCNc/jizfZLjZBB68tONedxt1+YiB4448=
github.com/lokalise/go-lokalise-api/v4 v4.1.4/go.mod h1:wBcA49IR9o4h3PLuNHbN2tu5BfY3xmO3fFyzTyD0XPs=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
Expand Down
Loading