// -------------------------------------------------
// bodies.tsp
// Standard bodies for requests or responses.
// -------------------------------------------------
import "@typespec/http";
import "@microsoft/typespec-msgraph";
import "./shared-models.tsp";

using TypeSpec.Http;
using MsGraph;
using MsGraph.SharedModels;

// Raw body models represent the content of the response body, without any additional metadata.
// Note that these are primarily marker types.  CSDL has no notion of what actual body content is returned in such types,
// but by passing markers through, HIDI can translate to OpenAPI.
// The content of the types exists for other future emitters that run directly off TypeSpec.
namespace MsGraph.Bodies {

  /** Complex type to represent a nested error that potentially has other recursive nested errors. */
  @error
  model InnerError {
    code: string;
    innererror: InnerError | null; // Small e for error NOT a typo.
  }

  /** Complex type to represent a standard Microsoft Graph error. */
  @error
  model GraphError {
    code: string;
    message: string;
    localizedMessage: string;
    target: string | null;
    innererror: InnerError | null;  // Small e for error NOT a typo.
    details: GraphError[];
  }

  @error
  model ErrorBody {
    error: GraphError;
  }


  model CollectionBody<TResource> {
    value: TResource[];
    `@odata.count`?: int64;
  }

  @pagedCollection
  model PagedCollectionBody<TResource> is CollectionBody<TResource> {
    `@odata.nextLink`?: MsGraph.SharedModels.graphUrl;
  }

  @pagedCollection
  @deltaCollection
  model DeltaCollectionBody<TResource> is PagedCollectionBody<TResource> {
    `@odata.deltaLink`?: MsGraph.SharedModels.graphUrl;
  }

  /** A body representing any image type. */
  model ImageBody {
    @header contentType: "image/*";
    @body _:bytes;
  }

  /** Binary body of one or more (unioned string) content types */
  model BinaryBody<TContentType> {
    @header contentType: TContentType;
    @body _:bytes;
  }

}
