Exemplo n.º 1
0
// runIndex issues the command talking to the web service.
func runIndex(cmd *cobra.Command, args []string) error {
	cmd.Printf("Ensure Indexes : Name[%s]\n", index.name)

	set, err := runGetSet(cmd, index.name)
	if err != nil {
		return err
	}

	verb := "PUT"
	url := "/v1/index/" + index.name

	data, err := json.Marshal(set)
	if err != nil {
		return err
	}

	cmd.Printf("\n%s\n\n", string(data))

	if _, err := web.Request(cmd, verb, url, bytes.NewBuffer(data)); err != nil {
		return err
	}

	cmd.Println("\n", "Ensure Indexes : Ensured")
	return nil
}
Exemplo n.º 2
0
// runExecWeb issues the command talking to the web service.
func runExecWeb(cmd *cobra.Command, vars map[string]string) error {
	verb := "GET"
	url := "/v1/exec/" + exe.name

	if len(vars) > 0 {
		var i int
		for k, v := range vars {
			if i == 0 {
				url += "?"
			} else {
				url += "&"
			}
			i++

			url += k + "=" + v
		}
	}

	resp, err := web.Request(cmd, verb, url, nil)
	if err != nil {
		return err
	}

	cmd.Printf("\n%s\n\n", resp)
	return nil
}
Exemplo n.º 3
0
// runDelete issues the command talking to the web service.
func runDelete(cmd *cobra.Command, args []string) error {
	verb := "DELETE"
	url := "/v1/query/" + delete.name

	if _, err := web.Request(cmd, verb, url, nil); err != nil {
		return err
	}

	cmd.Println("Deleting Set : Deleted")
	return nil
}
Exemplo n.º 4
0
// runDelete issues the command talking to the web service.
func runDelete(cmd *cobra.Command, args []string) error {
	verb := "DELETE"
	url := "/v1/relationship/" + delete.predicate

	if _, err := web.Request(cmd, verb, url, nil); err != nil {
		return err
	}

	cmd.Println("Deleting Relationship : Deleted")
	return nil
}
Exemplo n.º 5
0
// runDelete issues the command talking to the web service.
func runDelete(cmd *cobra.Command, args []string) error {
	verb := "DELETE"
	url := "/v1/mask/" + delete.collection + "/" + delete.field

	if _, err := web.Request(cmd, verb, url, nil); err != nil {
		return err
	}

	cmd.Println("Deleting Mask : Deleted")
	return nil
}
Exemplo n.º 6
0
// runGet issues the command talking to the web service.
func runGet(cmd *cobra.Command, args []string) error {
	verb := "GET"
	url := "/v1/query/" + get.name

	resp, err := web.Request(cmd, verb, url, nil)
	if err != nil {
		return err
	}

	cmd.Printf("\n%s\n\n", resp)
	return nil
}
Exemplo n.º 7
0
// runGet issues the command talking to the web service.
func runGet(cmd *cobra.Command, args []string) error {
	verb := "GET"
	url := "/v1/relationship"

	if get.predicate != "" {
		url += "/" + get.predicate
	}

	resp, err := web.Request(cmd, verb, url, nil)
	if err != nil {
		return err
	}

	cmd.Printf("\n%s\n\n", resp)
	return nil
}
Exemplo n.º 8
0
// runGetSet get a query set by name.
func runGetSet(cmd *cobra.Command, name string) (query.Set, error) {
	verb := "GET"
	url := "/v1/query/" + name

	resp, err := web.Request(cmd, verb, url, nil)
	if err != nil {
		return query.Set{}, err
	}

	var set query.Set
	if err = json.Unmarshal([]byte(resp), &set); err != nil {
		return query.Set{}, err
	}

	return set, nil
}
Exemplo n.º 9
0
// runUpsertWeb issues the command talking to the web service.
func runUpsertWeb(cmd *cobra.Command, msk mask.Mask) error {
	verb := "PUT"
	url := "/v1/mask"

	data, err := json.Marshal(msk)
	if err != nil {
		return err
	}

	cmd.Printf("\n%s\n\n", string(data))

	if _, err := web.Request(cmd, verb, url, bytes.NewBuffer(data)); err != nil {
		return err
	}

	return nil
}
Exemplo n.º 10
0
// runUpsertWeb issues the command talking to the web service.
func runUpsertWeb(cmd *cobra.Command, rel relationship.Relationship) error {
	verb := "PUT"
	url := "/v1/relationship"

	data, err := json.Marshal(rel)
	if err != nil {
		return err
	}

	cmd.Printf("\n%s\n\n", string(data))

	if _, err := web.Request(cmd, verb, url, bytes.NewBuffer(data)); err != nil {
		return err
	}

	return nil
}
Exemplo n.º 11
0
// runGet issues the command talking to the web service.
func runGet(cmd *cobra.Command, args []string) error {
	verb := "GET"
	url := "/v1/mask"

	if get.collection != "" {
		url += "/" + get.collection
	}

	if get.field != "" {
		url += "/" + get.field
	}

	resp, err := web.Request(cmd, verb, url, nil)
	if err != nil {
		return err
	}

	cmd.Printf("\n%s\n\n", resp)
	return nil
}