15#ifndef ZYPP_MEDIA_PRIVATE_PROVIDE_MESSAGE_P_H_INCLUDED
16#define ZYPP_MEDIA_PRIVATE_PROVIDE_MESSAGE_P_H_INCLUDED
18#include <zypp-core/base/PtrTypes.h>
19#include <zypp-core/zyppng/pipelines/Expected>
20#include <zypp-core/zyppng/rpc/MessageStream>
21#include <zypp-media/ng/ProvideSpec>
22#include <zypp-media/ng/HeaderValueMap>
25#include <zypp-proto/media/provider.pb.h>
34 namespace ProvideStartedMsgFields
36 constexpr std::string_view
Url (
"url");
41 namespace ProvideFinishedMsgFields
44 constexpr std::string_view
CacheHit (
"cacheHit");
47 namespace AuthInfoMsgFields
49 constexpr std::string_view
Username (
"username");
50 constexpr std::string_view
Password (
"password");
52 constexpr std::string_view
AuthType (
"authType");
55 namespace RedirectMsgFields
57 constexpr std::string_view
NewUrl (
"new_url");
60 namespace MetalinkRedirectMsgFields
62 constexpr std::string_view
NewUrl (
"new_url");
65 namespace ErrMsgFields
67 constexpr std::string_view
Reason (
"reason");
69 constexpr std::string_view
History (
"history");
72 namespace ProvideMsgFields
74 constexpr std::string_view Url (
"url");
75 constexpr std::string_view
Filename (
"filename");
76 constexpr std::string_view
DeltaFile (
"delta_file");
82 namespace AttachMsgFields
84 constexpr std::string_view Url (
"url");
85 constexpr std::string_view
AttachId (
"attach_id");
88 constexpr std::string_view
MediaNr (
"media_nr");
89 constexpr std::string_view
Device (
"device");
90 constexpr std::string_view
Label (
"label");
93 namespace DetachMsgFields
95 constexpr std::string_view Url (
"url");
98 namespace AuthDataRequestMsgFields
106 namespace MediaChangeRequestMsgFields
108 constexpr std::string_view
Label (
"label");
109 constexpr std::string_view
MediaNr (
"media_nr");
110 constexpr std::string_view
Device (
"device");
111 constexpr std::string_view
Desc (
"desc");
114 namespace EjectMsgFields
116 constexpr std::string_view
device (
"device");
122 using Code = zypp::proto::MessageCodes;
125 static expected<ProvideMessage>
create (
const zyppng::RpcMessage &message );
126 static expected<ProvideMessage>
create (
const zypp::proto::ProvideMessage &message );
131 static ProvideMessage createAuthInfo (
const uint32_t reqId,
const std::string &user,
const std::string &pw, int64_t timestamp,
const std::map<std::string, std::string> &extraValues = {} );
139 ,
const std::optional<std::string> &filename = {}
140 ,
const std::optional<std::string> &deltaFile = {}
141 ,
const std::optional<int64_t> &expFilesize = {}
142 ,
bool checkExistOnly = false );
148 ,
const std::string attachId
149 ,
const std::string &label
150 ,
const std::optional<std::string> &verifyType = {}
151 ,
const std::optional<std::string> &verifyData = {}
152 ,
const std::optional<int32_t> &mediaNr = {} );
155 static ProvideMessage createAuthDataRequest (
const uint32_t reqId,
const zypp::Url &effectiveUrl,
const std::string &lastTriedUser =
"",
const std::optional<int64_t> &lastAuthTimestamp = {},
const std::map<std::string, std::string> &extraValues = {} );
156 static ProvideMessage createMediaChangeRequest (
const uint32_t reqId,
const std::string &label, int32_t mediaNr,
const std::vector<std::string> &devices,
const std::optional<std::string> &desc );
162 void setCode (
const uint newCode );
164 std::vector<FieldVal>
values (
const std::string_view &
str )
const;
165 std::vector<FieldVal>
values (
const std::string &
str )
const;
166 HeaderValueMap
headers()
const;
177 void forEachVal(
const std::function<
bool(
const std::string &name,
const FieldVal &val)> &cb )
const;
179 zypp::proto::ProvideMessage &
impl();
180 const zypp::proto::ProvideMessage &
impl()
const;
191 {
return new zypp::proto::ProvideMessage(*rhs); }
static ProvideMessage createProvideStarted(const uint32_t reqId, const zypp::Url &url, const std::optional< std::string > &localFilename={}, const std::optional< std::string > &stagingFilename={})
static ProvideMessage createAuthInfo(const uint32_t reqId, const std::string &user, const std::string &pw, int64_t timestamp, const std::map< std::string, std::string > &extraValues={})
zypp::RWCOW_pointer< zypp::proto::ProvideMessage > _impl
static ProvideMessage createRedirect(const uint32_t reqId, const zypp::Url &newUrl)
static ProvideMessage createMetalinkRedir(const uint32_t reqId, const std::vector< zypp::Url > &newUrls)
static ProvideMessage createCancel(const uint32_t reqId)
void forEachVal(const std::function< bool(const std::string &name, const FieldVal &val)> &cb) const
HeaderValueMap headers() const
static ProvideMessage createMediaChanged(const uint32_t reqId)
static ProvideMessage createProvideFinished(const uint32_t reqId, const std::string &localFilename, bool cacheHit)
static expected< ProvideMessage > create(const zyppng::RpcMessage &message)
zypp::proto::MessageCodes Code
std::vector< FieldVal > values(const std::string_view &str) const
static ProvideMessage createMediaChangeRequest(const uint32_t reqId, const std::string &label, int32_t mediaNr, const std::vector< std::string > &devices, const std::optional< std::string > &desc)
static ProvideMessage createAttachFinished(const uint32_t reqId)
zypp::proto::ProvideMessage & impl()
FieldVal value(const std::string_view &str, const FieldVal &defaultVal=FieldVal()) const
void setCode(const uint newCode)
void setValue(const std::string &name, const FieldVal &value)
static ProvideMessage createAuthDataRequest(const uint32_t reqId, const zypp::Url &effectiveUrl, const std::string &lastTriedUser="", const std::optional< int64_t > &lastAuthTimestamp={}, const std::map< std::string, std::string > &extraValues={})
static ProvideMessage createProvide(const uint32_t reqId, const zypp::Url &url, const std::optional< std::string > &filename={}, const std::optional< std::string > &deltaFile={}, const std::optional< int64_t > &expFilesize={}, bool checkExistOnly=false)
void setRequestId(const uint id)
static ProvideMessage createDetachFinished(const uint32_t reqId)
void addValue(const std::string &name, const FieldVal &value)
static ProvideMessage createDetach(const uint32_t reqId, const zypp::Url &attachUrl)
static ProvideMessage createErrorResponse(const uint32_t reqId, const uint code, const std::string &reason, bool transient=false)
static ProvideMessage createAttach(const uint32_t reqId, const zypp::Url &url, const std::string attachId, const std::string &label, const std::optional< std::string > &verifyType={}, const std::optional< std::string > &verifyData={}, const std::optional< int32_t > &mediaNr={})
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
zypp::proto::ProvideMessage * rwcowClone< zypp::proto::ProvideMessage >(const zypp::proto::ProvideMessage *rhs)
constexpr std::string_view AttachId("attach_id")
constexpr std::string_view Device("device")
constexpr std::string_view VerifyData("verify_data")
constexpr std::string_view VerifyType("verify_type")
constexpr std::string_view Label("label")
constexpr std::string_view MediaNr("media_nr")
constexpr std::string_view LastUser("username")
constexpr std::string_view AuthHint("authHint")
constexpr std::string_view EffectiveUrl("effective_url")
constexpr std::string_view LastAuthTimestamp("last_auth_timestamp")
constexpr std::string_view Password("password")
constexpr std::string_view AuthType("authType")
constexpr std::string_view Username("username")
constexpr std::string_view AuthTimestamp("auth_timestamp")
constexpr std::string_view device("device")
constexpr std::string_view Reason("reason")
constexpr std::string_view History("history")
constexpr std::string_view Transient("transient")
constexpr std::string_view LocalFilename("local_filename")
constexpr std::string_view CacheHit("cacheHit")
constexpr std::string_view MetalinkEnabled("metalink_enabled")
constexpr std::string_view ExpectedFilesize("expected_filesize")
constexpr std::string_view DeltaFile("delta_file")
constexpr std::string_view CheckExistOnly("check_existance_only")
constexpr std::string_view Filename("filename")
constexpr std::string_view StagingFilename("staging_filename")
constexpr std::string_view Url("url")
constexpr std::string_view LocalFilename("local_filename")
constexpr std::string_view NewUrl("new_url")
RW_pointer supporting 'copy on write' functionality.