Documentation ¶
Overview ¶
Copyright © 2021-2022 Nikita Ivanovski info@slnt-opp.xyz
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2021-2022 Nikita Ivanovski info@slnt-opp.xyz
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2021-2022 Nikita Ivanovski info@slnt-opp.xyz
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2021-2022 Nikita Ivanovski info@slnt-opp.xyz
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2021-2022 Nikita Ivanovski info@slnt-opp.xyz
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2021-2022 Nikita Ivanovski info@slnt-opp.xyz
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CreateCmd = &cobra.Command{ Use: "create [title] [namespace UUID] [flags]", Aliases: []string{"crt", "c"}, Short: "Create NoCloud Account", Long: "Authorization data flags must be given('auth-type', 'auth-data')", Args: cobra.MinimumNArgs(2), RunE: func(cmd *cobra.Command, args []string) error { ctx, client := MakeAccountsServiceClientOrFail() authType, _ := cmd.Flags().GetString("auth-type") authData, _ := cmd.Flags().GetStringSlice("auth-data") if strings.Join(authData, "") == "" { return errors.New("Authorization Data wasn't given") } credentials := accountspb.Credentials{ Type: (authType), Data: authData, } access, _ := cmd.Flags().GetInt32("access-level") req := accountspb.CreateRequest{ Title: args[0], Namespace: args[1], Auth: &credentials, Access: &access, } res, err := client.Create(ctx, &req) if err != nil { return err } ok, err := tools.PrintJsonDataQ(cmd, res) if err != nil { return err } if !ok { fmt.Println("UUID:", res.GetUuid()) } return nil }, }
CreateCmd represents the create command
var DeleteCmd = &cobra.Command{ Use: "delete [UUID]", Aliases: []string{"del", "d"}, Short: "Delete NoCloud Account", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx, client := MakeAccountsServiceClientOrFail() res, err := client.Delete(ctx, &accountspb.DeleteRequest{ Uuid: args[0], }) if err != nil { return err } ok, err := tools.PrintJsonDataQ(cmd, res) if err != nil { return err } if !ok { fmt.Printf("Result: %t\n", res.GetResult()) } return nil }, }
DeleteCmd represents the delete command
var GetCmd = &cobra.Command{ Use: "get [UUID]", Short: "Get NoCloud Account Data", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx, client := MakeAccountsServiceClientOrFail() res, err := client.Get(ctx, &accountspb.GetRequest{ Uuid: args[0], }) if err != nil { return err } ok, err := tools.PrintJsonDataQ(cmd, res) if err != nil { return err } if !ok { PrintAccount(res) } return nil }, }
GetCmd represents the get command
var ListCmd = &cobra.Command{ Use: "list [[NAMESPACE]] [[flags]]", Aliases: []string{"l", "ls"}, Short: "List NoCloud Accounts", Long: `Add namespace UUID after list command, to filter accounts by namespace`, RunE: func(cmd *cobra.Command, args []string) error { ctx, client := MakeAccountsServiceClientOrFail() request := accountspb.ListRequest{} if len(args) > 0 { request.Namespace = &args[0] } d, _ := cmd.Flags().GetInt32("depth") request.Depth = &d res, err := client.List(ctx, &request) if err != nil { return err } ok, err := tools.PrintJsonDataQ(cmd, res) if err != nil { return err } if !ok { PrintAccountsPool(res.GetPool()) } return nil }, }
ListCmd represents the list command
var UpdateCmd = &cobra.Command{ Use: "update [account UUID] [flags]", Aliases: []string{"upd"}, Short: "Update NoCloud Account", Long: "In order to execute request you must change at least one field.", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { ctx, client := MakeAccountsServiceClientOrFail() updated := false req := accountspb.Account{ Uuid: args[0], } title, _ := cmd.Flags().GetString("title") if title != "" { req.Title = title updated = true } if !updated { return errors.New("no fields updated, exiting") } res, err := client.Update(ctx, &req) if err != nil { return err } ok, err := tools.PrintJsonDataQ(cmd, res) if err != nil { return err } if !ok { fmt.Printf("Result: %t\n", res.GetResult()) } return nil }, }
UpdateCmd represents the update command
Functions ¶
func MakeAccountsServiceClientOrFail ¶
func MakeAccountsServiceClientOrFail() (context.Context, regpb.AccountsServiceClient)
func PrintAccount ¶
func PrintAccountsPool ¶
Types ¶
This section is empty.