Skip to content

Commit bc8fec1

Browse files
authored
fix(gosdk): change signature of ImportFile to accept content as []byte and set Content-Type during ExportFile (#500)
1 parent 9b82894 commit bc8fec1

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

assets/pango/client.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ func (c *Client) Communicate(ctx context.Context, cmd util.PangoCommand, strip b
971971
}
972972

973973
// ImportFile imports the given file into PAN-OS.
974-
func (c *Client) ImportFile(ctx context.Context, cmd *xmlapi.Import, content, filename, fp string, strip bool, ans any) ([]byte, *http.Response, error) {
974+
func (c *Client) ImportFile(ctx context.Context, cmd *xmlapi.Import, content []byte, filename, fp string, strip bool, ans any) ([]byte, *http.Response, error) {
975975
if cmd == nil {
976976
return nil, nil, fmt.Errorf("cmd is nil")
977977
}
@@ -1002,7 +1002,7 @@ func (c *Client) ImportFile(ctx context.Context, cmd *xmlapi.Import, content, fi
10021002
return nil, nil, err
10031003
}
10041004

1005-
if _, err = io.Copy(w2, strings.NewReader(content)); err != nil {
1005+
if _, err = io.Copy(w2, bytes.NewReader(content)); err != nil {
10061006
return nil, nil, err
10071007
}
10081008

@@ -1038,6 +1038,8 @@ func (c *Client) ExportFile(ctx context.Context, cmd *xmlapi.Export, ans any) (s
10381038
return "", nil, nil, err
10391039
}
10401040

1041+
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
1042+
10411043
b, resp, err := c.sendRequest(ctx, req, false, ans)
10421044
if err != nil {
10431045
return "", b, resp, err

assets/pango/util/pangoclient.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type PangoClient interface {
3434

3535
// Specialized communication functions around specific XPI API commands.
3636
MultiConfig(context.Context, *xmlapi.MultiConfig, bool, url.Values) ([]byte, *http.Response, *xmlapi.MultiConfigResponse, error)
37-
ImportFile(context.Context, *xmlapi.Import, string, string, string, bool, any) ([]byte, *http.Response, error)
37+
ImportFile(context.Context, *xmlapi.Import, []byte, string, string, bool, any) ([]byte, *http.Response, error)
3838
ExportFile(context.Context, *xmlapi.Export, any) (string, []byte, *http.Response, error)
3939

4040
// Operational functions in use by one or more resources / data sources / namespaces.

pkg/translate/structs.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,6 @@ const structToXmlMarshalersTmpl = `
937937
{{- if .IsXmlContainer }}{{ continue }}{{ end }}
938938
func (o *{{ .XmlStructName }}) MarshalFromObject(s {{ .StructName }}) {
939939
{{- range .Fields }}
940-
// FieldType: {{ .FieldType }}
941940
{{- if .IsInternal }}{{ continue }}{{- end }}
942941
{{- if eq .FieldType "object" }}
943942
if s.{{ .Name.CamelCase }} != nil {

0 commit comments

Comments
 (0)