grants

package
v0.15.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 18, 2024 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = cli.Command{
	Name:        "grants",
	Action:      cli.ShowSubcommandHelp,
	Description: "Administer grants",
	Subcommands: []*cli.Command{&CreateCommand},
}
View Source
var CreateCommand = cli.Command{
	Name: "create",
	Action: func(c *cli.Context) error {
		api, err := types.NewClientWithResponses(c.String("api-url"))
		if err != nil {
			return err
		}

		b := types.PostGrantsJSONRequestBody{
			Subject:  "chris@commonfate.io",
			Start:    iso8601.New(time.Now().Add(time.Second * 2)),
			End:      iso8601.New(time.Now().Add(time.Hour)),
			Provider: "cf-dev",
			With: types.CreateGrant_With{
				AdditionalProperties: map[string]string{"accountId": "123451234512"},
			},
		}

		res, err := api.PostGrantsWithResponse(c.Context, b)
		if err != nil {
			return err
		}

		if res.StatusCode() == http.StatusCreated {
			zap.S().Infow("created grant", "grant", res.JSON201.Grant)
		} else {
			zap.S().Infow("error creating grant", "error", res.JSON400.Error)
		}

		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL