// (c) 2025 ANSYS, Inc. Unauthorized use, distribution, or duplication is prohibited. ANSYS Confidential Information
syntax = "proto3";

package ansys.api.speos.part.v1;

// Part definition, a Part is related to a CAD part file (scdocx, prt, ...) made of meshed bodies and faces
message Part
{
	// Instance of Part in parent coordinates system
	message PartInstance
	{
		string name = 1;
		string description = 2;
		string part_guid = 3; // Guid of Part in PartsManager
		repeated double axis_system = 11; // Part position relative to parent reference (Ox Oy Oz Xx Xy Xz Yx Yy Yz Zx Zy Zz). If the coordinate system is not orthonormal, it will be automatically orthonormalized
	}

	string name = 1;
	string description = 2;
	map<string, string> metadata = 3; // User defined metadata
	repeated string body_guids = 10; // List of bodies constituting the part
	repeated PartInstance parts = 20; // List of sub parts
}

// Service to manage geometrical objects
service PartsManager {
	// Create a new part
	rpc Create(Create_Request) returns (Create_Response) {}
	// Read a part
	rpc Read(Read_Request) returns (Read_Response) {}
	// Update a part
	rpc Update(Update_Request) returns (Update_Response) {}
	// Delete a part
	rpc Delete(Delete_Request) returns (Delete_Response) {}
	// List all parts in manager
	rpc List(List_Request) returns (List_Response) {}
	// Read the whole database, use a field mask in message grpc request metadata (key = read_masks) to only get needed fields.
	// i.e.: parts.*.name -> would only return the names of the bodies in the message
	rpc ReadAll(ReadAll_Request) returns (ReadAll_Response){}
}

// Request to create an element
message Create_Request {
    Part part = 1; // Element to create
}
// Response to create an element
message Create_Response {
	string guid = 1; // Guid of the created element
}

// Request to read an element
message Read_Request {
	string guid = 1; // Guid of the element to be read
}
// Response to read an element
message Read_Response {
	Part part = 1; // Element corresponding to the guid given in Read_Request
}

// Request to update an element
message Update_Request {
	string guid = 1; // Guid of the PartTemplate to be updated
	Part part = 2; // New element that will be used for the update
}
// Response to update an element
message Update_Response {
}

// Request to delete an element
message Delete_Request {
	string guid = 1; // Guid of the element to be deleted
}
// Response to delete an element
message Delete_Response {}

// Request to list all elements
message List_Request {}
// Response to list all elements
message List_Response {
	repeated string guids = 1; // Guids of all Parts
}

// Request to read all parts
message ReadAll_Request{
}
// Response to read all parts
message ReadAll_Response{
	map<string, Part> parts = 1; // Read parts with their Guids
}

// Actions available on a Part
service PartActions {
}

