func AddSecretVersion(w io.Writer, parent string) error {
	// parent := "projects/my-project/secrets/my-secret"

	// Get the payload to store. We are generate a random number and store as payload.

	secret_value , err := common.GenerateRandomString(20)

	if err != nil {
		return err
	}

	payload := []byte(secret_value)

	// Create the client.
	ctx := context.Background()
	client, err := secretmanager.NewClient(ctx)
	if err != nil {
			return fmt.Errorf("failed to create secretmanager client: %v", err)
	}
	defer client.Close()

	// Build the request.
	req := &secretmanagerpb.AddSecretVersionRequest{
			Parent: parent,
			Payload: &secretmanagerpb.SecretPayload{
					Data: payload,
			},
	}

	// Call the API.
	result, err := client.AddSecretVersion(ctx, req)
	if err != nil {
			return fmt.Errorf("failed to add secret version: %v", err)
	}
	fmt.Fprintf(w, "Added secret version: %s\n", result.Name)
	return nil
}
// addSecretVersion adds a new secret version to the given secret with the
// provided payload.
addSecretVersion adds a new secret version to the given secret with the
provided payload.
// addSecretVersion adds a new secret version to the given secret with the // provided payload .
func AddSecretVersion(w io.Writer, parent string) error {
	secret_value , err := common.GenerateRandomString(20)
	if err != nil {
		return err
	}
	payload := []byte(secret_value)
	ctx := context.Background()
	client, err := secretmanager.NewClient(ctx)
	if err != nil {
			return fmt.Errorf("failed to create secretmanager client: %v", err)
	}
	defer client.Close()
	req := &secretmanagerpb.AddSecretVersionRequest{
			Parent: parent,
			Payload: &secretmanagerpb.SecretPayload{
					Data: payload,
			},
	}
	result, err := client.AddSecretVersion(ctx, req)
	if err != nil {
			return fmt.Errorf("failed to add secret version: %v", err)
	}
	fmt.Fprintf(w, "Added secret version: %s\n", result.Name)
	return nil
}
func AddSecretVersion ( w io . Writer , parent string ) error { secret_value , err := common . GenerateRandomString ( 20 ) if err != nil { return err } payload := [ ] byte ( secret_value ) ctx := context . Background ( ) client , err := secretmanager . NewClient ( ctx ) if err != nil { return fmt . Errorf ( " " , err ) } defer client . Close ( ) req := & secretmanagerpb . AddSecretVersionRequest { Parent : parent , Payload : & secretmanagerpb . SecretPayload { Data : payload , } , } result , err := client . AddSecretVersion ( ctx , req ) if err != nil { return fmt . Errorf ( " " , err ) } fmt . Fprintf ( w , " \n " , result . Name ) return nil }
addSecretVersion adds a new secret version to the given secret with the
provided payload.
addSecretVersion adds a new secret version to the given secret with the provided payload .
// parent := "projects/my-project/secrets/my-secret" // Get the payload to store. We are generate a random number and store as payload. // Create the client. // Build the request. // Call the API.