<commit_before>package kong

import (
	"fmt"
	"net/http"

	"github.com/dghubble/sling"
	"github.com/hashicorp/terraform/helper/schema"
)

type API struct {
	ID                     string      `json:"id,omitempty"`
	Name                   string      `json:"name,omitempty"`
	Hosts                  interface{} `json:"hosts,omitempty"`
	URIs                   interface{} `json:"uris,omitempty"`
	StripURI               bool        `json:"strip_uri,omitempty"`
	PreserveHost           bool        `json:"preserve_host,omitempty"`
	UpstreamURL            string      `json:"upstream_url,omitempty"`
	Methods                interface{} `json:"methods,omitempty"`
	Retries                int         `json:"retries,omitempty"`
	HTTPSOnly              bool        `json:"https_only,omitempty"`
	HTTPIfTerminated       bool        `json:"http_if_terminated,omitempty"`
	UpstreamConnectTimeout int         `json:"upstream_connect_timeout,omitempty"`
	UpstreamSendTimeout    int         `json:"upstream_send_timeout,omitempty"`
	UpstreamReadTimeout    int         `json:"upstream_read_timeout,omitempty"`
}

func resourceKongAPI() *schema.Resource {
	return &schema.Resource{
		Create: resourceKongAPICreate,
		Read:   resourceKongAPIRead,
		Update: resourceKongAPIUpdate,
		Delete: resourceKongAPIDelete,

		Schema: map[string]*schema.Schema{
			"id": &schema.Schema{
				Type:     schema.TypeString,
				Computed: true,
			},

			"name": &schema.Schema{
				Type:        schema.TypeString,
				Optional:    true,
				Default:     nil,
				Description: "The API name.",
			},

			"hosts": &schema.Schema{
				Type:        schema.TypeList,
				Elem:        &schema.Schema{Type: schema.TypeString},
				Optional:    true,
				Default:     nil,
				Description: "A comma-separated list of domain names that point to your API. For example: example.com. At least one of hosts, uris, or methods should be specified.",
			},

			"uris": &schema.Schema{
				Type:        schema.TypeList,
				Elem:        &schema.Schema{Type: schema.TypeString},
				Optional:    true,
				Default:     nil,
				Description: "A comma-separated list of URIs prefixes that point to your API. For example: /my-path. At least one of hosts, uris, or methods should be specified.",
			},

			"strip_uri": &schema.Schema{
				Type:        schema.TypeBool,
				Optional:    true,
				Default:     false,
				Description: "Strip the request_path value before proxying the request to the final API. For example a request made to /someservice/hello will be resolved to upstream_url/hello. By default is false.",
			},

			"preserve_host": &schema.Schema{
				Type:        schema.TypeBool,
				Optional:    true,
				Default:     false,
				Description: "Preserves the original Host header sent by the client, instead of replacing it with the hostname of the upstream_url. By default is false.",
			},

			"upstream_url": &schema.Schema{
				Type:        schema.TypeString,
				Required:    true,
				Description: "The base target URL that points to your API server, this URL will be used for proxying requests. For example, https://mockbin.com.",
			},

			"methods": &schema.Schema{
				Type:        schema.TypeList,
				Elem:        &schema.Schema{Type: schema.TypeString},
				Optional:    true,
				Default:     nil,
				Description: "A comma-separated list of HTTP methods that point to your API. For example: GET,POST. At least one of hosts, uris, or methods should be specified.",<commit_msg>Never omit strip_uri and default to true<commit_after>package kong

import (
	"fmt"
	"net/http"

	"github.com/dghubble/sling"
	"github.com/hashicorp/terraform/helper/schema"
)

type API struct {
	ID                     string      `json:"id,omitempty"`
	Name                   string      `json:"name,omitempty"`
	Hosts                  interface{} `json:"hosts,omitempty"`
	URIs                   interface{} `json:"uris,omitempty"`
	StripURI               bool        `json:"strip_uri"`
	PreserveHost           bool        `json:"preserve_host,omitempty"`
	UpstreamURL            string      `json:"upstream_url,omitempty"`
	Methods                interface{} `json:"methods,omitempty"`
	Retries                int         `json:"retries,omitempty"`
	HTTPSOnly              bool        `json:"https_only,omitempty"`
	HTTPIfTerminated       bool        `json:"http_if_terminated,omitempty"`
	UpstreamConnectTimeout int         `json:"upstream_connect_timeout,omitempty"`
	UpstreamSendTimeout    int         `json:"upstream_send_timeout,omitempty"`
	UpstreamReadTimeout    int         `json:"upstream_read_timeout,omitempty"`
}

func resourceKongAPI() *schema.Resource {
	return &schema.Resource{
		Create: resourceKongAPICreate,
		Read:   resourceKongAPIRead,
		Update: resourceKongAPIUpdate,
		Delete: resourceKongAPIDelete,

		Schema: map[string]*schema.Schema{
			"id": &schema.Schema{
				Type:     schema.TypeString,
				Computed: true,
			},

			"name": &schema.Schema{
				Type:        schema.TypeString,
				Optional:    true,
				Default:     nil,
				Description: "The API name.",
			},

			"hosts": &schema.Schema{
				Type:        schema.TypeList,
				Elem:        &schema.Schema{Type: schema.TypeString},
				Optional:    true,
				Default:     nil,
				Description: "A comma-separated list of domain names that point to your API. For example: example.com. At least one of hosts, uris, or methods should be specified.",
			},

			"uris": &schema.Schema{
				Type:        schema.TypeList,
				Elem:        &schema.Schema{Type: schema.TypeString},
				Optional:    true,
				Default:     nil,
				Description: "A comma-separated list of URIs prefixes that point to your API. For example: /my-path. At least one of hosts, uris, or methods should be specified.",
			},

			"strip_uri": &schema.Schema{
				Type:        schema.TypeBool,
				Optional:    true,
				Default:     true,
				Description: "Strip the request_path value before proxying the request to the final API. For example a request made to /someservice/hello will be resolved to upstream_url/hello. By default is false.",
			},

			"preserve_host": &schema.Schema{
				Type:        schema.TypeBool,
				Optional:    true,
				Default:     false,
				Description: "Preserves the original Host header sent by the client, instead of replacing it with the hostname of the upstream_url. By default is false.",
			},

			"upstream_url": &schema.Schema{
				Type:        schema.TypeString,
				Required:    true,
				Description: "The base target URL that points to your API server, this URL will be used for proxying requests. For example, https://mockbin.com.",
			},

			"methods": &schema.Schema{
				Type:        schema.TypeList,
				Elem:        &schema.Schema{Type: schema.TypeString},
				Optional:    true,
				Default:     nil,
				Description: "A comma-separated list of HTTP methods that point to your API. For example: GET,POST. At least one of hosts, uris, or methods should be specified.",
{'fraction_non_alphanumeric': 0.09945150115473442, 'fraction_numerical': 0.0, 'mean_word_length': 2.6719660837307897, 'pattern_counts': {'":': 16, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6311981', 'n_tokens_mistral': 2278, 'n_tokens_neox': 1958, 'n_words': 591}