jkawamoto/roadie

View on GitHub
cloud/azure/batch/client/files/file_get_from_task_responses.go

Summary

Maintainability
D
2 days
Test Coverage
package files

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
    "fmt"
    "io"

    "github.com/go-openapi/errors"
    "github.com/go-openapi/runtime"
    "github.com/go-openapi/swag"

    strfmt "github.com/go-openapi/strfmt"

    "github.com/jkawamoto/roadie/cloud/azure/batch/models"
)

// FileGetFromTaskReader is a Reader for the FileGetFromTask structure.
type FileGetFromTaskReader struct {
    formats strfmt.Registry
}

// ReadResponse reads a server response into the received o.
func (o *FileGetFromTaskReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
    switch response.Code() {

    case 200:
        result := NewFileGetFromTaskOK()
        if err := result.readResponse(response, consumer, o.formats); err != nil {
            return nil, err
        }
        return result, nil

    default:
        result := NewFileGetFromTaskDefault(response.Code())
        if err := result.readResponse(response, consumer, o.formats); err != nil {
            return nil, err
        }
        if response.Code()/100 == 2 {
            return result, nil
        }
        return nil, result
    }
}

// NewFileGetFromTaskOK creates a FileGetFromTaskOK with default headers values
func NewFileGetFromTaskOK() *FileGetFromTaskOK {
    return &FileGetFromTaskOK{}
}

/*FileGetFromTaskOK handles this case with default header values.

A response containing the file content.
*/
type FileGetFromTaskOK struct {
    /*The length of the file.
     */
    ContentLength int64
    /*The content type of the file.
     */
    ContentType string
    /*The ETag HTTP response header. This is an opaque string. You can use it to detect whether the resource has changed between requests. In particular, you can pass the ETag to one of the If-Modified-Since, If-Unmodified-Since, If-Match or If-None-Match headers.
     */
    ETag string
    /*The time at which the resource was last modified.
     */
    LastModified string
    /*The client-request-id provided by the client during the request. This will be returned only if the return-client-request-id parameter was set to true.
     */
    ClientRequestID string
    /*Whether the object represents a directory.
     */
    OcpBatchFileIsdirectory bool
    /*The file mode attribute in octal format.
     */
    OcpBatchFileMode string
    /*The URL of the file.
     */
    OcpBatchFileURL string
    /*The file creation time.
     */
    OcpCreationTime string
    /*This header uniquely identifies the request that was made and can be used for troubleshooting the request. If a request is consistently failing and you have verified that the request is properly formulated, you may use this value to report the error to Microsoft. In your report, include the value of this header, the approximate time that the request was made, the Batch account against which the request was made, and the region that account resides in.
     */
    RequestID string

    Payload runtime.File
}

func (o *FileGetFromTaskOK) Error() string {
    return fmt.Sprintf("[GET /jobs/{jobId}/tasks/{taskId}/files/{fileName}][%d] fileGetFromTaskOK  %+v", 200, o.Payload)
}

func (o *FileGetFromTaskOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

    // response header Content-Length
    contentLength, err := swag.ConvertInt64(response.GetHeader("Content-Length"))
    if err != nil {
        return errors.InvalidType("Content-Length", "header", "int64", response.GetHeader("Content-Length"))
    }
    o.ContentLength = contentLength

    // response header Content-Type
    o.ContentType = response.GetHeader("Content-Type")

    // response header ETag
    o.ETag = response.GetHeader("ETag")

    // response header Last-Modified
    o.LastModified = response.GetHeader("Last-Modified")

    // response header client-request-id
    o.ClientRequestID = response.GetHeader("client-request-id")

    // response header ocp-batch-file-isdirectory
    ocpBatchFileIsdirectory, err := swag.ConvertBool(response.GetHeader("ocp-batch-file-isdirectory"))
    if err != nil {
        return errors.InvalidType("ocp-batch-file-isdirectory", "header", "bool", response.GetHeader("ocp-batch-file-isdirectory"))
    }
    o.OcpBatchFileIsdirectory = ocpBatchFileIsdirectory

    // response header ocp-batch-file-mode
    o.OcpBatchFileMode = response.GetHeader("ocp-batch-file-mode")

    // response header ocp-batch-file-url
    o.OcpBatchFileURL = response.GetHeader("ocp-batch-file-url")

    // response header ocp-creation-time
    o.OcpCreationTime = response.GetHeader("ocp-creation-time")

    // response header request-id
    o.RequestID = response.GetHeader("request-id")

    // response payload
    if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
        return err
    }

    return nil
}

// NewFileGetFromTaskDefault creates a FileGetFromTaskDefault with default headers values
func NewFileGetFromTaskDefault(code int) *FileGetFromTaskDefault {
    return &FileGetFromTaskDefault{
        _statusCode: code,
    }
}

/*FileGetFromTaskDefault handles this case with default header values.

The error from the Batch service.
*/
type FileGetFromTaskDefault struct {
    _statusCode int

    Payload *models.BatchError
}

// Code gets the status code for the file get from task default response
func (o *FileGetFromTaskDefault) Code() int {
    return o._statusCode
}

func (o *FileGetFromTaskDefault) Error() string {
    return fmt.Sprintf("[GET /jobs/{jobId}/tasks/{taskId}/files/{fileName}][%d] File_GetFromTask default  %+v", o._statusCode, o.Payload)
}

func (o *FileGetFromTaskDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {

    o.Payload = new(models.BatchError)

    // response payload
    if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF {
        return err
    }

    return nil
}